view tests/test-static-http.t @ 42743:8c9a6adec67a

rust-discovery: using the children cache in add_missing The DAG range computation often needs to get back to very old revisions, and turns out to be disproportionately long, given that the end goal is to remove the descendents of the given missing revisons from the undecided set. The fast iteration capabilities available in the Rust case make it possible to avoid the DAG range entirely, at the cost of precomputing the children cache, and to simply iterate on children of the given missing revisions. This is a case where staying on the same side of the interface between the two languages has clear benefits. On discoveries with initial undecided sets small enough to bypass sampling entirely, the total cost of computing the children cache and the subsequent iteration becomes better than the Python + C counterpart, which relies on reachableroots2. For example, on a repo with more than one million revisions with an initial undecided set of 11 elements, we get these figures: Rust version with simple iteration addcommons: 57.287us first undecided computation: 184.278334ms first children cache computation: 131.056us addmissings iteration: 42.766us first addinfo total: 185.24 ms Python + C version first addcommons: 0.29 ms addcommons 0.21 ms first undecided computation 191.35 ms addmissings 45.75 ms first addinfo total: 237.77 ms On discoveries with large undecided sets, the initial price paid makes the first addinfo slower than the Python + C version, but that's more than compensated by the gain in sampling and subsequent iterations. Here's an extreme example with an undecided set of a million revisions: Rust version: first undecided computation: 293.842629ms first children cache computation: 407.911297ms addmissings iteration: 34.312869ms first addinfo total: 776.02 ms taking initial sample query 2: sampling time: 1318.38 ms query 2; still undecided: 1005013, sample size is: 200 addmissings: 143.062us Python + C version: first undecided computation 298.13 ms addmissings 80.13 ms first addinfo total: 399.62 ms taking initial sample query 2: sampling time: 3957.23 ms query 2; still undecided: 1005013, sample size is: 200 addmissings 52.88 ms Differential Revision: https://phab.mercurial-scm.org/D6428
author Georges Racinet <georges.racinet@octobus.net>
date Tue, 16 Apr 2019 01:16:39 +0200
parents 94faa2e84094
children 35b255e474d9
line wrap: on
line source

#require no-reposimplestore

  $ hg clone http://localhost:$HGPORT/ copy
  abort: * (glob)
  [255]
  $ test -d copy
  [1]

This server doesn't do range requests so it's basically only good for
one pull

  $ "$PYTHON" "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid \
  > --logfile server.log
  $ cat dumb.pid >> $DAEMON_PIDS
  $ hg init remote
  $ cd remote
  $ echo foo > bar
  $ echo c2 > '.dotfile with spaces'
  $ hg add
  adding .dotfile with spaces
  adding bar
  $ hg commit -m"test"
  $ hg tip
  changeset:   0:02770d679fb8
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     test
  
  $ cd ..
  $ hg clone static-http://localhost:$HGPORT/remote local
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 2 changes to 2 files
  new changesets 02770d679fb8
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd local
  $ hg verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
  checked 1 changesets with 2 changes to 2 files
  $ cat bar
  foo
  $ cd ../remote
  $ echo baz > quux
  $ hg commit -A -mtest2
  adding quux

check for HTTP opener failures when cachefile does not exist

  $ rm .hg/cache/*
  $ cd ../local
  $ cat >> .hg/hgrc <<EOF
  > [hooks]
  > changegroup = sh -c "printenv.py --line changegroup"
  > EOF
  $ hg pull
  pulling from static-http://localhost:$HGPORT/remote
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  new changesets 4ac2e3648604
  changegroup hook: HG_HOOKNAME=changegroup
  HG_HOOKTYPE=changegroup
  HG_NODE=4ac2e3648604439c580c69b09ec9d93a88d93432
  HG_NODE_LAST=4ac2e3648604439c580c69b09ec9d93a88d93432
  HG_SOURCE=pull
  HG_TXNID=TXN:$ID$
  HG_TXNNAME=pull
  http://localhost:$HGPORT/remote
  HG_URL=http://localhost:$HGPORT/remote
  
  (run 'hg update' to get a working copy)

trying to push

  $ hg update
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo more foo >> bar
  $ hg commit -m"test"
  $ hg push
  pushing to static-http://localhost:$HGPORT/remote
  abort: destination does not support push
  [255]

trying clone -r

  $ cd ..
  $ hg clone -r doesnotexist static-http://localhost:$HGPORT/remote local0
  abort: unknown revision 'doesnotexist'!
  [255]
  $ hg clone -r 0 static-http://localhost:$HGPORT/remote local0
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 2 changes to 2 files
  new changesets 02770d679fb8
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved

test with "/" URI (issue747) and subrepo

  $ hg init
  $ hg init sub
  $ touch sub/test
  $ hg -R sub commit -A -m "test"
  adding test
  $ hg -R sub tag not-empty
  $ echo sub=sub > .hgsub
  $ echo a > a
  $ hg add a .hgsub
  $ hg -q ci -ma
  $ hg clone static-http://localhost:$HGPORT/ local2
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 3 changes to 3 files
  new changesets a9ebfbe8e587
  updating to branch default
  cloning subrepo sub from static-http://localhost:$HGPORT/sub
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files
  new changesets be090ea66256:322ea90975df
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd local2
  $ hg verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
  checked 1 changesets with 3 changes to 3 files
  checking subrepo links
  $ cat a
  a
  $ hg paths
  default = static-http://localhost:$HGPORT/

test with empty repo (issue965)

  $ cd ..
  $ hg init remotempty
  $ hg clone static-http://localhost:$HGPORT/remotempty local3
  no changes found
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd local3
  $ hg verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
  checked 0 changesets with 0 changes to 0 files
  $ hg paths
  default = static-http://localhost:$HGPORT/remotempty

test with non-repo

  $ cd ..
  $ mkdir notarepo
  $ hg clone static-http://localhost:$HGPORT/notarepo local3
  abort: 'http://localhost:$HGPORT/notarepo' does not appear to be an hg repository!
  [255]

Clone with tags and branches works

  $ hg init remote-with-names
  $ cd remote-with-names
  $ echo 0 > foo
  $ hg -q commit -A -m initial
  $ echo 1 > foo
  $ hg commit -m 'commit 1'
  $ hg -q up 0
  $ hg branch mybranch
  marked working directory as branch mybranch
  (branches are permanent and global, did you want a bookmark?)
  $ echo 2 > foo
  $ hg commit -m 'commit 2 (mybranch)'
  $ hg tag -r 1 'default-tag'
  $ hg tag -r 2 'branch-tag'

  $ cd ..

  $ hg clone static-http://localhost:$HGPORT/remote-with-names local-with-names
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 2 files (+1 heads)
  new changesets 68986213bd44:0c325bd2b5a7
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Clone a specific branch works

  $ hg clone -r mybranch static-http://localhost:$HGPORT/remote-with-names local-with-names-branch
  adding changesets
  adding manifests
  adding file changes
  added 4 changesets with 4 changes to 2 files
  new changesets 68986213bd44:0c325bd2b5a7
  updating to branch mybranch
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved

Clone a specific tag works

  $ hg clone -r default-tag static-http://localhost:$HGPORT/remote-with-names local-with-names-tag
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 1 files
  new changesets 68986213bd44:4ee3fcef1c80
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ killdaemons.py

List of files accessed over HTTP:

  $ cat server.log | sed -n -e 's|.*GET \(/[^ ]*\).*|\1|p' | sort -u
  /.hg/bookmarks
  /.hg/bookmarks.current
  /.hg/cache/hgtagsfnodes1
  /.hg/cache/rbc-names-v1
  /.hg/cache/rbc-revs-v1
  /.hg/requires
  /.hg/store/00changelog.i
  /.hg/store/00manifest.i
  /.hg/store/data/%7E2ehgsub.i (no-py37 !)
  /.hg/store/data/%7E2ehgsubstate.i (no-py37 !)
  /.hg/store/data/a.i
  /.hg/store/data/~2ehgsub.i (py37 !)
  /.hg/store/data/~2ehgsubstate.i (py37 !)
  /notarepo/.hg/00changelog.i
  /notarepo/.hg/requires
  /remote-with-names/.hg/bookmarks
  /remote-with-names/.hg/bookmarks.current
  /remote-with-names/.hg/cache/branch2-served
  /remote-with-names/.hg/cache/hgtagsfnodes1
  /remote-with-names/.hg/cache/rbc-names-v1
  /remote-with-names/.hg/cache/rbc-revs-v1
  /remote-with-names/.hg/cache/tags2-served
  /remote-with-names/.hg/localtags
  /remote-with-names/.hg/requires
  /remote-with-names/.hg/store/00changelog.i
  /remote-with-names/.hg/store/00manifest.i
  /remote-with-names/.hg/store/data/%7E2ehgtags.i (no-py37 !)
  /remote-with-names/.hg/store/data/foo.i
  /remote-with-names/.hg/store/data/~2ehgtags.i (py37 !)
  /remote/.hg/bookmarks
  /remote/.hg/bookmarks.current
  /remote/.hg/cache/branch2-base
  /remote/.hg/cache/branch2-immutable
  /remote/.hg/cache/branch2-served
  /remote/.hg/cache/hgtagsfnodes1
  /remote/.hg/cache/rbc-names-v1
  /remote/.hg/cache/rbc-revs-v1
  /remote/.hg/cache/tags2-served
  /remote/.hg/localtags
  /remote/.hg/requires
  /remote/.hg/store/00changelog.i
  /remote/.hg/store/00manifest.i
  /remote/.hg/store/data/%7E2edotfile%20with%20spaces.i (no-py37 !)
  /remote/.hg/store/data/%7E2ehgtags.i (no-py37 !)
  /remote/.hg/store/data/bar.i
  /remote/.hg/store/data/quux.i
  /remote/.hg/store/data/~2edotfile%20with%20spaces.i (py37 !)
  /remote/.hg/store/data/~2ehgtags.i (py37 !)
  /remotempty/.hg/bookmarks
  /remotempty/.hg/bookmarks.current
  /remotempty/.hg/requires
  /remotempty/.hg/store/00changelog.i
  /remotempty/.hg/store/00manifest.i
  /sub/.hg/bookmarks
  /sub/.hg/bookmarks.current
  /sub/.hg/cache/hgtagsfnodes1
  /sub/.hg/cache/rbc-names-v1
  /sub/.hg/cache/rbc-revs-v1
  /sub/.hg/requires
  /sub/.hg/store/00changelog.i
  /sub/.hg/store/00manifest.i
  /sub/.hg/store/data/%7E2ehgtags.i (no-py37 !)
  /sub/.hg/store/data/test.i
  /sub/.hg/store/data/~2ehgtags.i (py37 !)