##// END OF EJS Templates
bisect: avoid adding irrelevant revisions to bisect state...
bisect: avoid adding irrelevant revisions to bisect state When adding new revisions to the bisect state, it only makes sense to add information about revisions that are under consideration (i.e., those that are topologically between the known good and bad revisions). However, if the user passes in a revset (e.g., '!merge()' to exclude merge commits), hg will resolve the revset first and add all matching revisions to the bisect state (which in this case would likely be the majority of revisions in the repo). To avoid this, revisions should only be added to the bisect state if they are between the good and bad revisions (and therefore relevant to the bisection). -- Here are the results of some performance tests using the `mozilla-central` repo (since it is one of the largest freely-available hg repositories in the wild). These tests compare the performance of a locally-built `hg` before and after application of this series. Note that `--noupdate` is passed to avoid including update time (which should not vary across cases). Setup (run between each test): $ hg bisect --reset $ hg bisect --noupdate --bad 56c3ad4bde5c70714b784ccf15d099e0df0f5bde $ hg bisect --noupdate --good 57426696adaf08298af3027fa77486fee0633b13 Test using a revset that returns a very large number of revisions: $ time hg bisect --noupdate --skip '!merge()' > /dev/null Before: real 0m9.398s user 0m9.233s sys 0m0.120s After: real 0m1.513s user 0m1.425s sys 0m0.052s Test using a revset that is expensive to compute: $ time hg bisect --noupdate --skip 'desc("Bug")' > /dev/null Before: real 0m49.853s user 0m49.580s sys 0m0.243s After: real 0m4.120s user 0m4.036s sys 0m0.048s

File last commit:

r49731:42d2b31c default
r50337:81623652 default
Show More
test-profile.t
180 lines | 4.8 KiB | text/troff | Tads3Lexer
test --time
$ hg --time help -q help 2>&1 | grep time > /dev/null
$ hg init a
$ cd a
Function to check that statprof ran
$ statprofran () {
> egrep 'Sample count:|No samples recorded' > /dev/null
> }
test --profile
$ hg st --profile 2>&1 | statprofran
Abreviated version
$ hg st --prof 2>&1 | statprofran
In alias
$ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran
#if lsprof
$ prof () {
> hg --config profiling.type=ls --profile $@
> }
$ prof st 2>../out
$ grep CallCount ../out > /dev/null || cat ../out
$ prof --config profiling.output=../out st
$ grep CallCount ../out > /dev/null || cat ../out
$ prof --config profiling.output=blackbox --config extensions.blackbox= st
$ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log
$ prof --config profiling.format=text st 2>../out
$ grep CallCount ../out > /dev/null || cat ../out
$ echo "[profiling]" >> $HGRCPATH
$ echo "format=kcachegrind" >> $HGRCPATH
$ prof st 2>../out
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
$ prof --config profiling.output=../out st
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
#endif
#if lsprof serve
Profiling of HTTP requests works
$ prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
$ cat ../hg.pid >> $DAEMON_PIDS
$ hg -q clone -U http://localhost:$HGPORT ../clone
A single profile is logged because file logging doesn't append
$ grep CallCount ../profile.log | wc -l
\s*1 (re)
#endif
Install an extension that can sleep and guarantee a profiler has time to run
$ cat >> sleepext_with_a_long_filename.py << EOF
> import time
> from mercurial import registrar
> cmdtable = {}
> command = registrar.command(cmdtable)
> @command(b'sleep', [], b'hg sleep')
> def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
> t = time.time() # don't use time.sleep because we need CPU time
> while time.time() - t < 0.5:
> pass
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> sleep = `pwd`/sleepext_with_a_long_filename.py
> EOF
statistical profiler works
$ hg --profile sleep 2>../out
$ cat ../out | statprofran
Various statprof formatters work
$ hg --profile --config profiling.statformat=byline sleep 2>../out || cat ../out
$ grep -v _path_stat ../out | head -n 3
% cumulative self
time seconds seconds name
* sleepext_with_a_long_filename.py:*:sleep_for_at_least_one_stat_cycle (glob)
$ cat ../out | statprofran
$ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
$ head -n 1 ../out
% cumulative self
$ cat ../out | statprofran
Windows real time tracking is broken, only use CPU
#if no-windows
$ hg --profile --config profiling.time-track=real --config profiling.statformat=hotpath sleep 2>../out || cat ../out
$ cat ../out | statprofran
$ grep sleepext_with_a_long_filename.py ../out | head -n 1
.* [0-9.]+% [0-9.]+s sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
#endif
$ hg --profile --config profiling.time-track=cpu --config profiling.statformat=hotpath sleep 2>../out || cat ../out
$ cat ../out | statprofran
$ grep sleepext_with_a_long_filename.py ../out | head -n 1
.* [0-9.]+% [0-9.]+s sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
$ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
$ cat ../out
\[\[-?\d+.* (re)
statprof can be used as a standalone module
$ "$PYTHON" -m mercurial.statprof hotpath
must specify --file to load
[1]
$ cd ..
#if no-chg
profiler extension could be loaded before other extensions
$ cat > fooprof.py <<EOF
> import contextlib
> import sys
> @contextlib.contextmanager
> def profile(ui, fp):
> print('fooprof: start profile')
> sys.stdout.flush()
> yield
> print('fooprof: end profile')
> sys.stdout.flush()
> def extsetup(ui):
> ui.write(b'fooprof: loaded\n')
> EOF
$ cat > otherextension.py <<EOF
> def extsetup(ui):
> ui.write(b'otherextension: loaded\n')
> EOF
$ hg init b
$ cd b
$ cat >> .hg/hgrc <<EOF
> [extensions]
> other = $TESTTMP/otherextension.py
> fooprof = $TESTTMP/fooprof.py
> EOF
$ hg root
otherextension: loaded
fooprof: loaded
$TESTTMP/b
$ HGPROF=fooprof hg root --profile
fooprof: loaded
fooprof: start profile
otherextension: loaded
$TESTTMP/b
fooprof: end profile
$ HGPROF=other hg root --profile 2>&1 | head -n 2
otherextension: loaded
unrecognized profiler 'other' - ignored
$ HGPROF=unknown hg root --profile 2>&1 | head -n 1
unrecognized profiler 'unknown' - ignored
$ cd ..
#endif