Mercurial > hg
view tests/test-copies-in-changeset.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 | 30570a056fa8 |
children | ea9563e9e65a |
line wrap: on
line source
#testcases extra sidedata #if extra $ cat >> $HGRCPATH << EOF > [experimental] > copies.write-to=changeset-only > copies.read-from=changeset-only > [alias] > changesetcopies = log -r . -T 'files: {files} > {extras % "{ifcontains("files", key, "{key}: {value}\n")}"} > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' > EOF #endif #if sidedata $ cat >> $HGRCPATH << EOF > [format] > exp-use-copies-side-data-changeset = yes > EOF #endif $ cat >> $HGRCPATH << EOF > [alias] > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}' > [extensions] > rebase = > split = > EOF Check that copies are recorded correctly $ hg init repo $ cd repo #if sidedata $ hg debugformat -v format-variant repo config default fncache: yes yes yes dotencode: yes yes yes generaldelta: yes yes yes sparserevlog: yes yes yes sidedata: yes yes no copies-sdc: yes yes no plain-cl-delta: yes yes yes compression: zlib zlib zlib compression-level: default default default #else $ hg debugformat -v format-variant repo config default fncache: yes yes yes dotencode: yes yes yes generaldelta: yes yes yes sparserevlog: yes yes yes sidedata: no no no copies-sdc: no no no plain-cl-delta: yes yes yes compression: zlib zlib zlib compression-level: default default default #endif $ echo a > a $ hg add a $ hg ci -m initial $ hg cp a b $ hg cp a c $ hg cp a d $ hg ci -m 'copy a to b, c, and d' #if extra $ hg changesetcopies files: b c d filesadded: 0 1 2 p1copies: 0\x00a (esc) 1\x00a (esc) 2\x00a (esc) #else $ hg debugsidedata -c -v -- -1 2 sidedata entries entry-0010 size 11 '0\x00a\n1\x00a\n2\x00a' entry-0012 size 5 '0\n1\n2' #endif $ hg showcopies a -> b a -> c a -> d #if extra $ hg showcopies --config experimental.copies.read-from=compatibility a -> b a -> c a -> d $ hg showcopies --config experimental.copies.read-from=filelog-only #endif Check that renames are recorded correctly $ hg mv b b2 $ hg ci -m 'rename b to b2' #if extra $ hg changesetcopies files: b b2 filesadded: 1 filesremoved: 0 p1copies: 1\x00b (esc) #else $ hg debugsidedata -c -v -- -1 3 sidedata entries entry-0010 size 3 '1\x00b' entry-0012 size 1 '1' entry-0013 size 1 '0' #endif $ hg showcopies b -> b2 Rename onto existing file. This should get recorded in the changeset files list and in the extras, even though there is no filelog entry. $ hg cp b2 c --force $ hg st --copies M c b2 #if extra $ hg debugindex c rev linkrev nodeid p1 p2 0 1 b789fdd96dc2 000000000000 000000000000 #else $ hg debugindex c rev linkrev nodeid p1 p2 0 1 37d9b5d994ea 000000000000 000000000000 #endif $ hg ci -m 'move b onto d' #if extra $ hg changesetcopies files: c p1copies: 0\x00b2 (esc) #else $ hg debugsidedata -c -v -- -1 1 sidedata entries entry-0010 size 4 '0\x00b2' #endif $ hg showcopies b2 -> c #if extra $ hg debugindex c rev linkrev nodeid p1 p2 0 1 b789fdd96dc2 000000000000 000000000000 #else $ hg debugindex c rev linkrev nodeid p1 p2 0 1 37d9b5d994ea 000000000000 000000000000 1 3 029625640347 000000000000 000000000000 #endif Create a merge commit with copying done during merge. $ hg co 0 0 files updated, 0 files merged, 3 files removed, 0 files unresolved $ hg cp a e $ hg cp a f $ hg ci -m 'copy a to e and f' created new head $ hg merge 3 3 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) File 'a' exists on both sides, so 'g' could be recorded as being from p1 or p2, but we currently always record it as being from p1 $ hg cp a g File 'd' exists only in p2, so 'h' should be from p2 $ hg cp d h File 'f' exists only in p1, so 'i' should be from p1 $ hg cp f i $ hg ci -m 'merge' #if extra $ hg changesetcopies files: g h i filesadded: 0 1 2 p1copies: 0\x00a (esc) 2\x00f (esc) p2copies: 1\x00d (esc) #else $ hg debugsidedata -c -v -- -1 3 sidedata entries entry-0010 size 7 '0\x00a\n2\x00f' entry-0011 size 3 '1\x00d' entry-0012 size 5 '0\n1\n2' #endif $ hg showcopies a -> g d -> h f -> i Test writing to both changeset and filelog $ hg cp a j #if extra $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility $ hg changesetcopies files: j filesadded: 0 filesremoved: p1copies: 0\x00a (esc) p2copies: #else $ hg ci -m 'copy a to j' $ hg debugsidedata -c -v -- -1 2 sidedata entries entry-0010 size 3 '0\x00a' entry-0012 size 1 '0' #endif $ hg debugdata j 0 \x01 (esc) copy: a copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 \x01 (esc) a $ hg showcopies a -> j $ hg showcopies --config experimental.copies.read-from=compatibility a -> j $ hg showcopies --config experimental.copies.read-from=filelog-only a -> j Existing copy information in the changeset gets removed on amend and writing copy information on to the filelog #if extra $ hg ci --amend -m 'copy a to j, v2' \ > --config experimental.copies.write-to=filelog-only saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob) $ hg changesetcopies files: j #else $ hg ci --amend -m 'copy a to j, v2' saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob) $ hg debugsidedata -c -v -- -1 2 sidedata entries entry-0010 size 3 '0\x00a' entry-0012 size 1 '0' #endif $ hg showcopies --config experimental.copies.read-from=filelog-only a -> j The entries should be written to extras even if they're empty (so the client won't have to fall back to reading from filelogs) $ echo x >> j #if extra $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility $ hg changesetcopies files: j filesadded: filesremoved: p1copies: p2copies: #else $ hg ci -m 'modify j' $ hg debugsidedata -c -v -- -1 #endif Test writing only to filelog $ hg cp a k #if extra $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only $ hg changesetcopies files: k #else $ hg ci -m 'copy a to k' $ hg debugsidedata -c -v -- -1 2 sidedata entries entry-0010 size 3 '0\x00a' entry-0012 size 1 '0' #endif $ hg debugdata k 0 \x01 (esc) copy: a copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 \x01 (esc) a #if extra $ hg showcopies $ hg showcopies --config experimental.copies.read-from=compatibility a -> k $ hg showcopies --config experimental.copies.read-from=filelog-only a -> k #else $ hg showcopies a -> k #endif $ cd .. Test rebasing a commit with copy information $ hg init rebase-rename $ cd rebase-rename $ echo a > a $ hg ci -Aqm 'add a' $ echo a2 > a $ hg ci -m 'modify a' $ hg co -q 0 $ hg mv a b $ hg ci -qm 'rename a to b' $ hg rebase -d 1 --config rebase.experimental.inmemory=yes rebasing 2:* "rename a to b" (tip) (glob) merging a and b to b saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/*-*-rebase.hg (glob) $ hg st --change . --copies A b a R a $ cd .. Test splitting a commit $ hg init split $ cd split $ echo a > a $ echo b > b $ hg ci -Aqm 'add a and b' $ echo a2 > a $ hg mv b c $ hg ci -m 'modify a, move b to c' $ hg --config ui.interactive=yes split <<EOF > y > y > n > y > EOF diff --git a/a b/a 1 hunks, 1 lines changed examine changes to 'a'? (enter ? for help) [Ynesfdaq?] y @@ -1,1 +1,1 @@ -a +a2 record this change to 'a'? (enter ? for help) [Ynesfdaq?] y diff --git a/b b/c rename from b rename to c examine changes to 'b' and 'c'? (enter ? for help) [Ynesfdaq?] n created new head diff --git a/b b/c rename from b rename to c examine changes to 'b' and 'c'? (enter ? for help) [Ynesfdaq?] y saved backup bundle to $TESTTMP/split/.hg/strip-backup/*-*-split.hg (glob) $ cd .. Test committing half a rename $ hg init partial $ cd partial $ echo a > a $ hg ci -Aqm 'add a' $ hg mv a b $ hg ci -m 'remove a' a #if sidedata Test upgrading/downgrading to sidedata storage ============================================== downgrading (keeping some sidedata) $ hg debugformat -v format-variant repo config default fncache: yes yes yes dotencode: yes yes yes generaldelta: yes yes yes sparserevlog: yes yes yes sidedata: yes yes no copies-sdc: yes yes no plain-cl-delta: yes yes yes compression: zlib zlib zlib compression-level: default default default $ hg debugsidedata -c -- 0 1 sidedata entries entry-0012 size 1 $ hg debugsidedata -c -- 1 1 sidedata entries entry-0013 size 1 $ hg debugsidedata -m -- 0 $ cat << EOF > .hg/hgrc > [format] > exp-use-side-data = yes > exp-use-copies-side-data-changeset = no > EOF $ hg debugupgraderepo --run --quiet --no-backup > /dev/null $ hg debugformat -v format-variant repo config default fncache: yes yes yes dotencode: yes yes yes generaldelta: yes yes yes sparserevlog: yes yes yes sidedata: yes yes no copies-sdc: no no no plain-cl-delta: yes yes yes compression: zlib zlib zlib compression-level: default default default $ hg debugsidedata -c -- 0 $ hg debugsidedata -c -- 1 $ hg debugsidedata -m -- 0 upgrading $ cat << EOF > .hg/hgrc > [format] > exp-use-copies-side-data-changeset = yes > EOF $ hg debugupgraderepo --run --quiet --no-backup > /dev/null $ hg debugformat -v format-variant repo config default fncache: yes yes yes dotencode: yes yes yes generaldelta: yes yes yes sparserevlog: yes yes yes sidedata: yes yes no copies-sdc: yes yes no plain-cl-delta: yes yes yes compression: zlib zlib zlib compression-level: default default default $ hg debugsidedata -c -- 0 1 sidedata entries entry-0012 size 1 $ hg debugsidedata -c -- 1 1 sidedata entries entry-0013 size 1 $ hg debugsidedata -m -- 0 #endif $ cd ..