tests/test-narrow-exchange.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 02:54:19 +0200
changeset 51586 1cef1412af3e
parent 49825 2f2682f40ea0
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

#testcases lfs-on lfs-off

#if lfs-on
  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > lfs =
  > EOF
#endif

  $ . "$TESTDIR/narrow-library.sh"

create full repo

  $ hg init master
  $ cd master
  $ cat >> .hg/hgrc <<EOF
  > [narrow]
  > serveellipses=True
  > EOF

  $ mkdir inside
  $ echo 1 > inside/f
  $ mkdir inside2
  $ echo 1 > inside2/f
  $ mkdir outside
  $ echo 1 > outside/f
  $ hg ci -Aqm 'initial'

  $ echo 2 > inside/f
  $ hg ci -qm 'inside 2'

  $ echo 2 > inside2/f
  $ hg ci -qm 'inside2 2'

  $ echo 2 > outside/f
  $ hg ci -qm 'outside 2'

  $ cd ..

  $ hg clone --narrow ssh://user@dummy/master narrow --include inside
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 2 changes to 1 files
  new changesets *:* (glob)
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ hg clone --narrow ssh://user@dummy/master narrow2 --include inside --include inside2
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 4 changesets with 4 changes to 2 files
  new changesets *:* (glob)
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved

Can push to wider repo if change does not affect paths in wider repo that are
not also in narrower repo

  $ cd narrow
  $ echo 3 > inside/f
  $ hg ci -m 'inside 3'
  $ hg push ssh://user@dummy/narrow2
  pushing to ssh://user@dummy/narrow2
  searching for changes
  remote: adding changesets
  remote: adding manifests
  remote: adding file changes
  remote: added 1 changesets with 1 changes to 1 files

Can push to narrower repo if change affects only paths within remote's
narrow spec

  $ cd ../narrow2
  $ cat >> .hg/hgrc <<EOF
  > [narrow]
  > serveellipses=True
  > EOF
  $ hg co -r 'desc("inside 3")'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo 4 > inside/f
  $ hg ci -m 'inside 4'
  $ hg push ssh://user@dummy/narrow
  pushing to ssh://user@dummy/narrow
  searching for changes
  remote: adding changesets
  remote: adding manifests
  remote: adding file changes
  remote: added 1 changesets with 1 changes to 1 files

Can push to narrow repo if change affects only paths outside remote's
narrow spec

  $ echo 3 > inside2/f
  $ hg ci -m 'inside2 3'
TODO: this should be successful
  $ hg push ssh://user@dummy/narrow
  pushing to ssh://user@dummy/narrow
  searching for changes
  remote: adding changesets
  remote: adding manifests
  remote: adding file changes
  remote: transaction abort!
  remote: rollback completed
  remote: abort: data/inside2/f@4a1aa07735e673e20c00fae80f40dc301ee30616: unknown parent (reporevlogstore !)
  remote: abort: data/inside2/f/index@4a1aa07735e6: no node (reposimplestore !)
  abort: stream ended unexpectedly (got 0 bytes, expected 4)
  [255]

Can pull from wider repo if change affects only paths outside remote's
narrow spec
  $ echo 4 > inside2/f
  $ hg ci -m 'inside2 4'
  $ hg log -G -T '{rev} {node|short} {files}\n'
  @  7 d78a96df731d inside2/f
  |
  o  6 8c26f5218962 inside2/f
  |
  o  5 ba3480e2f9de inside/f
  |
  o  4 4e5edd526618 inside/f
  |
  o  3 81e7e07b7ab0 outside/f
  |
  o  2 f3993b8c0c2b inside2/f
  |
  o  1 8cd66ca966b4 inside/f
  |
  o  0 c8057d6f53ab inside/f inside2/f outside/f
  
  $ cd ../narrow
  $ hg log -G -T '{rev} {node|short} {files}\n'
  o  4 ba3480e2f9de inside/f
  |
  @  3 4e5edd526618 inside/f
  |
  o  2 81e7e07b7ab0 outside/f
  |
  o  1 8cd66ca966b4 inside/f
  |
  o  0 c8057d6f53ab inside/f inside2/f outside/f
  
  $ hg pull ssh://user@dummy/narrow2
  pulling from ssh://user@dummy/narrow2
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 0 changes to 0 files
  new changesets d78a96df731d
  (run 'hg update' to get a working copy)

Check that the resulting history is valid in the full repo

  $ cd ../narrow2
  $ hg push ssh://user@dummy/master
  pushing to ssh://user@dummy/master
  searching for changes
  remote: adding changesets
  remote: adding manifests
  remote: adding file changes
  remote: added 4 changesets with 4 changes to 2 files
  $ cd ../master
  $ hg verify -q

Can not push to wider repo if change affects paths in wider repo that are
not also in narrower repo
  $ cd ../master
  $ hg co -r 'desc("inside2 4")'
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo 5 > inside2/f
  $ hg ci -m 'inside2 5'
  $ hg log -G -T '{rev} {node|short} {files}\n'
  @  8 5970befb64ba inside2/f
  |
  o  7 d78a96df731d inside2/f
  |
  o  6 8c26f5218962 inside2/f
  |
  o  5 ba3480e2f9de inside/f
  |
  o  4 4e5edd526618 inside/f
  |
  o  3 81e7e07b7ab0 outside/f
  |
  o  2 f3993b8c0c2b inside2/f
  |
  o  1 8cd66ca966b4 inside/f
  |
  o  0 c8057d6f53ab inside/f inside2/f outside/f
  
  $ cd ../narrow
  $ hg pull
  pulling from ssh://user@dummy/master
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 0 changes to 0 files
  new changesets * (glob)
  (run 'hg update' to get a working copy)
TODO: this should tell the user that their narrow clone does not have the
necessary content to be able to push to the target

TODO: lfs shouldn't abort like this
  $ hg push ssh://user@dummy/narrow2 || true
  pushing to ssh://user@dummy/narrow2
  searching for changes
  remote: adding changesets
  remote: adding manifests
  remote: adding file changes
  remote: added 1 changesets with 0 changes to 0 files (no-lfs-on !)
  remote: error: pretxnchangegroup.lfs hook raised an exception: inside2/f@f59b4e0218355383d2789196f1092abcf2262b0c: no match found (lfs-on !)
  remote: transaction abort! (lfs-on !)
  remote: rollback completed (lfs-on !)
  remote: abort: inside2/f@f59b4e0218355383d2789196f1092abcf2262b0c: no match found (lfs-on !)
  abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)