[PATCH] revset: lower weight for _intlist function

Durham Goode durham at fb.com
Fri Sep 12 16:35:47 CDT 2014


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1410556878 25200
#      Fri Sep 12 14:21:18 2014 -0700
# Node ID f40b873cf6aa1a7b0f401c3df8090e6fb8000698
# Parent  ca854cd4a26a8770fbc22b4d7ee1ac6823b682a5
revset: lower weight for _intlist function

The histedit command uses a revset like:

(_intlist('1234\x001235')) and merge()

Previously the optimizer gave a weight of 1.5 to the _intlist side (1 for the
function, 0.5 for the string) which caused it to process the merge() side first.
This caused it to evaluate merge against every commit in the repo, which took
2.5 seconds on a large repo.

I changed the weight of _intlist to 0, since it's a trivial calculation, which
makes it process intlist first, which makes merge apply only to the revs in the
list. Which makes the revset take 0.15 seconds now. Cutting off 2.4 seconds off
our histedit performance.

>From the revset benchmark:
revset #25: (_intlist('20000\x0020001')) and merge()
0) obsolete feature not enabled but 54243 markers found!
! wall 0.036767 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
1) obsolete feature not enabled but 54243 markers found!
! wall 0.000198 comb 0.000000 user 0.000000 sys 0.000000 (best of 9084)

diff --git a/contrib/revsetbenchmarks.txt b/contrib/revsetbenchmarks.txt
--- a/contrib/revsetbenchmarks.txt
+++ b/contrib/revsetbenchmarks.txt
@@ -23,3 +23,4 @@
 max(::(tip~20) - obsolete())
 roots((0:tip)::)
 (not public() - obsolete())
+(_intlist('20000\x0020001')) and merge()
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1913,7 +1913,7 @@
             w = 100 # very slow
         elif f == "ancestor":
             w = 1 * smallbonus
-        elif f in "reverse limit first":
+        elif f in "reverse limit first _intlist":
             w = 0
         elif f in "sort":
             w = 10 # assume most sorts look at changelog


More information about the Mercurial-devel mailing list