Mercurial > hg
annotate tests/test-diff-reverse.t @ 47120:7109a38830c9
dirstate-tree: Fold "tracked descendants" counter update in main walk
For the purpose of implementing `has_tracked_dir` (which means "has tracked
descendants) without an expensive sub-tree traversal, we maintaing a counter
of tracked descendants on each "directory" node of the tree-shaped dirstate.
Before this changeset, mutating or inserting a node at a given path would
involve:
* Walking the tree from root through ancestors to find the node or the spot
where to insert it
* Looking at the previous node if any to decide what counter update is needed
* Performing any node mutation
* Walking the tree *again* to update counters in ancestor nodes
When profiling `hg status` on a large repo, this second walk takes times
while loading a the dirstate from disk.
It turns out we have enough information to decide before he first tree walk
what counter update is needed. This changeset merges the two walks, gaining
~10% of the total time for `hg update` (in the same hyperfine benchmark as
the previous changeset).
---
Profiling was done by compiling with this `.cargo/config`:
[profile.release]
debug = true
then running with:
py-spy record -r 500 -n -o /tmp/hg.json --format speedscope -- \
./hg status -R $REPO --config experimental.dirstate-tree.in-memory=1
then visualizing the recorded JSON file in https://www.speedscope.app/
Differential Revision: https://phab.mercurial-scm.org/D10554
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 30 Apr 2021 14:22:14 +0200 |
parents | c586cb50872b |
children | 55c6ebd11cb9 |
rev | line source |
---|---|
12139
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
1 $ hg init |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
diff
changeset
|
2 |
12139
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
3 $ cat > a <<EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
4 > a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
5 > b |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
6 > c |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
7 > EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
8 $ hg ci -Am adda |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
9 adding a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
10 |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
11 $ cat > a <<EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
12 > d |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
13 > e |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
14 > f |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
15 > EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
16 $ hg ci -m moda |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
diff
changeset
|
17 |
12139
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
18 $ hg diff --reverse -r0 -r1 |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
19 diff -r 2855cdcfcbb7 -r 8e1805a3cf6e a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
20 --- a/a Thu Jan 01 00:00:00 1970 +0000 |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
21 +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
22 @@ -1,3 +1,3 @@ |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
23 -d |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
24 -e |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
25 -f |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
26 +a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
27 +b |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
28 +c |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
diff
changeset
|
29 |
12139
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
30 $ cat >> a <<EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
31 > g |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
32 > h |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
33 > EOF |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
34 $ hg diff --reverse --nodates |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
35 diff -r 2855cdcfcbb7 a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
36 --- a/a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
37 +++ b/a |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
38 @@ -1,5 +1,3 @@ |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
39 d |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
40 e |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
41 f |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
42 -g |
5a69ea8d65b3
tests: unify test-diff-reverse
Adrian Buehlmann <adrian@cadifra.com>
parents:
9857
diff
changeset
|
43 -h |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
diff
changeset
|
44 |
23080
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
45 should show removed file 'a' as being added |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
46 $ hg revert a |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
47 $ hg rm a |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
48 $ hg diff --reverse --nodates a |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
49 diff -r 2855cdcfcbb7 a |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
50 --- /dev/null |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
51 +++ b/a |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
52 @@ -0,0 +1,3 @@ |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
53 +d |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
54 +e |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
55 +f |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
56 |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
57 should show added file 'b' as being removed |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
58 $ echo b >> b |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
59 $ hg add b |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
60 $ hg diff --reverse --nodates b |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
61 diff -r 2855cdcfcbb7 b |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
62 --- a/b |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
63 +++ /dev/null |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
64 @@ -1,1 +0,0 @@ |
c586cb50872b
context.status: remove incorrect swapping of added/removed in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
12139
diff
changeset
|
65 -b |