perf: make perftags clear tags cache correctly
Before this patch, "hg perftags" command doesn't measure performance
of "repo.tags()" correctly, because it doesn't clear tags cache
correctly.
9dca7653b525 replaced repo._tags with repo._tagscache, but didn't
change the code path to clear tags cache in perftags() at that time.
BTW, full history of "tags cache" is:
-
d7df759d0e97 (or 0.6) introduced repo.tagscache as the first "tags cache"
-
5614a628d173 (or 1.4) replaced repo.tagscache with repo._tags
-
9dca7653b525 (or 2.0) replaced repo._tags with repo._tagscache
-
98c867ac1330 (or 2.5) made repo._tagscache filteredpropertycache
To make perftags clear tags cache correctly, and to increase
"historical portability" of perftags, this patch examines existence of
attributes in repo object, and guess appropriate procedure to clear
tags cache.
To avoid examining existence of attributes at each repetition, this
patch makes repocleartagscachefunc() return the function, which
actually clears tags cache.
mozilla-central repo (85 tags on 308365 revs) with each Mercurial
version between before and after this patch.
==== ========= =========
ver before after
==== ========= =========
1.9 0.476062 0.466464
------- *1 -------
2.0 0.346309 0.458327
2.1 0.343106 0.454489
------- *2 -------
2.2 0.069790 0.071263
2.3 0.067829 0.069340
2.4 0.068075 0.069573
------- *3 -------
2.5 0.021896 0.022406
2.6 0.021900 0.022374
2.7 0.021883 0.022379
2.8 0.021949 0.022327
2.9 0.021877 0.022330
3.0 0.021860 0.022314
3.1 0.021869 0.022669
3.2 0.021831 0.022668
3.3 0.021809 0.022691
3.4 0.021861 0.022916
3.5 0.019335 0.020749
3.6 0.019319 0.020866
3.7 0.018781 0.020251
------- *4 -------
3.8 0.068262 0.072558
3.9 0.069682 0.073773
==== ========= =========
(*1) repo._tags was replaced with repo._tagscache at this point
"repo._tags = None" in perftags "before" this patch doesn't clear
tags cache for Mercurial 2.0 or later. This causes significant
gap of "before" between 1.9 and 2.0 .
(*2) I'm not sure about significant gap at this point, but release
note of 2.2 described "a number of significant performance
improvements for large repositories"
(*3) filtered changelog was cached in repoview as repoview.changelog
at this point (by
4d92e2d75cff)
This avoids calculation of filtered changelog at each repetition
of t().
(*4) calculation of filtered changelog was included into wall time at
this point (by
332926212ef8), again
See below for detail about this significant gap:
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083410.html
$ echo "[extensions]" >> $HGRCPATH
$ echo "churn=" >> $HGRCPATH
create test repository
$ hg init repo
$ cd repo
$ echo a > a
$ hg ci -Am adda -u user1 -d 6:00
adding a
$ echo b >> a
$ echo b > b
$ hg ci -m changeba -u user2 -d 9:00 a
$ hg ci -Am addb -u user2 -d 9:30
adding b
$ echo c >> a
$ echo c >> b
$ echo c > c
$ hg ci -m changeca -u user3 -d 12:00 a
$ hg ci -m changecb -u user3 -d 12:15 b
$ hg ci -Am addc -u user3 -d 12:30
adding c
$ mkdir -p d/e
$ echo abc > d/e/f1.txt
$ hg ci -Am "add d/e/f1.txt" -u user1 -d 12:45 d/e/f1.txt
$ mkdir -p d/g
$ echo def > d/g/f2.txt
$ hg ci -Am "add d/g/f2.txt" -u user1 -d 13:00 d/g/f2.txt
churn separate directories
$ cd d
$ hg churn e
user1 1 ***************************************************************
churn all
$ hg churn
user1 3 ***************************************************************
user3 3 ***************************************************************
user2 2 ******************************************
churn excluding one dir
$ hg churn -X e
user3 3 ***************************************************************
user1 2 ******************************************
user2 2 ******************************************
churn up to rev 2
$ hg churn -r :2
user2 2 ***************************************************************
user1 1 ********************************
$ cd ..
churn with aliases
$ cat > ../aliases <<EOF
> user1 alias1
> user3 alias3
> not-an-alias
> EOF
churn with .hgchurn
$ mv ../aliases .hgchurn
$ hg churn
skipping malformed alias: not-an-alias
alias1 3 **************************************************************
alias3 3 **************************************************************
user2 2 *****************************************
$ rm .hgchurn
churn with column specifier
$ COLUMNS=40 hg churn
user1 3 ***********************
user3 3 ***********************
user2 2 ***************
churn by hour
$ hg churn -f '%H' -s
06 1 *****************
09 2 *********************************
12 4 ******************************************************************
13 1 *****************
churn with separated added/removed lines
$ hg rm d/g/f2.txt
$ hg ci -Am "removed d/g/f2.txt" -u user1 -d 14:00 d/g/f2.txt
$ hg churn --diffstat
user1 +3/-1 +++++++++++++++++++++++++++++++++++++++++--------------
user3 +3/-0 +++++++++++++++++++++++++++++++++++++++++
user2 +2/-0 +++++++++++++++++++++++++++
churn --diffstat with color
$ hg --config extensions.color= churn --config color.mode=ansi \
> --diffstat --color=always
user1 +3/-1 \x1b[0;32m+++++++++++++++++++++++++++++++++++++++++\x1b[0m\x1b[0;31m--------------\x1b[0m (esc)
user3 +3/-0 \x1b[0;32m+++++++++++++++++++++++++++++++++++++++++\x1b[0m (esc)
user2 +2/-0 \x1b[0;32m+++++++++++++++++++++++++++\x1b[0m (esc)
changeset number churn
$ hg churn -c
user1 4 ***************************************************************
user3 3 ***********************************************
user2 2 ********************************
$ echo 'with space = no-space' >> ../aliases
$ echo a >> a
$ hg commit -m a -u 'with space' -d 15:00
churn with space in alias
$ hg churn --aliases ../aliases -r tip
no-space 1 ************************************************************
$ cd ..
Issue833: ZeroDivisionError
$ hg init issue-833
$ cd issue-833
$ touch foo
$ hg ci -Am foo
adding foo
this was failing with a ZeroDivisionError
$ hg churn
test 0
$ cd ..
Ignore trailing or leading spaces in emails
$ cd repo
$ touch bar
$ hg ci -Am'bar' -u 'user4 <user4@x.com>'
adding bar
$ touch foo
$ hg ci -Am'foo' -u 'user4 < user4@x.com >'
adding foo
$ hg log -l2 --template '[{author|email}]\n'
[ user4@x.com ]
[user4@x.com]
$ hg churn -c
user1 4 *********************************************************
user3 3 *******************************************
user2 2 *****************************
user4@x.com 2 *****************************
with space 1 **************
Test multibyte sequences in names
$ echo bar >> bar
$ hg --encoding utf-8 ci -m'changed bar' -u 'El NiƱo <nino@x.com>'
$ hg --encoding utf-8 churn -ct '{author|person}'
user1 4 **********************************************************
user3 3 ********************************************
user2 2 *****************************
user4 2 *****************************
El Ni\xc3\xb1o 1 *************** (esc)
with space 1 ***************
Test --template argument, with backwards compatibility
$ hg churn -t '{author|user}'
user1 4 ***************************************************************
user3 3 ***********************************************
user2 2 ********************************
nino 1 ****************
with 1 ****************
0
user4 0
$ hg churn -T '{author|user}'
user1 4 ***************************************************************
user3 3 ***********************************************
user2 2 ********************************
nino 1 ****************
with 1 ****************
0
user4 0
$ hg churn -t 'alltogether'
alltogether 11 *********************************************************
$ hg churn -T 'alltogether'
alltogether 11 *********************************************************
$ cd ..