D12395: subsetmaker: use SortedSet for the scratch variant
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Tue Mar 22 07:06:10 UTC 2022
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This provides a massive speedup on wide repository with many heads. For example
on mozilla-try, this move from un-usable slow to fairly instant.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12395
AFFECTED FILES
contrib/perf-utils/subsetmaker.py
CHANGE DETAILS
diff --git a/contrib/perf-utils/subsetmaker.py b/contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py
+++ b/contrib/perf-utils/subsetmaker.py
@@ -15,6 +15,10 @@
smartset,
)
+import sortedcontainers
+
+SortedSet = sortedcontainers.SortedSet
+
revsetpredicate = registrar.revsetpredicate()
@@ -78,7 +82,7 @@
n = revsetlang.getinteger(n, _(b"scratch expects a number"))
selected = set()
- heads = set()
+ heads = SortedSet()
children_count = collections.defaultdict(lambda: 0)
parents = repo.changelog._uncheckedparentrevs
@@ -102,9 +106,7 @@
for x in range(n):
if not heads:
break
- pickable = list(heads)
- pickable.sort()
- pick = rand.choice(pickable)
+ pick = rand.choice(heads)
heads.remove(pick)
assert pick not in selected
selected.add(pick)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list