Mercurial > hg
view tests/test-rebase-rename.t @ 44363:f7459da77f23
nodemap: introduce an option to use mmap to read the nodemap mapping
The performance and memory benefit is much greater if we don't have to copy all
the data in memory for each information. So we introduce an option (on by
default) to read the data using mmap.
This changeset is the last one definition the API for index support nodemap
data. (they have to be able to use the mmaping).
Below are some benchmark comparing the best we currently have in 5.3 with the
final step of this series (using the persistent nodemap implementation in
Rust). The benchmark run `hg perfindex` with various revset and the following
variants:
Before:
* do not use the persistent nodemap
* use the CPython implementation of the index for nodemap
* use mmapping of the changelog index
After:
* use the MixedIndex Rust code, with the NodeTree object for nodemap access
(still in review)
* use the persistent nodemap data from disk
* access the persistent nodemap data through mmap
* use mmapping of the changelog index
The persistent nodemap greatly speed up most operation on very large
repositories. Some of the previously very fast lookup end up a bit slower because
the persistent nodemap has to be setup. However the absolute slowdown is very
small and won't matters in the big picture.
Here are some numbers (in seconds) for the reference copy of mozilla-try:
Revset Before After abs-change speedup
-10000: 0.004622 0.005532 0.000910 × 0.83
-10: 0.000050 0.000132 0.000082 × 0.37
tip 0.000052 0.000085 0.000033 × 0.61
0 + (-10000:) 0.028222 0.005337 -0.022885 × 5.29
0 0.023521 0.000084 -0.023437 × 280.01
(-10000:) + 0 0.235539 0.005308 -0.230231 × 44.37
(-10:) + :9 0.232883 0.000180 -0.232703 ×1293.79
(-10000:) + (:99) 0.238735 0.005358 -0.233377 × 44.55
:99 + (-10000:) 0.317942 0.005593 -0.312349 × 56.84
:9 + (-10:) 0.313372 0.000179 -0.313193 ×1750.68
:9 0.316450 0.000143 -0.316307 ×2212.93
On smaller repositories, the cost of nodemap related operation is not as big, so
the win is much more modest. Yet it helps shaving a handful of millisecond here
and there.
Here are some numbers (in seconds) for the reference copy of mercurial:
Revset Before After abs-change speedup
-10: 0.000065 0.000097 0.000032 × 0.67
tip 0.000063 0.000078 0.000015 × 0.80
0 0.000561 0.000079 -0.000482 × 7.10
-10000: 0.004609 0.003648 -0.000961 × 1.26
0 + (-10000:) 0.005023 0.003715 -0.001307 × 1.35
(-10:) + :9 0.002187 0.000108 -0.002079 ×20.25
(-10000:) + 0 0.006252 0.003716 -0.002536 × 1.68
(-10000:) + (:99) 0.006367 0.003707 -0.002660 × 1.71
:9 + (-10:) 0.003846 0.000110 -0.003736 ×34.96
:9 0.003854 0.000099 -0.003755 ×38.92
:99 + (-10000:) 0.007644 0.003778 -0.003866 × 2.02
Differential Revision: https://phab.mercurial-scm.org/D7894
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 11 Feb 2020 11:18:52 +0100 |
parents | 45ec64d93b3a |
children | f90a5c211251 |
line wrap: on
line source
$ cat >> $HGRCPATH <<EOF > [extensions] > rebase= > > [alias] > tlog = log --template "{rev}: {node|short} '{desc}' {branches}\n" > tglog = tlog --graph > EOF $ hg init a $ cd a $ mkdir d $ echo a > a $ hg ci -Am A adding a $ echo b > d/b $ hg ci -Am B adding d/b $ hg mv d d-renamed moving d/b to d-renamed/b $ hg ci -m 'rename B' $ hg up -q -C 1 $ hg mv a a-renamed $ echo x > d/x $ hg add d/x $ hg ci -m 'rename A' created new head $ hg tglog @ 3: 73a3ee40125d 'rename A' | | o 2: 220d0626d185 'rename B' |/ o 1: 3ab5da9a5c01 'B' | o 0: 1994f17a630e 'A' Rename is tracked: $ hg tlog -p --git -r tip 3: 73a3ee40125d 'rename A' diff --git a/a b/a-renamed rename from a rename to a-renamed diff --git a/d/x b/d/x new file mode 100644 --- /dev/null +++ b/d/x @@ -0,0 +1,1 @@ +x Rebase the revision containing the rename: $ hg rebase -s 3 -d 2 rebasing 3:73a3ee40125d "rename A" (tip) saved backup bundle to $TESTTMP/a/.hg/strip-backup/73a3ee40125d-1d78ebcf-rebase.hg $ hg tglog @ 3: 032a9b75e83b 'rename A' | o 2: 220d0626d185 'rename B' | o 1: 3ab5da9a5c01 'B' | o 0: 1994f17a630e 'A' Rename is not lost: $ hg tlog -p --git -r tip 3: 032a9b75e83b 'rename A' diff --git a/a b/a-renamed rename from a rename to a-renamed diff --git a/d-renamed/x b/d-renamed/x new file mode 100644 --- /dev/null +++ b/d-renamed/x @@ -0,0 +1,1 @@ +x Rebased revision does not contain information about b (issue3739) $ hg log -r 3 --debug changeset: 3:032a9b75e83bff1dcfb6cbfa4ef50a704bf1b569 tag: tip phase: draft parent: 2:220d0626d185f372d9d8f69d9c73b0811d7725f7 parent: -1:0000000000000000000000000000000000000000 manifest: 3:035d66b27a1b06b2d12b46d41a39adb7a200c370 user: test date: Thu Jan 01 00:00:00 1970 +0000 files+: a-renamed d-renamed/x files-: a extra: branch=default extra: rebase_source=73a3ee40125d6f0f347082e5831ceccb3f005f8a description: rename A $ repeatchange() { > hg checkout $1 > hg cp a z > echo blah >> z > hg commit -Am "$2" --user "$3" > } $ repeatchange 1 "E" "user1" 2 files updated, 0 files merged, 3 files removed, 0 files unresolved created new head $ repeatchange 1 "E" "user2" 0 files updated, 0 files merged, 1 files removed, 0 files unresolved created new head $ hg tglog @ 5: af8ad1f97097 'E' | | o 4: 60f545c27784 'E' |/ | o 3: 032a9b75e83b 'rename A' | | | o 2: 220d0626d185 'rename B' |/ o 1: 3ab5da9a5c01 'B' | o 0: 1994f17a630e 'A' $ hg rebase -s 5 -d 4 rebasing 5:af8ad1f97097 "E" (tip) note: not rebasing 5:af8ad1f97097 "E" (tip), its destination already has all its changes saved backup bundle to $TESTTMP/a/.hg/strip-backup/af8ad1f97097-c3e90708-rebase.hg $ hg tglog @ 4: 60f545c27784 'E' | | o 3: 032a9b75e83b 'rename A' | | | o 2: 220d0626d185 'rename B' |/ o 1: 3ab5da9a5c01 'B' | o 0: 1994f17a630e 'A' $ hg export tip # HG changeset patch # User user1 # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 # Node ID 60f545c277846e6bad309919bae3ae106f59cb39 # Parent 3ab5da9a5c01faa02c20f2ec4870a4f689c92da6 E diff -r 3ab5da9a5c01 -r 60f545c27784 z --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/z Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,2 @@ +a +blah $ cd .. $ hg init b $ cd b $ echo a > a $ hg ci -Am A adding a $ echo b > b $ hg ci -Am B adding b $ hg cp b b-copied $ hg ci -Am 'copy B' $ hg up -q -C 1 $ hg cp a a-copied $ hg ci -m 'copy A' created new head $ hg tglog @ 3: 0a8162ff18a8 'copy A' | | o 2: 39e588434882 'copy B' |/ o 1: 6c81ed0049f8 'B' | o 0: 1994f17a630e 'A' Copy is tracked: $ hg tlog -p --git -r tip 3: 0a8162ff18a8 'copy A' diff --git a/a b/a-copied copy from a copy to a-copied Rebase the revision containing the copy: $ hg rebase -s 3 -d 2 rebasing 3:0a8162ff18a8 "copy A" (tip) saved backup bundle to $TESTTMP/b/.hg/strip-backup/0a8162ff18a8-dd06302a-rebase.hg $ hg tglog @ 3: 98f6e6dbf45a 'copy A' | o 2: 39e588434882 'copy B' | o 1: 6c81ed0049f8 'B' | o 0: 1994f17a630e 'A' Copy is not lost: $ hg tlog -p --git -r tip 3: 98f6e6dbf45a 'copy A' diff --git a/a b/a-copied copy from a copy to a-copied Rebased revision does not contain information about b (issue3739) $ hg log -r 3 --debug changeset: 3:98f6e6dbf45ab54079c2237fbd11066a5c41a11d tag: tip phase: draft parent: 2:39e588434882ff77d01229d169cdc77f29e8855e parent: -1:0000000000000000000000000000000000000000 manifest: 3:2232f329d66fffe3930d43479ae624f66322b04d user: test date: Thu Jan 01 00:00:00 1970 +0000 files+: a-copied extra: branch=default extra: rebase_source=0a8162ff18a8900df8df8ef7ac0046955205613e description: copy A $ cd .. Test rebase across repeating renames: $ hg init repo $ cd repo $ echo testing > file1.txt $ hg add file1.txt $ hg ci -m "Adding file1" $ hg rename file1.txt file2.txt $ hg ci -m "Rename file1 to file2" $ echo Unrelated change > unrelated.txt $ hg add unrelated.txt $ hg ci -m "Unrelated change" $ hg rename file2.txt file1.txt $ hg ci -m "Rename file2 back to file1" $ hg update -r -2 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo Another unrelated change >> unrelated.txt $ hg ci -m "Another unrelated change" created new head $ hg tglog @ 4: b918d683b091 'Another unrelated change' | | o 3: 1ac17e43d8aa 'Rename file2 back to file1' |/ o 2: 480101d66d8d 'Unrelated change' | o 1: be44c61debd2 'Rename file1 to file2' | o 0: 8ce9a346991d 'Adding file1' $ hg rebase -s 4 -d 3 rebasing 4:b918d683b091 "Another unrelated change" (tip) saved backup bundle to $TESTTMP/repo/.hg/strip-backup/b918d683b091-3024bc57-rebase.hg $ hg diff --stat -c . unrelated.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) $ cd .. Verify that copies get preserved (issue4192). $ hg init copy-gets-preserved $ cd copy-gets-preserved $ echo a > a $ hg add a $ hg commit --message "File a created" $ hg copy a b $ echo b > b $ hg commit --message "File b created as copy of a and modified" $ hg copy b c $ echo c > c $ hg commit --message "File c created as copy of b and modified" $ hg copy c d $ echo d > d $ hg commit --message "File d created as copy of c and modified" Note that there are four entries in the log for d $ hg tglog --follow d @ 3: 421b7e82bb85 'File d created as copy of c and modified' | o 2: 327f772bc074 'File c created as copy of b and modified' | o 1: 79d255d24ad2 'File b created as copy of a and modified' | o 0: b220cd6d2326 'File a created' Update back to before we performed copies, and inject an unrelated change. $ hg update 0 0 files updated, 0 files merged, 3 files removed, 0 files unresolved $ echo unrelated > unrelated $ hg add unrelated $ hg commit --message "Unrelated file created" created new head $ hg update 4 0 files updated, 0 files merged, 0 files removed, 0 files unresolved Rebase the copies on top of the unrelated change. $ hg rebase --source 1 --dest 4 rebasing 1:79d255d24ad2 "File b created as copy of a and modified" rebasing 2:327f772bc074 "File c created as copy of b and modified" rebasing 3:421b7e82bb85 "File d created as copy of c and modified" saved backup bundle to $TESTTMP/copy-gets-preserved/.hg/strip-backup/79d255d24ad2-a2265555-rebase.hg $ hg update 4 3 files updated, 0 files merged, 0 files removed, 0 files unresolved There should still be four entries in the log for d $ hg tglog --follow d @ 4: dbb9ba033561 'File d created as copy of c and modified' | o 3: af74b229bc02 'File c created as copy of b and modified' | o 2: 68bf06433839 'File b created as copy of a and modified' : o 0: b220cd6d2326 'File a created' Same steps as above, but with --collapse on rebase to make sure the copy records collapse correctly. $ hg co 1 0 files updated, 0 files merged, 3 files removed, 0 files unresolved $ echo more >> unrelated $ hg ci -m 'unrelated commit is unrelated' created new head $ hg rebase -s 2 --dest 5 --collapse rebasing 2:68bf06433839 "File b created as copy of a and modified" rebasing 3:af74b229bc02 "File c created as copy of b and modified" merging b and c to c rebasing 4:dbb9ba033561 "File d created as copy of c and modified" merging c and d to d saved backup bundle to $TESTTMP/copy-gets-preserved/.hg/strip-backup/68bf06433839-dde37595-rebase.hg $ hg co tip 3 files updated, 0 files merged, 0 files removed, 0 files unresolved This should show both revision 3 and 0 since 'd' was transitively a copy of 'a'. $ hg tglog --follow d @ 3: 5a46b94210e5 'Collapsed revision : * File b created as copy of a and modified : * File c created as copy of b and modified : * File d created as copy of c and modified' o 0: b220cd6d2326 'File a created' $ cd ..