tests/test-dirstate.t
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 24 Sep 2018 09:41:42 -0700
changeset 39861 db5501d93bcf
parent 35393 4441705b7111
child 42456 87a34c767384
permissions -rw-r--r--
changegroup: remove reordering control (BC) This logic - including the experimental bundle.reorder option - was originally added in a8e3931e3fb5 in 2011 and then later ported to changegroup.py. The intent of this option and associated logic is to control the ordering of revisions in deltagroups in changegroups. At the time it was implemented, only changegroup version 1 existed and generaldelta revlogs were just coming into the world. Changegroup version 1 requires that deltas be made against the last revision sent over the wire. Used with generaldelta, this created an impedance mismatch of sorts and resulted in changegroup producers spending a lot of time recomputing deltas. Revision reordering was introduced so outgoing revisions would be sent in "generaldelta order" and producers would be able to reuse internal deltas from storage. Later on, we introduced changegroup version 2. It supported denoting which revision a delta was against. So we no longer needed to sort outgoing revisions to ensure optimal delta generation from the producer. So, subsequent changegroup versions disabled reordering. We also later made the changelog not store deltas by default. And we also made the changelog send out deltas in storage order. Why we do this for changelog, I'm not sure. Maybe we want to preserve revision order across clones? It doesn't really matter for this commit. Fast forward to 2018. We want to abstract storage backends. And having changegroup code require knowledge about how deltas are stored internally interferes with that goal. This commit removes reordering control from changegroup generation. After this commit, the reordering behavior is: * The changelog is always sent out in storage order (no behavior change). * Non-changelog generaldelta revlogs are reordered to always be in DAG topological order (previously, generaldelta revlogs would be emitted in storage order for version 2 and 3 changegroups). * Non-changelog non-generaldelta revlogs are sent in storage order (no behavior change). * There exists no config option to override behavior. The big difference here is that generaldelta revlogs now *always* have their revisions sorted in DAG order before going out over the wire. This behavior was previously only done for changegroup version 1. Version 2 and version 3 changegroups disabled reordering because the interchange format supported encoding arbitrary delta parents, so reordering wasn't strictly necessary. I can think of a few significant implications for this change. Because changegroup receivers will now see non-changelog revisions in DAG order instead of storage order, the internal storage order of manifests and files may differ substantially between producer and consumer. I don't think this matters that much, since the storage order of manifests and files is largely hidden from users. Only the storage order of changelog matters (because `hg log` shows the changelog in storage order). I don't think there should be any controversy here. The reordering of revisions has implications for changegroup producers. Previously, generaldelta revlogs would be emitted in storage order. And in the common case, the internally-stored delta could effectively be copied from disk into the deltagroup delta. This meant that emitting delta groups for generaldelta revlogs would be mostly linear read I/O. This is desirable for performance. With us now reordering generaldelta revlog revisions in DAG order, the read operations may use more random I/O instead of sequential I/O. This could result in performance loss. But with the prevalence of SSDs and fast random I/O, I'm not too worried. (Note: the optimal emission order for revlogs is actually delta encoding order. But the changegroup code wasn't doing that before or after this change. We could potentially implement that in a later commit.) Changegroups in DAG order will have implications for receivers. Previously, receiving storage order might mean seeing a number of interleaved branches. This would mean long delta chains, sparse I/O, and possibly more fulltext revisions instead of deltas, blowing up storage storage. (This is the same set of problems that sparse revlogs aims to address.) With the producer now sending revisions in DAG order, the receiver also stores revisions in DAG order. That means revisions for the same DAG branch are all grouped together. And this should yield better storage outcomes. In other words, sending the reordered changegroup allows the receiver to have better storage order and for the producer to not propagate its (possibly sub-optimal) internal storage order. On the mozilla-unified repository, this change influences bundle generation: $ hg bundle -t none-v2 -a before: time: real 355.680 secs (user 256.790+0.000 sys 16.820+0.000) after: time: real 382.950 secs (user 281.700+0.000 sys 17.690+0.000) before: 7,150,228,967 bytes (uncompressed) after: 7,041,556,273 bytes (uncompressed) before: 1,669,063,234 bytes (zstd l=3) after: 1,628,598,830 bytes (zstd l=3) $ hg unbundle before: time: real 511.910 secs (user 466.750+0.000 sys 32.680+0.000) after: time: real 487.790 secs (user 443.940+0.000 sys 30.840+0.000) 00manifest.d size: source: 274,924,292 bytes before: 304,741,626 bytes after: 245,252,087 bytes .hg/store total file size: source: 2,649,133,490 before: 2,680,888,130 after: 2,627,875,673 We see the bundle size drop. That's probably because if a revlog internally isn't storing a delta, it will choose to delta against the last emitted revision. And on repos with interleaved branches (like mozilla-unified), the previous revision could be an unrelated branch and therefore be a large delta. But with this patch, the previous revision is likely p1 or p2 and a delta should be small. We also see the manifest size drop by ~50 MB. It's worth noting that the manifest actually *increased* in size by ~25 MB in the old strategy and decreased ~25 MB from its source in the new strategy. Again, my explanation for this is that the DAG ordering in the changegroup is resulting in better grouping of revisions in the receiver, which results in more compact delta chains and higher storage efficiency. Unbundle time also dropped. I suspect this is due to the revlog having to work less to compute deltas since the incoming deltas are more optimal. i.e. the receiver spends less time resolving fulltext revisions as incoming deltas bounce around between DAG branches and delta chains. We also see bundle generation time increase. This is not desirable. However, the regression is only significant on the original repository: if we generate a bundle from the repository created from the new, always reordered bundles, we're close to baseline (if not at it with expected noise): $ hg bundle -t none-v2 -a before (original): time: real 355.680 secs (user 256.790+0.000 sys 16.820+0.000) after (original): time: real 382.950 secs (user 281.700+0.000 sys 17.690+0.000) after (new repo): time: real 362.280 secs (user 260.300+0.000 sys 17.700+0.000) This regression is a bit worrying because it will impact serving canonical repositories (that don't have optimal internal storage unless they are reordered - possibly as part of running `hg debugupgraderepo`). However, this regression will only be noticed by very large changegroups. And I'm guessing/hoping that any repository that large is using clonebundles to mitigate server load. Again, sending DAG order isn't the optimal send order for servers: sending in storage-delta order is. But in order to enable storage-optimal send order, we'll need a storage API that handles sorting. Future commits will introduce such an API. Differential Revision: https://phab.mercurial-scm.org/D4721
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
     1
------ Test dirstate._dirs refcounting
7096
6dab29f6df37 dirstate._dirs: fix refcounting broken by 7dfac37cfabf
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     2
11887
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     3
  $ hg init t
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     4
  $ cd t
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     5
  $ mkdir -p a/b/c/d
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     6
  $ touch a/b/c/d/x
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     7
  $ touch a/b/c/d/y
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     8
  $ touch a/b/c/d/z
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
     9
  $ hg ci -Am m
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    10
  adding a/b/c/d/x
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    11
  adding a/b/c/d/y
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    12
  adding a/b/c/d/z
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    13
  $ hg mv a z
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33954
diff changeset
    14
  moving a/b/c/d/x to z/b/c/d/x
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33954
diff changeset
    15
  moving a/b/c/d/y to z/b/c/d/y
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33954
diff changeset
    16
  moving a/b/c/d/z to z/b/c/d/z
17095
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    17
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    18
Test name collisions
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    19
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    20
  $ rm z/b/c/d/x
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    21
  $ mkdir z/b/c/d/x
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    22
  $ touch z/b/c/d/x/y
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    23
  $ hg add z/b/c/d/x/y
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    24
  abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    25
  [255]
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    26
  $ rm -rf z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    27
  $ touch z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    28
  $ hg add z/b/c/d
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    29
  abort: directory 'z/b/c/d' already in dirstate
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    30
  [255]
45cf6a91a02d dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents: 15447
diff changeset
    31
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    32
  $ cd ..
11887
76818b28ce98 tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents: 7096
diff changeset
    33
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11888
diff changeset
    34
Issue1790: dirstate entry locked into unset if file mtime is set into
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11888
diff changeset
    35
the future
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    36
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    37
Prepare test repo:
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    38
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    39
  $ hg init u
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    40
  $ cd u
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    41
  $ echo a > a
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    42
  $ hg add
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    43
  adding a
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    44
  $ hg ci -m1
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    45
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    46
Set mtime of a into the future:
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    47
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    48
  $ touch -t 202101011200 a
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    49
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    50
Status must not set a's entry to unset (issue1790):
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    51
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    52
  $ hg status
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    53
  $ hg debugstate
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    54
  n 644          2 2021-01-01 12:00:00 a
17733
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    55
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    56
Test modulo storage/comparison of absurd dates:
11888
2bd699886ffc tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents: 11887
diff changeset
    57
19092
8c560ad1cdc4 tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 17737
diff changeset
    58
#if no-aix
17733
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    59
  $ touch -t 195001011200 a
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    60
  $ hg st
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    61
  $ hg debugstate
3c775c5a6c03 dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents: 17095
diff changeset
    62
  n 644          2 2018-01-19 15:14:08 a
19092
8c560ad1cdc4 tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 17737
diff changeset
    63
#endif
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    64
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    65
Verify that exceptions during a dirstate change leave the dirstate
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    66
coherent (issue4353)
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    67
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    68
  $ cat > ../dirstateexception.py <<EOF
33954
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    69
  > from __future__ import absolute_import
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    70
  > from mercurial import (
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    71
  >   error,
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    72
  >   extensions,
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    73
  >   merge,
b9765319880e tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 26587
diff changeset
    74
  > )
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    75
  > 
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    76
  > def wraprecordupdates(orig, repo, actions, branchmerge):
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 22406
diff changeset
    77
  >     raise error.Abort("simulated error while recording dirstateupdates")
22406
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    78
  > 
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    79
  > def reposetup(ui, repo):
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    80
  >     extensions.wrapfunction(merge, 'recordupdates', wraprecordupdates)
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    81
  > EOF
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    82
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    83
  $ hg rm a
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    84
  $ hg commit -m 'rm a'
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    85
  $ echo "[extensions]" >> .hg/hgrc
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    86
  $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    87
  $ hg up 0
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    88
  abort: simulated error while recording dirstateupdates
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    89
  [255]
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    90
  $ hg log -r . -T '{rev}\n'
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    91
  1
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    92
  $ hg status
2e47e461d2ca dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents: 19092
diff changeset
    93
  ? a