changeset 18273:a2d54f68e13c

performance: speedup computation of unserved revisions In their current state, revset calls can be very costly, as we test predicates on the entire repository. The "unserved" filter is used in multiple applications, and in particular in some branch cache loading operations. We need to make it fast. This change drops revset calls in favor of direct testing of the phase of a changeset. Performance test on my Mercurial checkout - 19857 total changesets, - 1584 obsolete changesets, - 13310 obsolescence markers. Before: ! unserved ! wall 0.030477 After: ! unserved ! wall 0.011844 Performance test on a Mozilla central checkout: - 117293 total changesets, - 1 obsolete changeset, - 1 obsolescence marker. Before: ! unserved ! wall 0.111259 After: ! unserved ! wall 0.000084
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Fri, 04 Jan 2013 20:19:05 +0100
parents 95ef7a87c053
children 254b708fd37d
files mercurial/repoview.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repoview.py	Fri Jan 04 05:44:01 2013 +0100
+++ b/mercurial/repoview.py	Fri Jan 04 20:19:05 2013 +0100
@@ -38,8 +38,17 @@
     Secret and hidden changeset should not pretend to be here."""
     assert not repo.changelog.filteredrevs
     # fast path in simple case to avoid impact of non optimised code
-    if phases.hassecret(repo) or repo.obsstore:
-        return frozenset(repo.revs('hidden() + secret()'))
+    hiddens = filteredrevs(repo, 'hidden')
+    if phases.hassecret(repo):
+        cl = repo.changelog
+        secret = phases.secret
+        getphase = repo._phasecache.phase
+        first = min(cl.rev(n) for n in repo._phasecache.phaseroots[secret])
+        revs = cl.revs(start=first)
+        secrets = set(r for r in revs if getphase(repo, r) >= secret)
+        return frozenset(hiddens | secrets)
+    else:
+        return hiddens
     return frozenset()
 
 def computemutable(repo):