# HG changeset patch # User Gregory Szorc # Date 1494097351 25200 # Node ID 112ba1c7d65d461dab388f8d6f9931e4ce1de134 # Parent 1395f843ece4ee83dc031413f93a43d3404f39b9 perf: store reference to revlog._chunkraw in a local variable To prepare for renaming revlog._chunkraw, we stuff a reference to this metho in a local variable. This does 2 things. First, it moves the attribute lookup outside of a loop, which more accurately measures the time of the code being invoked. Second, it allows us to alias to different methods depending on their presence (perf.py needs to support running against old Mercurial versions). Removing an attribute lookup from a tigh loop appears to shift the numbers slightly with mozilla-central: $ hg perfrevlogchunks -c ! read ! wall 0.354789 comb 0.340000 user 0.330000 sys 0.010000 (best of 28) ! wall 0.335932 comb 0.330000 user 0.290000 sys 0.040000 (best of 30) ! read w/ reused fd ! wall 0.342326 comb 0.340000 user 0.320000 sys 0.020000 (best of 29) ! wall 0.332857 comb 0.340000 user 0.290000 sys 0.050000 (best of 30) ! read batch ! wall 0.023623 comb 0.020000 user 0.000000 sys 0.020000 (best of 124) ! wall 0.023666 comb 0.020000 user 0.000000 sys 0.020000 (best of 125) ! read batch w/ reused fd ! wall 0.023828 comb 0.020000 user 0.000000 sys 0.020000 (best of 124) ! wall 0.023556 comb 0.020000 user 0.000000 sys 0.020000 (best of 126) diff -r 1395f843ece4 -r 112ba1c7d65d contrib/perf.py --- a/contrib/perf.py Sat May 06 12:02:12 2017 -0700 +++ b/contrib/perf.py Sat May 06 12:02:31 2017 -0700 @@ -887,6 +887,7 @@ see ``perfrevlog`` and ``perfrevlogrevision``. """ rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts) + segmentforrevs = rl._chunkraw # Verify engines argument. if engines: @@ -918,22 +919,22 @@ def doread(): rl.clearcaches() for rev in revs: - rl._chunkraw(rev, rev) + segmentforrevs(rev, rev) def doreadcachedfh(): rl.clearcaches() fh = rlfh(rl) for rev in revs: - rl._chunkraw(rev, rev, df=fh) + segmentforrevs(rev, rev, df=fh) def doreadbatch(): rl.clearcaches() - rl._chunkraw(revs[0], revs[-1]) + segmentforrevs(revs[0], revs[-1]) def doreadbatchcachedfh(): rl.clearcaches() fh = rlfh(rl) - rl._chunkraw(revs[0], revs[-1], df=fh) + segmentforrevs(revs[0], revs[-1], df=fh) def dochunk(): rl.clearcaches() @@ -1002,6 +1003,7 @@ raise error.CommandError('perfrevlogrevision', 'invalid arguments') r = cmdutil.openrevlog(repo, 'perfrevlogrevision', file_, opts) + segmentforrevs = r._chunkraw node = r.lookup(rev) rev = r.rev(node) @@ -1033,7 +1035,7 @@ def doread(chain): if not cache: r.clearcaches() - r._chunkraw(chain[0], chain[-1]) + segmentforrevs(chain[0], chain[-1]) def dorawchunks(data, chain): if not cache: @@ -1061,7 +1063,7 @@ r.revision(node) chain = r._deltachain(rev)[0] - data = r._chunkraw(chain[0], chain[-1])[1] + data = segmentforrevs(chain[0], chain[-1])[1] rawchunks = getrawchunks(data, chain) bins = r._chunks(chain) text = str(bins[0])