Mercurial > hg
annotate tests/test-share.t @ 16120:47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Historically, during 'hg update', every largefile in the working copy was
hashed (which is a very expensive operation on big files) and any
largefiles that did not have a hash that matched their standin were
updated.
This patch optimizes 'hg update' by keeping track of what standins have
changed between the old and new revisions, and only updating the largefiles
that have changed. This saves a lot of time by avoiding the unecessary
calculation of a list of sha1 hashes for big files.
With this patch, the time 'hg update' takes to complete is a function of
how many largefiles need to be updated and what their size is.
Performance tests on a repository with about 80 largefiles ranging from
a few MB to about 97 MB are shown below. The tests show how long it takes
to run 'hg update' with no changes actually being updated.
Mercurial 2.1 release:
$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
getting changed largefiles
0 largefiles updated, 0 removed
real 0m10.045s
user 0m9.367s
sys 0m0.674s
With this patch:
$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
real 0m0.965s
user 0m0.845s
sys 0m0.115s
The same repsoitory, without the largefiles extension enabled:
$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
real 0m0.799s
user 0m0.684s
sys 0m0.111s
So before the patch, 'hg update' with no changes was approximately 9.25s
slower with largefiles enabled. With this patch, it is approximately 0.165s
slower.
author | Na'Tosha Bard <natosha@unity3d.com> |
---|---|
date | Mon, 13 Feb 2012 18:37:07 +0100 |
parents | 9910f60a37ee |
children | f2719b387380 |
rev | line source |
---|---|
15446
c5c9ca3719f9
tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents:
15101
diff
changeset
|
1 $ "$TESTDIR/hghave" serve || exit 80 |
9990 | 2 |
12487 | 3 $ echo "[extensions]" >> $HGRCPATH |
4 $ echo "share = " >> $HGRCPATH | |
5 | |
6 prepare repo1 | |
9990 | 7 |
12487 | 8 $ hg init repo1 |
9 $ cd repo1 | |
10 $ echo a > a | |
11 $ hg commit -A -m'init' | |
12 adding a | |
13 | |
14 share it | |
9990 | 15 |
12487 | 16 $ cd .. |
17 $ hg share repo1 repo2 | |
18 updating working directory | |
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
20 | |
21 share shouldn't have a store dir | |
22 | |
23 $ cd repo2 | |
24 $ test -d .hg/store | |
25 [1] | |
9990 | 26 |
12487 | 27 Some sed versions appends newline, some don't, and some just fails |
28 | |
29 $ cat .hg/sharedpath; echo | |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
15446
diff
changeset
|
30 $TESTTMP/repo1/.hg (glob) |
12487 | 31 |
15101
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
32 trailing newline on .hg/sharedpath is ok |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
33 $ hg tip -q |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
34 0:d3873e73d99e |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
35 $ echo '' >> .hg/sharedpath |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
36 $ cat .hg/sharedpath |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
15446
diff
changeset
|
37 $TESTTMP/repo1/.hg (glob) |
15101
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
38 $ hg tip -q |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
39 0:d3873e73d99e |
a21ccf4412d5
share: allow trailing newline on .hg/sharedpath.
Greg Ward <greg@gerg.ca>
parents:
15080
diff
changeset
|
40 |
12487 | 41 commit in shared clone |
42 | |
43 $ echo a >> a | |
44 $ hg commit -m'change in shared clone' | |
45 | |
46 check original | |
9990 | 47 |
12487 | 48 $ cd ../repo1 |
49 $ hg log | |
50 changeset: 1:8af4dc49db9e | |
51 tag: tip | |
52 user: test | |
53 date: Thu Jan 01 00:00:00 1970 +0000 | |
54 summary: change in shared clone | |
55 | |
56 changeset: 0:d3873e73d99e | |
57 user: test | |
58 date: Thu Jan 01 00:00:00 1970 +0000 | |
59 summary: init | |
60 | |
61 $ hg update | |
62 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
63 $ cat a # should be two lines of "a" | |
64 a | |
65 a | |
9990 | 66 |
12487 | 67 commit in original |
68 | |
69 $ echo b > b | |
70 $ hg commit -A -m'another file' | |
71 adding b | |
72 | |
73 check in shared clone | |
9990 | 74 |
12487 | 75 $ cd ../repo2 |
76 $ hg log | |
77 changeset: 2:c2e0ac586386 | |
78 tag: tip | |
79 user: test | |
80 date: Thu Jan 01 00:00:00 1970 +0000 | |
81 summary: another file | |
82 | |
83 changeset: 1:8af4dc49db9e | |
84 user: test | |
85 date: Thu Jan 01 00:00:00 1970 +0000 | |
86 summary: change in shared clone | |
87 | |
88 changeset: 0:d3873e73d99e | |
89 user: test | |
90 date: Thu Jan 01 00:00:00 1970 +0000 | |
91 summary: init | |
92 | |
93 $ hg update | |
94 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
95 $ cat b # should exist with one "b" | |
96 b | |
9990 | 97 |
12487 | 98 hg serve shared clone |
9990 | 99 |
12487 | 100 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid |
101 $ cat hg.pid >> $DAEMON_PIDS | |
102 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-file/' | |
103 200 Script output follows | |
104 | |
105 | |
106 -rw-r--r-- 4 a | |
107 -rw-r--r-- 2 b | |
108 | |
109 | |
15080
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
110 |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
111 test unshare command |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
112 |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
113 $ hg unshare |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
114 $ test -d .hg/store |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
115 $ test -f .hg/sharedpath |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
116 [1] |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
117 $ hg unshare |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
118 abort: this is not a shared repo |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
119 [255] |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
120 |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
121 check that a change does not propagate |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
122 |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
123 $ echo b >> b |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
124 $ hg commit -m'change in unshared' |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
125 $ cd ../repo1 |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
126 $ hg id -r tip |
574dc5d74f9b
test: test unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12640
diff
changeset
|
127 c2e0ac586386 tip |