tests/test-template-graph.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 02:54:19 +0200
changeset 51586 1cef1412af3e
parent 45895 fc4fb2f17dd4
permissions -rw-r--r--
phases: rework the logic of _pushdiscoveryphase to bound complexity This rework the various graph traversal in _pushdiscoveryphase to keep the complexity in check. This is done though a couple of things: - first, limiting the space we have to explore, for example, if we are not in publishing push, we don't need to consider remote draft roots that are also draft locally, as there is nothing to be moved there. - avoid unbounded descendant computation, and use the faster "rev between" computation. This provide a massive boost to performance when exchanging with repository with a massive amount of draft, like mozilla-try: ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # benchmark.name = hg.command.push # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.reuse-external-delta-parent = default ## benchmark.variants.revs = any-1-extra-rev before: 20.346590 seconds after: 11.232059 seconds (-38.15%, -7.48 seconds) ## benchmark.variants.revs = any-100-extra-rev before: 24.752051 seconds after: 15.367412 seconds (-37.91%, -9.38 seconds) After this changes, the push operation is still quite too slow. Some of this can be attributed to general phases slowness (reading all the roots from disk for example) and other know slowness (not using persistent-nodemap, branchmap, tags, etc. We are also working on them, but with this series, phase discovery during push no longer showing up in profile and this is a pretty nice and bit low-hanging fruit out of the way. ### (same case as the above) # benchmark.variants.revs = any-1-extra-rev pre-%ln-change: 44.235070 this-changeset: 11.232059 seconds (-74.61%, -33.00 seconds) # benchmark.variants.revs = any-100-extra-rev pre-%ln-change: 49.234697 this-changeset: 15.367412 seconds (-68.79%, -33.87 seconds) Note that with this change, the `hg push` performance is now much closer to the `hg pull` performance, even it still lagging behind a bit. (and the overall performance are still too slow). ### data-env-vars.name = mozilla-try-2023-03-22-ds2-pnm # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default # bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 6.517450 hg.command.push: 11.219888 ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 10.160991 hg.command.push: 14.251107 ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.577772 hg.command.push: 11.232059 ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.152976 hg.command.push: 15.367412 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.731982 hg.command.push: 11.178751 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.184236 hg.command.push: 15.620843

Test graph-related template functions
=====================================

  $ cat <<'EOF' >> $HGRCPATH
  > [extensions]
  > drawdag = $RUNTESTDIR/drawdag.py
  > EOF

  $ hg init a
  $ cd a

  $ hg debugdrawdag <<'EOF'
  >   l
  >  / \
  > |   k
  > |   |\
  > |   | j
  > |   | |
  > i   | |
  > |\  | |
  > h | | |
  > | | | |
  > | g | |
  > | | | |
  > f | | |
  > | |/ /
  > | e |
  > | |/
  > | d
  > |/|
  > c |
  > | |
  > b |
  >   |
  >   a
  > EOF

  $ hg log -Gq -T'{rev} {tags}\n'
  o    11 l tip
  |\
  | o    10 i
  | |\
  o \ \    9 k
  |\ \ \
  +-----o  8 g
  | | |
  | o |  7 j
  | | |
  | | o  6 h
  | | |
  o | |  5 e
  |/ /
  | o  4 f
  | |
  o |  3 d
  |\|
  | o  2 c
  | |
  | o  1 b
  |
  o  0 a
  

  $ cd ..

Create repository containing merges of p1 > p2:

  $ hg init named-branch-order
  $ cd named-branch-order

  $ hg branch -q b0
  $ hg ci -m 0
  $ hg up -q null
  $ hg branch -q b1
  $ hg ci -m 1
  $ hg up -q null
  $ hg branch -q b2
  $ hg ci -m 2
  $ hg merge -q 1
  $ hg ci -m 3
  $ hg ci -m 4 --config ui.allowemptycommit=true
  $ hg merge -q 0
  $ hg ci -m 5
  $ hg ci -m 6 --config ui.allowemptycommit=true
  $ hg up -q 1
  $ hg branch -q b7
  $ hg ci -m 7
  $ hg ci -m 8 --config ui.allowemptycommit=true
  $ hg up -q 6
  $ hg ci -m 9 --config ui.allowemptycommit=true
  $ hg up -q 8
  $ hg merge -q 9
  $ hg ci -m 10

  $ hg log -Gq -T'{rev} {branch} -> {p1.rev} {p2.rev}\n'
  @    10 b7 -> 8 9
  |\
  | o  9 b2 -> 6 -1
  | |
  o |  8 b7 -> 7 -1
  | |
  o |  7 b7 -> 1 -1
  | |
  | o  6 b2 -> 5 -1
  | |
  | o    5 b2 -> 4 0
  | |\
  | | o  4 b2 -> 3 -1
  | | |
  +---o  3 b2 -> 2 1
  | | |
  | | o  2 b2 -> -1 -1
  | |
  o |  1 b1 -> -1 -1
   /
  o  0 b0 -> -1 -1
  

  $ cd ..

subsetparents
-------------

  $ cd a

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+i"))}\n' -r 'c+i'
  o  10 i: 2
  :
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+i"))}\n' -r 'c+h+i'
  o    10 i: 6
  |\
  o :  6 h: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+l"))}\n' -r 'c+h+l'
  o    11 l tip: 6
  :\
  : o  6 h: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+f+l"))}\n' -r 'c+f+l'
  o    11 l tip: 4
  :\
  : o  4 f: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+i+k"))}\n' -r 'c+h+i+k'
  o    10 i: 6
  |\
  | : o  9 k: 2
  | :/
  o :  6 h: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+d+h+i+k"))}\n' -r 'c+d+h+i+k'
  o    10 i: 6 3
  |\
  | : o  9 k: 3
  | :/
  o :  6 h: 2
  : :
  : o  3 d: 2
  :/|
  : ~
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+j+k+i"))}\n' -r 'c+j+k+i'
  o  10 i: 2
  :
  : o  9 k: 7
  :/|
  : o  7 j: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+e+f+j"))}\n' -r 'c+e+f+j'
  o  7 j: 2
  :
  : o  5 e: 2
  :/
  : o  4 f: 2
  :/
  o  2 c:
  |
  ~

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+e+f+j"))}\n' -r 'b+e+f+j'
  o  7 j: 1
  :
  : o  5 e: 1
  :/
  : o  4 f: 1
  :/
  o  1 b:
  

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("a+c+f+g+j+l"))}\n' -r 'a+c+f+g+j+l'
  o    11 l tip: 4 8 7
  :\
  : \
  : :\
  : : \
  : : :\
  : : : \
  : : : :\
  : o---+ :  8 g: 0 2
  : :/ / /
  : +---o  7 j: 0 2
  : : :/
  o---+  4 f: 2
   / /
  : o  2 c:
  : |
  : ~
  o  0 a:
  

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+i+l"))}\n' -r 'b+i+l'
  o    11 l tip: 10
  |\
  o :  10 i: 1
  :/
  o  1 b:
  

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+i+j+l"))}\n' -r 'b+i+j+l'
  o    11 l tip: 10 7
  |\
  | \
  | :\
  o : :  10 i: 1
  :/ /
  : o  7 j: 1
  :/
  o  1 b:
  

null in subset:

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("null+a+c+f"))}\n' -r 'null+a+c+f'
  o  4 f: 2
  |
  o  2 c: -1
  :
  : o  0 a: -1
  :/
  @  -1 : -1
  

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("null+a+b+c+f"))}\n' -r 'null+a+b+c+f'
  o  4 f: 2
  |
  o  2 c: 1
  |
  o  1 b: -1
  |
  | o  0 a: -1
  |/
  @  -1 : -1
  

wdir in subset:

  $ hg update -qC i

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("f+k+wdir()"))}\n' -r 'f+k+wdir()'
  o  2147483647 : 4
  :
  : o    9 k:
  : |\
  : ~ ~
  o  4 f:
  |
  ~

  $ hg update -qC null

Revisions not in subset:

  $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("a+c+f+g+j+l"))}\n'
  11 l tip: 4 8 7
  10 i: 
  9 k: 
  8 g: 0 2
  7 j: 0 2
  6 h: 
  5 e: 
  4 f: 2
  3 d: 
  2 c: 
  1 b: 
  0 a: 

  $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("b+c"))}\n'
  11 l tip: 
  10 i: 
  9 k: 
  8 g: 
  7 j: 
  6 h: 
  5 e: 
  4 f: 
  3 d: 
  2 c: 1
  1 b: 
  0 a: 

  $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("b+c"))}\n' -r'reverse(null:2)'
  2 c: 1
  1 b: 
  0 a: 
  -1 : 

Nothing excluded:

  $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("null:wdir()"))}\n' -r'reverse(null:wdir())'
  2147483647 : -1
  11 l tip: 10 9
  10 i: 6 8
  9 k: 5 7
  8 g: 5
  7 j: 3
  6 h: 4
  5 e: 3
  4 f: 2
  3 d: 0 2
  2 c: 1
  1 b: -1
  0 a: -1
  -1 : -1

Uncachable query:

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("%d:%d", rev, rev - 1))}\n'
  o    11 l tip: 10
  |\
  | o    10 i:
  | |\
  o \ \    9 k:
  |\ \ \
  +-----o  8 g:
  | | |
  | o |  7 j:
  | | |
  | | o  6 h:
  | | |
  o | |  5 e:
  |/ /
  | o  4 f:
  | |
  o |  3 d: 2
  |\|
  | o  2 c: 1
  | |
  | o  1 b:
  |
  o  0 a: -1
  

Invalid arguments:

  $ hg log -T '{subsetparents()}\n'
  hg: parse error: subsetparents expects two arguments
  [10]
  $ hg log -T '{subsetparents("a")}\n'
  hg: parse error: subsetparents expects two arguments
  [10]
  $ hg log -T '{subsetparents(rev, extras)}\n'
  hg: parse error: subsetparents expects a queried revset
  [10]

  $ cd ..

subsetparents: p1/p2 order
-------------------------

  $ cd named-branch-order

Parents should be sorted in p1/p2 order since p1 is likely to belong to
the same named branch:

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+6"))}\n' -r '0+1+2+6'
  o    6 : 2 1 0
  :\
  : \
  : :\
  : : o  2 :
  : :
  : o  1 :
  :
  o  0 :
  

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+6+10"))}\n' -r '0+1+2+6+10'
  @    10 tip: 6
  :\
  : o    6 : 2 1 0
  :/:\
  : : o  2 :
  : :
  o :  1 :
   /
  o  0 :
  

And p1 path should be selected if both p1/p2 paths exist:

  $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+10"))}\n' -r '0+1+2+10'
  @    10 tip: 1 2 0
  :\
  : \
  : :\
  : : o  2 :
  : :
  o :  1 :
   /
  o  0 :
  

  $ cd ..