Mercurial > hg-stable
changeset 27784:432242f41d9f
obsolete: make _computeobsoleteset much faster
This patch makes _computeobsoleteset much faster by looping
over the draft and secrets as opposed to looping over the
successors.
This works because "number of draft and secret" is typically
way smaller(<100) than the number of successor in the repo (~90k in
my checkout of core mercurial as of today). And also because
it is very fast to compute "not public()".
I timed the code with the following setup:
"""
from mercurial import hg, ui, obsolete
ui = ui.ui()
repo = hg.repository(ui, "~/hg")
l = repo.obsstore.successors # This caches the result
"""
With about 90k successors.
k=obsolete._computeobsoleteset(repo) before this patch:
10 loops, best of 3: 33.9 ms per loop
k=obsolete._computeobsoleteset(repo) after this patch:
10000 loops, best of 3: 83.3 µs per loop
author | Laurent Charignon <lc2817@columbia.edu> |
---|---|
date | Wed, 13 Jan 2016 21:52:26 -0800 |
parents | 1d095371de47 |
children | ba427b51f1d8 |
files | mercurial/obsolete.py |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/obsolete.py Tue Jan 12 08:34:38 2016 +0000 +++ b/mercurial/obsolete.py Wed Jan 13 21:52:26 2016 -0800 @@ -1119,12 +1119,11 @@ def _computeobsoleteset(repo): """the set of obsolete revisions""" obs = set() - getrev = repo.changelog.nodemap.get - getphase = repo._phasecache.phase - for n in repo.obsstore.successors: - rev = getrev(n) - if rev is not None and getphase(repo, rev): - obs.add(rev) + getnode = repo.changelog.node + notpublic = repo.revs("not public()") + for r in notpublic: + if getnode(r) in repo.obsstore.successors: + obs.add(r) return obs @cachefor('unstable')