tests/test-pull-pull-corruption.t
author Martijn Pieters <mj@zopatista.com>
Tue, 31 Jul 2018 19:37:54 +0200
changeset 38781 0a57945aaf7f
parent 34661 eb586ed5d8ce
child 39489 f1186c292d03
permissions -rw-r--r--
manifest: persist the manifestfulltext cache Reconstructing the manifest from the revlog takes time, so much so that there already is a LRU cache to avoid having to load a manifest multiple times. This patch persists that LRU cache in the .hg/cache directory, so we can re-use this cache across hg commands. Commit benchmark (run on Macos 10.13 on a 2017-model Macbook Pro with Core i7 2.9GHz and flash drive), testing without and with patch run 5 times, baseline is r2a227782e754: * committing to an existing file, against the mozilla-central repository. Baseline real time average 1.9692, with patch 1.3786. A new debugcommand "hg debugmanifestfulltextcache" lets you inspect the cache, clear it, or add specific manifest nodeids to it. When calling repo.updatecaches(), the manifest(s) for the working copy parents are added to the cache. The hg perfmanifest command has an additional --clear-disk switch to clear this cache when testing manifest loading performance. Using this command to test performance on the firefox repository for revision f947d902ed91, whose manifest has a delta chain length of 60540, we see: $ hg perfmanifest f947d902ed91 --clear-disk ! wall 0.972253 comb 0.970000 user 0.850000 sys 0.120000 (best of 10) $ hg debugmanifestfulltextcache -a `hg log --debug -r f947d902ed91 | grep manifest | cut -d: -f3` Cache contains 1 manifest entries, in order of most to least recent: id: 0294517df4aad07c70701db43bc7ff24c3ce7dbc, size 25.6 MB Total cache data size 25.6 MB, on-disk 0 bytes $ hg perfmanifest f947d902ed91 ! wall 0.036748 comb 0.040000 user 0.020000 sys 0.020000 (best of 100) Worst-case scenario: a manifest text loaded from a single delta; in the firefox repository manifest node 9a1246ff762e is the chain base for the manifest attached to revision f947d902ed91. Loading this from a full cache file is just as fast as without the cache; the extra node ids ensure a big full cache: $ for node in 9a1246ff762e 1a1922c14a3e 54a31d11a36a 0294517df4aa; do > hgd debugmanifestfulltextcache -a $node > /dev/null > done $ hgd perfmanifest -m 9a1246ff762e ! wall 0.077513 comb 0.080000 user 0.030000 sys 0.050000 (best of 100) $ hgd perfmanifest -m 9a1246ff762e --clear-disk ! wall 0.078547 comb 0.080000 user 0.070000 sys 0.010000 (best of 100)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     1
Corrupt an hg repo with two pulls.
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     2
create one repo with a long history
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     3
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     4
  $ hg init source1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     5
  $ cd source1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     6
  $ touch foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     7
  $ hg add foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     8
  $ for i in 1 2 3 4 5 6 7 8 9 10; do
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
     9
  >     echo $i >> foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    10
  >     hg ci -m $i
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    11
  > done
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    12
  $ cd ..
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    13
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    14
create one repo with a shorter history
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    15
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    16
  $ hg clone -r 0 source1 source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    17
  adding changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    18
  adding manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    19
  adding file changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    20
  added 1 changesets with 1 changes to 1 files
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
    21
  new changesets 495a0ec48aaf
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    22
  updating to branch default
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    23
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    24
  $ cd source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    25
  $ echo a >> foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    26
  $ hg ci -m a
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    27
  $ cd ..
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    28
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    29
create a third repo to pull both other repos into it
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    30
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    31
  $ hg init corrupted
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    32
  $ cd corrupted
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    33
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    34
use a hook to make the second pull start while the first one is still running
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    35
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    36
  $ echo '[hooks]' >> .hg/hgrc
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    37
  $ echo 'prechangegroup = sleep 5' >> .hg/hgrc
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    38
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    39
start a pull...
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    40
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    41
  $ hg pull ../source1 > pull.out 2>&1 &
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    42
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    43
... and start another pull before the first one has finished
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    44
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    45
  $ sleep 1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    46
  $ hg pull ../source2 2>/dev/null
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    47
  pulling from ../source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    48
  searching for changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    49
  adding changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    50
  adding manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    51
  adding file changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    52
  added 1 changesets with 1 changes to 1 files (+1 heads)
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
    53
  new changesets ca3c05af513e
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    54
  (run 'hg heads' to see heads, 'hg merge' to merge)
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    55
  $ cat pull.out
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    56
  pulling from ../source1
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    57
  requesting all changes
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    58
  adding changesets
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    59
  adding manifests
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    60
  adding file changes
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    61
  added 10 changesets with 10 changes to 1 files
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
    62
  new changesets 495a0ec48aaf:1e7b6c812ca8
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
    63
  (run 'hg update' to get a working copy)
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    64
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    65
see the result
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    66
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    67
  $ wait
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    68
  $ hg verify
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    69
  checking changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    70
  checking manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    71
  crosschecking files in changesets and manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    72
  checking files
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
    73
  1 files, 11 changesets, 11 total revisions
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16481
diff changeset
    74
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16481
diff changeset
    75
  $ cd ..