tests/test-arbitraryfilectx.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 16 Apr 2019 17:26:38 +0200
changeset 42159 4f9a89837f07
parent 41334 5361f9ed8a30
child 48876 42d2b31cee0b
permissions -rw-r--r--
setdiscovery: stop limiting the number of local head we initially send In our testing this limitation provides now real gain and instead triggers pathological discovery timing for some repository with many heads. See inline documentation for details. Some timing below: Mozilla try repository, (~1M revs, ~35K heads), discovery between 2 clones with 100 head missing on each side before: ! wall 1.492111 comb 1.490000 user 1.450000 sys 0.040000 (best of 20) ! wall 1.813992 comb 1.820000 user 1.700000 sys 0.120000 (max of 20) ! wall 1.574326 comb 1.573500 user 1.522000 sys 0.051500 (avg of 20) ! wall 1.572583 comb 1.570000 user 1.520000 sys 0.050000 (median of 20) after: ! wall 1.147834 comb 1.150000 user 1.090000 sys 0.060000 (best of 20) ! wall 1.449144 comb 1.450000 user 1.330000 sys 0.120000 (max of 20) ! wall 1.204618 comb 1.202500 user 1.146500 sys 0.056000 (avg of 20) ! wall 1.194407 comb 1.190000 user 1.140000 sys 0.050000 (median of 20) pypy (~100 heads, 317 heads) discovery between clones with only 42 common heads before: ! wall 0.031653 comb 0.030000 user 0.030000 sys 0.000000 (best of 25) ! wall 0.055719 comb 0.050000 user 0.040000 sys 0.010000 (max of 25) ! wall 0.038939 comb 0.039600 user 0.038400 sys 0.001200 (avg of 25) ! wall 0.038660 comb 0.050000 user 0.040000 sys 0.010000 (median of 25) after: ! wall 0.018754 comb 0.020000 user 0.020000 sys 0.000000 (best of 49) ! wall 0.034505 comb 0.040000 user 0.030000 sys 0.010000 (max of 49) ! wall 0.019631 comb 0.019796 user 0.018367 sys 0.001429 (avg of 49) ! wall 0.019132 comb 0.020000 user 0.020000 sys 0.000000 (median of 49) Private repository (~1M revs, ~3K heads), discovery from a strip subset, about 100 changesets to be pulled. before: ! wall 1.837729 comb 1.840000 user 1.790000 sys 0.050000 (best of 20) ! wall 2.203468 comb 2.200000 user 2.100000 sys 0.100000 (max of 20) ! wall 2.049355 comb 2.048500 user 2.002500 sys 0.046000 (avg of 20) ! wall 2.035315 comb 2.040000 user 2.000000 sys 0.040000 (median of 20) after: ! wall 0.136598 comb 0.130000 user 0.110000 sys 0.020000 (best of 20) ! wall 0.330519 comb 0.330000 user 0.260000 sys 0.070000 (max of 20) ! wall 0.157254 comb 0.155500 user 0.123000 sys 0.032500 (avg of 20) ! wall 0.149870 comb 0.140000 user 0.110000 sys 0.030000 (median of 20) Same private repo, discovery between two clone with 500 different heads on each side: before: ! wall 2.372919 comb 2.370000 user 2.320000 sys 0.050000 (best of 20) ! wall 2.622422 comb 2.610000 user 2.510000 sys 0.100000 (max of 20) ! wall 2.450135 comb 2.450000 user 2.402000 sys 0.048000 (avg of 20) ! wall 2.443896 comb 2.450000 user 2.410000 sys 0.040000 (median of 20) after: ! wall 0.625497 comb 0.620000 user 0.570000 sys 0.050000 (best of 20) ! wall 0.834723 comb 0.820000 user 0.730000 sys 0.090000 (max of 20) ! wall 0.675725 comb 0.675500 user 0.628000 sys 0.047500 (avg of 20) ! wall 0.671614 comb 0.680000 user 0.640000 sys 0.040000 (median of 20)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     1
Setup:
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     2
  $ cat > eval.py <<EOF
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     3
  > from __future__ import absolute_import
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     4
  > import filecmp
37318
9954d0e2ad00 py3: use pycompat.bytestr() intsead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36382
diff changeset
     5
  > from mercurial import commands, context, pycompat, registrar
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     6
  > cmdtable = {}
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     7
  > command = registrar.command(cmdtable)
36382
b4d1c09b754b py3: add missing b'' in test-arbitraryfilectx.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35947
diff changeset
     8
  > @command(b'eval', [], b'hg eval CMD')
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
     9
  > def eval_(ui, repo, *cmds, **opts):
35947
a36d3c8a0e41 py3: add b'' prefixes to string literals in test files
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34936
diff changeset
    10
  >     cmd = b" ".join(cmds)
37318
9954d0e2ad00 py3: use pycompat.bytestr() intsead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36382
diff changeset
    11
  >     res = pycompat.bytestr(eval(cmd, globals(), locals()))
35947
a36d3c8a0e41 py3: add b'' prefixes to string literals in test files
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34936
diff changeset
    12
  >     ui.warn(b"%s" % res)
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    13
  > EOF
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    14
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    15
  $ echo "[extensions]" >> $HGRCPATH
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    16
  $ echo "eval=`pwd`/eval.py" >> $HGRCPATH
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    17
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    18
Arbitraryfilectx.cmp does not follow symlinks:
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    19
  $ mkdir case1
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    20
  $ cd case1
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    21
  $ hg init
34936
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    22
#if symlink
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    23
  $ printf "A" > real_A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    24
  $ printf "foo" > A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    25
  $ printf "foo" > B
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    26
  $ ln -s A sym_A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    27
  $ hg add .
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    28
  adding A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    29
  adding B
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    30
  adding real_A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    31
  adding sym_A
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    32
  $ hg commit -m "base"
34936
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    33
#else
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    34
  $ hg import -q --bypass - <<EOF
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    35
  > # HG changeset patch
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    36
  > # User test
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    37
  > # Date 0 0
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    38
  > base
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    39
  > 
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    40
  > diff --git a/A b/A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    41
  > new file mode 100644
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    42
  > --- /dev/null
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    43
  > +++ b/A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    44
  > @@ -0,0 +1,1 @@
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    45
  > +foo
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    46
  > \ No newline at end of file
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    47
  > diff --git a/B b/B
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    48
  > new file mode 100644
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    49
  > --- /dev/null
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    50
  > +++ b/B
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    51
  > @@ -0,0 +1,1 @@
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    52
  > +foo
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    53
  > \ No newline at end of file
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    54
  > diff --git a/real_A b/real_A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    55
  > new file mode 100644
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    56
  > --- /dev/null
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    57
  > +++ b/real_A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    58
  > @@ -0,0 +1,1 @@
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    59
  > +A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    60
  > \ No newline at end of file
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    61
  > diff --git a/sym_A b/sym_A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    62
  > new file mode 120000
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    63
  > --- /dev/null
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    64
  > +++ b/sym_A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    65
  > @@ -0,0 +1,1 @@
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    66
  > +A
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    67
  > \ No newline at end of file
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    68
  > EOF
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    69
  $ hg up -q
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    70
#endif
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    71
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    72
These files are different and should return True (different):
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    73
(Note that filecmp.cmp's return semantics are inverted from ours, so we invert
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    74
for simplicity):
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    75
  $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'real_A'])"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    76
  True (no-eol)
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    77
  $ hg eval "not filecmp.cmp(b'A', b'real_A')"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    78
  True (no-eol)
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    79
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    80
These files are identical and should return False (same):
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    81
  $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'A'])"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    82
  False (no-eol)
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    83
  $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'B'])"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    84
  False (no-eol)
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    85
  $ hg eval "not filecmp.cmp(b'A', b'B')"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    86
  False (no-eol)
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    87
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    88
This comparison should also return False, since A and sym_A are substantially
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    89
the same in the eyes of ``filectx.cmp``, which looks at data only.
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    90
  $ hg eval "context.arbitraryfilectx(b'real_A', repo).cmp(repo[None][b'sym_A'])"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    91
  False (no-eol)
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    92
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    93
A naive use of filecmp on those two would wrongly return True, since it follows
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    94
the symlink to "A", which has different contents.
34936
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    95
#if symlink
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    96
  $ hg eval "not filecmp.cmp(b'real_A', b'sym_A')"
34835
14c87708f432 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
diff changeset
    97
  True (no-eol)
34936
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
    98
#else
41334
5361f9ed8a30 py3: fix missing b prefixes in test-arbitraryfilectx.t
Augie Fackler <augie@google.com>
parents: 37318
diff changeset
    99
  $ hg eval "not filecmp.cmp(b'real_A', b'sym_A')"
34936
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
   100
  False (no-eol)
9645c2a2bc2a test-arbitraryfilectx: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 34835
diff changeset
   101
#endif