tests/test-requires.t
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 06 Sep 2018 14:04:46 -0700
changeset 39568 842cd0bdda75
parent 37135 ecac0006b90e
child 40229 fed5e57c8dc7
permissions -rw-r--r--
util: teach lrucachedict to enforce a max total cost Now that lrucachedict entries can have a numeric cost associated with them and we can easily pop the oldest item in the cache, it now becomes relatively trivial to implement support for enforcing a high water mark on the total cost of items in the cache. This commit teaches lrucachedict instances to have a max cost associated with them. When items are inserted, we pop old items until enough "cost" frees up to make room for the new item. This feature is close to zero cost when not used (modulo the insertion regressed introduced by the previous commit): $ ./hg perflrucachedict --size 4 --gets 1000000 --sets 1000000 --mixed 1000000 ! gets ! wall 0.607444 comb 0.610000 user 0.610000 sys 0.000000 (best of 17) ! wall 0.601653 comb 0.600000 user 0.600000 sys 0.000000 (best of 17) ! inserts ! wall 0.678261 comb 0.680000 user 0.680000 sys 0.000000 (best of 14) ! wall 0.685042 comb 0.680000 user 0.680000 sys 0.000000 (best of 15) ! sets ! wall 0.808770 comb 0.800000 user 0.800000 sys 0.000000 (best of 13) ! wall 0.834241 comb 0.830000 user 0.830000 sys 0.000000 (best of 12) ! mixed ! wall 0.782441 comb 0.780000 user 0.780000 sys 0.000000 (best of 13) ! wall 0.803804 comb 0.800000 user 0.800000 sys 0.000000 (best of 13) $ hg perflrucachedict --size 1000 --gets 1000000 --sets 1000000 --mixed 1000000 ! init ! wall 0.006952 comb 0.010000 user 0.010000 sys 0.000000 (best of 418) ! gets ! wall 0.613350 comb 0.610000 user 0.610000 sys 0.000000 (best of 17) ! wall 0.617415 comb 0.620000 user 0.620000 sys 0.000000 (best of 17) ! inserts ! wall 0.701270 comb 0.700000 user 0.700000 sys 0.000000 (best of 15) ! wall 0.700516 comb 0.700000 user 0.700000 sys 0.000000 (best of 15) ! sets ! wall 0.825720 comb 0.830000 user 0.830000 sys 0.000000 (best of 13) ! wall 0.837946 comb 0.840000 user 0.830000 sys 0.010000 (best of 12) ! mixed ! wall 0.821644 comb 0.820000 user 0.820000 sys 0.000000 (best of 13) ! wall 0.850559 comb 0.850000 user 0.850000 sys 0.000000 (best of 12) I reckon the slight slowdown on insert is due to added if checks. For caches with total cost limiting enabled: $ hg perflrucachedict --size 4 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 100 ! gets w/ cost limit ! wall 0.598737 comb 0.590000 user 0.590000 sys 0.000000 (best of 17) ! inserts w/ cost limit ! wall 1.694282 comb 1.700000 user 1.700000 sys 0.000000 (best of 6) ! mixed w/ cost limit ! wall 1.157655 comb 1.150000 user 1.150000 sys 0.000000 (best of 9) $ hg perflrucachedict --size 1000 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 10000 ! gets w/ cost limit ! wall 0.598526 comb 0.600000 user 0.600000 sys 0.000000 (best of 17) ! inserts w/ cost limit ! wall 37.838315 comb 37.840000 user 37.840000 sys 0.000000 (best of 3) ! mixed w/ cost limit ! wall 18.060198 comb 18.060000 user 18.060000 sys 0.000000 (best of 3) $ hg perflrucachedict --size 1000 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 10000 --mixedgetfreq 90 ! gets w/ cost limit ! wall 0.600024 comb 0.600000 user 0.600000 sys 0.000000 (best of 17) ! inserts w/ cost limit ! wall 37.154547 comb 37.120000 user 37.120000 sys 0.000000 (best of 3) ! mixed w/ cost limit ! wall 4.381602 comb 4.380000 user 4.370000 sys 0.010000 (best of 3) The functions we're benchmarking are slightly different, which could move numbers by a few milliseconds. But the slowdown on insert is too great to be explained by that. The slowness is due to insert heavy operations needing to call popoldest() repeatedly when the cache is at capacity. The next commit will address this. Differential Revision: https://phab.mercurial-scm.org/D4503
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13956
ffb5c09ba822 tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents: 12346
diff changeset
     1
  $ hg init t
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     2
  $ cd t
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     3
  $ echo a > a
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     4
  $ hg add a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12116
diff changeset
     5
  $ hg commit -m test
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     6
  $ rm .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     7
  $ hg tip
32392
36d3559c69a6 revlog: tweak wording and logic for flags validation
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32291
diff changeset
     8
  abort: unknown version (2) in revlog 00changelog.i!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
     9
  [255]
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    10
  $ echo indoor-pool > .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    11
  $ hg tip
20820
f8e531a3a77c repo: rephrase the "missing requirement" error message
Mads Kiilerich <madski@unity3d.com>
parents: 20715
diff changeset
    12
  abort: repository requires features unknown to this Mercurial: indoor-pool!
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    13
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
    14
  [255]
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    15
  $ echo outdoor-pool >> .hg/requires
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    16
  $ hg tip
20820
f8e531a3a77c repo: rephrase the "missing requirement" error message
Mads Kiilerich <madski@unity3d.com>
parents: 20715
diff changeset
    17
  abort: repository requires features unknown to this Mercurial: indoor-pool outdoor-pool!
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    18
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    19
  [255]
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    20
  $ cd ..
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    21
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    22
Test checking between features supported locally and ones required in
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    23
another repository of push/pull/clone on localhost:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    24
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    25
  $ mkdir supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    26
  $ cd supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    27
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    28
  $ hg init supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    29
  $ echo a > supported/a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    30
  $ hg -R supported commit -Am '#0 at supported'
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    31
  adding a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    32
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    33
  $ echo 'featuresetup-test' >> supported/.hg/requires
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    34
  $ cat > $TESTTMP/supported-locally/supportlocally.py <<EOF
33985
68bc85f46fe3 tests: update test-requires to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 32392
diff changeset
    35
  > from __future__ import absolute_import
68bc85f46fe3 tests: update test-requires to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 32392
diff changeset
    36
  > from mercurial import extensions, localrepo
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    37
  > def featuresetup(ui, supported):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    38
  >     for name, module in extensions.extensions(ui):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    39
  >         if __name__ == module.__name__:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    40
  >             # support specific feature locally
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 26421
diff changeset
    41
  >             supported |= {'featuresetup-test'}
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    42
  >             return
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    43
  > def uisetup(ui):
37135
ecac0006b90e localrepo: move featuresetupfuncs out of localrepository class (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33985
diff changeset
    44
  >     localrepo.featuresetupfuncs.add(featuresetup)
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    45
  > EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    46
  $ cat > supported/.hg/hgrc <<EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    47
  > [extensions]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    48
  > # enable extension locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    49
  > supportlocally = $TESTTMP/supported-locally/supportlocally.py
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    50
  > EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    51
  $ hg -R supported status
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    52
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    53
  $ hg init push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    54
  $ hg -R supported push push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    55
  pushing to push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    56
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    57
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    58
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    59
  $ hg init pull-src
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    60
  $ hg -R pull-src pull supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    61
  pulling from supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    62
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    63
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    64
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    65
  $ hg clone supported clone-dst
20820
f8e531a3a77c repo: rephrase the "missing requirement" error message
Mads Kiilerich <madski@unity3d.com>
parents: 20715
diff changeset
    66
  abort: repository requires features unknown to this Mercurial: featuresetup-test!
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 20820
diff changeset
    67
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    68
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    69
  $ hg clone --pull supported clone-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    70
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    71
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    72
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    73
  $ cd ..