annotate tests/test-addremove-similar.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
1 $ hg init rep; cd rep
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
2
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
3 $ touch empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
4 $ python -c 'for x in range(10000): print x' > large-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
5
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
6 $ hg addremove
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
7 adding empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
8 adding large-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
9
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
10 $ hg commit -m A
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
11
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
12 $ rm large-file empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
13 $ python -c 'for x in range(10,10000): print x' > another-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
14
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
15 $ hg addremove -s50
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
16 adding another-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
17 removing empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
18 removing large-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
19 recording removal of large-file as rename to another-file (99% similar)
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
20
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
21 $ hg commit -m B
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
22
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
23 comparing two empty files caused ZeroDivisionError in the past
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
24
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
25 $ hg update -C 0
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
26 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
27 $ rm empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
28 $ touch another-empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
29 $ hg addremove -s50
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
30 adding another-empty-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
31 removing empty-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
32
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
33 $ cd ..
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
34
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
35 $ hg init rep2; cd rep2
4472
736e49292809 addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4135
diff changeset
36
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
37 $ python -c 'for x in range(10000): print x' > large-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
38 $ python -c 'for x in range(50): print x' > tiny-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
39
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
40 $ hg addremove
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
41 adding large-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
42 adding tiny-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
43
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
44 $ hg commit -m A
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
45
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
46 $ python -c 'for x in range(70): print x' > small-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
47 $ rm tiny-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
48 $ rm large-file
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
49
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
50 $ hg addremove -s50
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
51 removing large-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
52 adding small-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
53 removing tiny-file
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
54 recording removal of tiny-file as rename to small-file (82% similar)
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
55
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
56 $ hg commit -m B
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
57
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
58 should all fail
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
59
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
60 $ hg addremove -s foo
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
61 abort: similarity must be a number
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11851
diff changeset
62 [255]
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
63 $ hg addremove -s -1
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
64 abort: similarity must be between 0 and 100
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11851
diff changeset
65 [255]
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
66 $ hg addremove -s 1e6
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
67 abort: similarity must be between 0 and 100
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11851
diff changeset
68 [255]
4135
6cb6cfe43c5d Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff changeset
69
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
70 $ cd ..
4966
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4472
diff changeset
71
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 12346
diff changeset
72 Issue1527: repeated addremove causes util.Abort
8489
1a96f1d9599b addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4966
diff changeset
73
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
74 $ hg init rep3; cd rep3
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
75 $ mkdir d
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
76 $ echo a > d/a
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
77 $ hg add d/a
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
78 $ hg commit -m 1
8489
1a96f1d9599b addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4966
diff changeset
79
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
80 $ mv d/a d/b
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
81 $ hg addremove -s80
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
82 removing d/a
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
83 adding d/b
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 12399
diff changeset
84 recording removal of d/a as rename to d/b (100% similar) (glob)
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
85 $ hg debugstate
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
86 r 0 0 1970-01-01 00:00:00 d/a
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
87 a 0 -1 unset d/b
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
88 copy: d/a -> d/b
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
89 $ mv d/b c
8489
1a96f1d9599b addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4966
diff changeset
90
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
91 no copies found here (since the target isn't in d
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
92
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
93 $ hg addremove -s80 d
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 12399
diff changeset
94 removing d/b (glob)
11851
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
95
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
96 copies here
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
97
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
98 $ hg addremove -s80
db955418a6af tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents: 8489
diff changeset
99 adding c
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 12399
diff changeset
100 recording removal of d/a as rename to c (100% similar) (glob)