changeset 18275:9818f22785b7

performance: speedup computation of unstable revisions In their current state, revset calls can be very costly, as we test predicates on the entire repository. This change drops revset call in favor of direct testing of the phase of changesets. Performance test on my Mercurial checkout - 19857 total changesets, - 1584 obsolete changesets, - 13310 obsolescence markers. Before: ! unstable ! wall 0.017366 After this changes: ! unstable ! wall 0.008093 Performance test on a Mozilla central checkout: - 117293 total changesets, - 1 obsolete changeset, - 1 obsolescence marker. Before: ! unstable ! wall 0.045190 After: ! unstable ! wall 0.000032
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 04 Jan 2013 03:15:21 +0100
parents 254b708fd37d
children 834ef7e70d0f
files mercurial/obsolete.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Mon Jan 07 15:50:25 2013 +0100
+++ b/mercurial/obsolete.py	Fri Jan 04 03:15:21 2013 +0100
@@ -660,7 +660,13 @@
 @cachefor('unstable')
 def _computeunstableset(repo):
     """the set of non obsolete revisions with obsolete parents"""
-    return set(repo.revs('(obsolete()::) - obsolete()'))
+    # revset is not efficient enough here
+    # we do (obsolete()::) - obsolete() by hand
+    obs = getrevs(repo, 'obsolete')
+    if not obs:
+        return set()
+    cl = repo.changelog
+    return set(r for r in cl.descendants(obs) if r not in obs)
 
 @cachefor('suspended')
 def _computesuspendedset(repo):