util: lower water mark when removing nodes after cost limit reached
See the inline comment for the reasoning here. This is a pretty
common strategy for garbage collectors, other cache-like primtives.
The performance impact is substantial:
$ hg perflrucachedict --size 4 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 100
! inserts w/ cost limit
! wall 1.659181 comb 1.650000 user 1.650000 sys 0.000000 (best of 7)
! wall 1.722122 comb 1.720000 user 1.720000 sys 0.000000 (best of 6)
! mixed w/ cost limit
! wall 1.139955 comb 1.140000 user 1.140000 sys 0.000000 (best of 9)
! wall 1.182513 comb 1.180000 user 1.180000 sys 0.000000 (best of 9)
$ hg perflrucachedict --size 1000 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 10000
! inserts
! wall 0.679546 comb 0.680000 user 0.680000 sys 0.000000 (best of 15)
! sets
! wall 0.825147 comb 0.830000 user 0.830000 sys 0.000000 (best of 13)
! inserts w/ cost limit
! wall 25.105273 comb 25.080000 user 25.080000 sys 0.000000 (best of 3)
! wall 1.724397 comb 1.720000 user 1.720000 sys 0.000000 (best of 6)
! mixed
! wall 0.807096 comb 0.810000 user 0.810000 sys 0.000000 (best of 13)
! mixed w/ cost limit
! wall 12.104470 comb 12.070000 user 12.070000 sys 0.000000 (best of 3)
! wall 1.190563 comb 1.190000 user 1.190000 sys 0.000000 (best of 9)
$ hg perflrucachedict --size 1000 --gets 1000000 --sets 1000000 --mixed 1000000 --costlimit 10000 --mixedgetfreq 90
! inserts
! wall 0.711177 comb 0.710000 user 0.710000 sys 0.000000 (best of 14)
! sets
! wall 0.846992 comb 0.850000 user 0.850000 sys 0.000000 (best of 12)
! inserts w/ cost limit
! wall 25.963028 comb 25.960000 user 25.960000 sys 0.000000 (best of 3)
! wall 2.184311 comb 2.180000 user 2.180000 sys 0.000000 (best of 5)
! mixed
! wall 0.728256 comb 0.730000 user 0.730000 sys 0.000000 (best of 14)
! mixed w/ cost limit
! wall 3.174256 comb 3.170000 user 3.170000 sys 0.000000 (best of 4)
! wall 0.773186 comb 0.770000 user 0.770000 sys 0.000000 (best of 13)
$ hg perflrucachedict --size 100000 --gets 1000000 --sets 1000000 --mixed 1000000 --mixedgetfreq 90 --costlimit 5000000
! gets
! wall 1.191368 comb 1.190000 user 1.190000 sys 0.000000 (best of 9)
! wall 1.195304 comb 1.190000 user 1.190000 sys 0.000000 (best of 9)
! inserts
! wall 0.950995 comb 0.950000 user 0.950000 sys 0.000000 (best of 11)
! inserts w/ cost limit
! wall 1.589732 comb 1.590000 user 1.590000 sys 0.000000 (best of 7)
! sets
! wall 1.094941 comb 1.100000 user 1.090000 sys 0.010000 (best of 9)
! mixed
! wall 0.936420 comb 0.940000 user 0.930000 sys 0.010000 (best of 10)
! mixed w/ cost limit
! wall 0.882780 comb 0.870000 user 0.870000 sys 0.000000 (best of 11)
This puts us ~2x slower than caches without cost accounting. And for
read-heavy workloads (the prime use cases for caches), performance is
nearly identical.
In the worst case (pure write workloads with cost accounting enabled),
we're looking at ~1.5us per insert on large caches. That seems "fast
enough."
Differential Revision: https://phab.mercurial-scm.org/D4505
$ hg init test
$ cd test
$ hg unbundle "$TESTDIR/bundles/remote.hg"
adding changesets
adding manifests
adding file changes
added 9 changesets with 7 changes to 4 files (+1 heads)
new changesets bfaf4b5cbf01:916f1afdef90 (9 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg up tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
$ for i in 0 1 2 3 4 5 6 7 8; do
> mkdir test-"$i"
> hg --cwd test-"$i" init
> hg -R test bundle -r "$i" test-"$i".hg test-"$i"
> cd test-"$i"
> hg unbundle ../test-"$i".hg
> hg verify
> hg tip -q
> cd ..
> done
searching for changes
1 changesets found
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
new changesets bfaf4b5cbf01 (1 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 1 changesets with 1 changes to 1 files
0:bfaf4b5cbf01
searching for changes
2 changesets found
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
new changesets bfaf4b5cbf01:21f32785131f (2 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 2 changesets with 2 changes to 1 files
1:21f32785131f
searching for changes
3 changesets found
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 1 files
new changesets bfaf4b5cbf01:4ce51a113780 (3 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 3 changesets with 3 changes to 1 files
2:4ce51a113780
searching for changes
4 changesets found
adding changesets
adding manifests
adding file changes
added 4 changesets with 4 changes to 1 files
new changesets bfaf4b5cbf01:93ee6ab32777 (4 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 4 changesets with 4 changes to 1 files
3:93ee6ab32777
searching for changes
2 changesets found
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
new changesets bfaf4b5cbf01:c70afb1ee985 (2 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 2 changesets with 2 changes to 1 files
1:c70afb1ee985
searching for changes
3 changesets found
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 1 files
new changesets bfaf4b5cbf01:f03ae5a9b979 (3 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 3 changesets with 3 changes to 1 files
2:f03ae5a9b979
searching for changes
4 changesets found
adding changesets
adding manifests
adding file changes
added 4 changesets with 5 changes to 2 files
new changesets bfaf4b5cbf01:095cb14b1b4d (4 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 4 changesets with 5 changes to 2 files
3:095cb14b1b4d
searching for changes
5 changesets found
adding changesets
adding manifests
adding file changes
added 5 changesets with 6 changes to 3 files
new changesets bfaf4b5cbf01:faa2e4234c7a (5 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 5 changesets with 6 changes to 3 files
4:faa2e4234c7a
searching for changes
5 changesets found
adding changesets
adding manifests
adding file changes
added 5 changesets with 5 changes to 2 files
new changesets bfaf4b5cbf01:916f1afdef90 (5 drafts)
(run 'hg update' to get a working copy)
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 5 changesets with 5 changes to 2 files
4:916f1afdef90
$ cd test-8
$ hg pull ../test-7
pulling from ../test-7
searching for changes
adding changesets
adding manifests
adding file changes
added 4 changesets with 2 changes to 3 files (+1 heads)
new changesets c70afb1ee985:faa2e4234c7a
1 local changesets published
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 9 changesets with 7 changes to 4 files
$ hg rollback
repository tip rolled back to revision 4 (undo pull)
$ cd ..
should fail
$ hg -R test bundle --base 2 -r tip test-bundle-branch1.hg test-3
abort: --base is incompatible with specifying a destination
[255]
$ hg -R test bundle -a -r tip test-bundle-branch1.hg test-3
abort: --all is incompatible with specifying a destination
[255]
$ hg -R test bundle -r tip test-bundle-branch1.hg
abort: repository default-push not found!
[255]
$ hg -R test bundle --base 2 -r tip test-bundle-branch1.hg
2 changesets found
$ hg -R test bundle --base 2 -r 7 test-bundle-branch2.hg
4 changesets found
$ hg -R test bundle --base 2 test-bundle-all.hg
6 changesets found
$ hg -R test bundle --base 2 --all test-bundle-all-2.hg
ignoring --base because --all was specified
9 changesets found
$ hg -R test bundle --base 3 -r tip test-bundle-should-fail.hg
1 changesets found
empty bundle
$ hg -R test bundle --base 7 --base 8 test-bundle-empty.hg
no changes found
[1]
issue76 msg2163
$ hg -R test bundle --base 3 -r 3 -r 3 test-bundle-cset-3.hg
no changes found
[1]
Issue1910: 'hg bundle --base $head' does not exclude $head from
result
$ hg -R test bundle --base 7 test-bundle-cset-7.hg
4 changesets found
$ hg clone test-2 test-9
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd test-9
revision 2
$ hg tip -q
2:4ce51a113780
$ hg unbundle ../test-bundle-should-fail.hg
adding changesets
transaction abort!
rollback completed
abort: 00changelog.i@93ee6ab32777: unknown parent!
[255]
revision 2
$ hg tip -q
2:4ce51a113780
$ hg unbundle ../test-bundle-all.hg
adding changesets
adding manifests
adding file changes
added 6 changesets with 4 changes to 4 files (+1 heads)
new changesets 93ee6ab32777:916f1afdef90 (6 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
revision 8
$ hg tip -q
8:916f1afdef90
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 9 changesets with 7 changes to 4 files
$ hg rollback
repository tip rolled back to revision 2 (undo unbundle)
revision 2
$ hg tip -q
2:4ce51a113780
$ hg unbundle ../test-bundle-branch1.hg
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
new changesets 93ee6ab32777:916f1afdef90 (2 drafts)
(run 'hg update' to get a working copy)
revision 4
$ hg tip -q
4:916f1afdef90
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 5 changesets with 5 changes to 2 files
$ hg rollback
repository tip rolled back to revision 2 (undo unbundle)
$ hg unbundle ../test-bundle-branch2.hg
adding changesets
adding manifests
adding file changes
added 4 changesets with 3 changes to 3 files (+1 heads)
new changesets c70afb1ee985:faa2e4234c7a (4 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
revision 6
$ hg tip -q
6:faa2e4234c7a
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 7 changesets with 6 changes to 3 files
$ hg rollback
repository tip rolled back to revision 2 (undo unbundle)
$ hg unbundle ../test-bundle-cset-7.hg
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
new changesets 93ee6ab32777:916f1afdef90 (2 drafts)
(run 'hg update' to get a working copy)
revision 4
$ hg tip -q
4:916f1afdef90
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 5 changesets with 5 changes to 2 files
$ cd ../test
$ hg merge 7
note: possible conflict - afile was renamed multiple times to:
anotherfile
adifferentfile
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m merge
$ cd ..
$ hg -R test bundle --base 2 test-bundle-head.hg
7 changesets found
$ hg clone test-2 test-10
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd test-10
$ hg unbundle ../test-bundle-head.hg
adding changesets
adding manifests
adding file changes
added 7 changesets with 4 changes to 4 files
new changesets 93ee6ab32777:03fc0b0e347c (7 drafts)
(run 'hg update' to get a working copy)
revision 9
$ hg tip -q
9:03fc0b0e347c
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
checked 10 changesets with 7 changes to 4 files
$ cd ..