sapling/tests/test-perftweaks.t

118 lines
2.7 KiB
Perl
Raw Normal View History

Test disabling the tag cache
$ hg init tagcache
$ cd tagcache
$ cat >> .hg/hgrc <<EOF
> [extensions]
> blackbox=
> EOF
$ touch a && hg add -q a
$ hg commit -qm "Foo"
$ hg tag foo
$ rm -rf .hg/cache .hg/blackbox.log
$ hg tags
tip 1:2cc13e58bcd8
foo 0:be5a2292aa62
#if no-fsmonitor
$ hg blackbox | grep tag
*> tags (glob)
*> writing * bytes to cache/hgtagsfnodes1 (glob)
*> writing .hg/cache/tags2-visible with 1 tags (glob)
*> tags exited 0 after * seconds (glob)
#endif
$ rm -rf .hg/cache .hg/blackbox.log
$ hg tags --config perftweaks.disabletags=True
tip 1:2cc13e58bcd8
$ hg blackbox | grep tag
*> tags* (glob)
*> tags --config 'perftweaks.disabletags=True' exited 0 after * seconds (glob)
2015-10-07 22:29:56 +03:00
$ cd ..
#if osx
#else
2015-10-07 22:29:56 +03:00
Test disabling the case conflict check (only fails on case sensitive systems)
$ hg init casecheck
$ cd casecheck
$ cat >> .hg/hgrc <<EOF
> [perftweaks]
> disablecasecheck=True
> EOF
$ touch a
$ hg add a
$ hg commit -m a
$ touch A
$ hg add A
warning: possible case-folding collision for A
$ hg commit -m A
$ cd ..
#endif
Test disabling the branchcache
$ hg init branchcache
$ cd branchcache
$ cat >> .hg/hgrc <<EOF
> [extensions]
> blackbox=
> strip=
> EOF
$ echo a > a
$ hg commit -Aqm a
#if no-fsmonitor
$ hg blackbox
*> commit -Aqm a (glob)
*> updated served branch cache in * seconds (glob)
*> wrote served branch cache with 1 labels and 1 nodes (glob)
*> commit -Aqm a exited 0 after * seconds (glob)
*> blackbox (glob)
#endif
$ hg strip -q -r . -k
$ rm .hg/blackbox.log
$ rm -rf .hg/cache
perftweaks: further cleanup branchmap code paths The branchmap code is actually quite expensive (O(changelog)). So let's try to avoid them as much as possible. First, reading or writing on-disk caches are unnecessary since even with the on-disk cache, it still has to pay O(changelog) headrevs cost to incrementally update the cache, which is the same cost of rebuilding the cache from memory. Secondly, `repo.branchmap()` calls update unconditionally so the update function should be smart to not update unnecessarily. That's the `validfor` check. Thirdly, `repo.branchmap()` calls `branchmap.updatecache` which constructs the "served", "immutable", "base" repoviews as an attempt to "incrementally" build the branch cache for the "visible" repoview. There is no need to have that many repoviews in this case. Therefore `branchmap.updatecache` is replaced to a simplified version that does not construct other repoviews. Note: there is a simple cache in index.headrevs() but that cache gets invalidated if filteredrevs has a different address - that means different repoviews will not benefit from index.headrevs() cache if they pass different filteredrevs objects. The change is gated by a new config option `perftweaks.disablebranchcache2` so we can rollback if anything went wrong. Test Plan: Run core hg tests which do not use branches (about 371 tests): ruby -e 'puts Dir["*.t"].reject{|x|File.read(x)[/(hg.* branch(es)?|branch\(|--branch|branch:\s*[^d]|cache\/branch|updating to branch\s*[^d])/]}' > /tmp/tests ./run-tests.py -l --extra-config-opt=extensions.perftweaks=$HOME/fb-hgext/hgext3rd/perftweaks.py --extra-config-opt=perftweaks.disablebranchcache=1 --extra-config-opt=perftweaks.disablebranchcache2=1 -j `nproc` `cat /tmp/tests` Categorize them and analyse failures: "abort: push creates new remote head X": Failed test-exchange-obsmarkers-case-A2.t: output changed Failed test-exchange-obsmarkers-case-A3.t: output changed Failed test-exchange-obsmarkers-case-A5.t: output changed Failed test-exchange-obsmarkers-case-B3.t: output changed Failed test-exchange-obsmarkers-case-D4.t: output changed Failed test-obsolete-checkheads.t: output changed Failed test-push-checkheads-unpushed-D3.t: output changed Failed test-push-checkheads-unpushed-D4.t: output changed Failed test-push-checkheads-unpushed-D5.t: output changed Failed test-push-checkheads-unpushed-D7.t: output changed Failed test-bundle2-exchange.t: output changed Failed test-phases-exchange.t: output changed This is already broken before this change because we ignored `revgen` parameter passed to `branchcache.update` from `checkheads` code path. Harmless: config/extension/help/ui.log output changes: Failed test-basic.t: output changed Failed test-debugextensions.t: output changed Failed test-help.t: output changed Failed test-devel-warnings.t: output changed Failed test-blackbox.t: output changed Harmless: Change because .hg/cache does not get created: Failed test-parseindex.t: output changed Harmless: Branch related tests that are not filtered by regex: Failed test-convert-cvs-branch.t: output changed Failed test-convert-cvs.t: output changed Failed test-convert-tagsbranch-topology.t: output changed Harmless "Unable to find a working hg binary to extract the version from the repository tags": Failed test-run-tests.t: output changed Run jf integration test which catches an error caused by previous problematic patches. Differential Revision: https://phab.mercurial-scm.org/D1501
2017-12-05 22:53:07 +03:00
$ hg commit -Aqm a --config perftweaks.disablebranchcache=True --config perftweaks.disablebranchcache2=True
#if no-fsmonitor
$ hg blackbox
*> commit -Aqm a* (glob)
*> perftweaks updated served branch cache (glob)
perftweaks: further cleanup branchmap code paths The branchmap code is actually quite expensive (O(changelog)). So let's try to avoid them as much as possible. First, reading or writing on-disk caches are unnecessary since even with the on-disk cache, it still has to pay O(changelog) headrevs cost to incrementally update the cache, which is the same cost of rebuilding the cache from memory. Secondly, `repo.branchmap()` calls update unconditionally so the update function should be smart to not update unnecessarily. That's the `validfor` check. Thirdly, `repo.branchmap()` calls `branchmap.updatecache` which constructs the "served", "immutable", "base" repoviews as an attempt to "incrementally" build the branch cache for the "visible" repoview. There is no need to have that many repoviews in this case. Therefore `branchmap.updatecache` is replaced to a simplified version that does not construct other repoviews. Note: there is a simple cache in index.headrevs() but that cache gets invalidated if filteredrevs has a different address - that means different repoviews will not benefit from index.headrevs() cache if they pass different filteredrevs objects. The change is gated by a new config option `perftweaks.disablebranchcache2` so we can rollback if anything went wrong. Test Plan: Run core hg tests which do not use branches (about 371 tests): ruby -e 'puts Dir["*.t"].reject{|x|File.read(x)[/(hg.* branch(es)?|branch\(|--branch|branch:\s*[^d]|cache\/branch|updating to branch\s*[^d])/]}' > /tmp/tests ./run-tests.py -l --extra-config-opt=extensions.perftweaks=$HOME/fb-hgext/hgext3rd/perftweaks.py --extra-config-opt=perftweaks.disablebranchcache=1 --extra-config-opt=perftweaks.disablebranchcache2=1 -j `nproc` `cat /tmp/tests` Categorize them and analyse failures: "abort: push creates new remote head X": Failed test-exchange-obsmarkers-case-A2.t: output changed Failed test-exchange-obsmarkers-case-A3.t: output changed Failed test-exchange-obsmarkers-case-A5.t: output changed Failed test-exchange-obsmarkers-case-B3.t: output changed Failed test-exchange-obsmarkers-case-D4.t: output changed Failed test-obsolete-checkheads.t: output changed Failed test-push-checkheads-unpushed-D3.t: output changed Failed test-push-checkheads-unpushed-D4.t: output changed Failed test-push-checkheads-unpushed-D5.t: output changed Failed test-push-checkheads-unpushed-D7.t: output changed Failed test-bundle2-exchange.t: output changed Failed test-phases-exchange.t: output changed This is already broken before this change because we ignored `revgen` parameter passed to `branchcache.update` from `checkheads` code path. Harmless: config/extension/help/ui.log output changes: Failed test-basic.t: output changed Failed test-debugextensions.t: output changed Failed test-help.t: output changed Failed test-devel-warnings.t: output changed Failed test-blackbox.t: output changed Harmless: Change because .hg/cache does not get created: Failed test-parseindex.t: output changed Harmless: Branch related tests that are not filtered by regex: Failed test-convert-cvs-branch.t: output changed Failed test-convert-cvs.t: output changed Failed test-convert-tagsbranch-topology.t: output changed Harmless "Unable to find a working hg binary to extract the version from the repository tags": Failed test-run-tests.t: output changed Run jf integration test which catches an error caused by previous problematic patches. Differential Revision: https://phab.mercurial-scm.org/D1501
2017-12-05 22:53:07 +03:00
*> commit -Aqm a * exited 0 after * seconds (glob)
*> blackbox (glob)
#endif
$ cd ..
Test avoiding calculating head changes during commit
$ hg init branchatcommit
$ cd branchatcommit
$ hg debugdrawdag<<'EOS'
> B
> |
> A
> EOS
$ hg up -q A
$ echo C > C
$ hg commit -m C -A C
$ hg up -q A
$ echo D > D
$ hg commit -m D -A D
Test disabling updating branchcache during commit
$ $TESTDIR/ls-l.py .hg/cache | grep branch
-rw-r--r-- 196 branch2-served
$ rm -f .hg/cache/branch*
$ echo D >> D
$ hg commit -m D2
$ $TESTDIR/ls-l.py .hg/cache | grep branch
-rw-r--r-- 196 branch2-served
$ rm -f .hg/cache/branch*
$ echo D >> D
$ hg commit -m D3 --config perftweaks.disableupdatebranchcacheoncommit=1 --config perftweaks.disableheaddetection=1
$ $TESTDIR/ls-l.py .hg/cache | grep branch
[1]
$ cd ..