Patchwork [STABLE] revset: drop pre-lazyset optimization for stringset of subset == entire repo

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 3, 2015, 2:36 a.m.
Message ID <e96450f354b1b693385d.1420252571@mimosa>
Download mbox | patch
Permalink /patch/7307/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 3, 2015, 2:36 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1420248308 -32400
#      Sat Jan 03 10:25:08 2015 +0900
# Branch stable
# Node ID e96450f354b1b693385d9cd1e1374fa910e1bf5f
# Parent  4308087f2fbd90b5beaac53a71d6264684ee0c40
revset: drop pre-lazyset optimization for stringset of subset == entire repo

It was introduced at e44ebd2a142a, where spanset.__contains__() did not exist.
Nowadays, we have to pay huge penalty for len(subset).

The following example showed that OR operation could be O(n * m^2)
(n: len(repo), m: number of OR operators, m >= 2) probably because of
filteredset.__len__.

revset #0: 0|1|2|3|4|5|6|7|8|9
0) wall 8.092713 comb 8.090000 user 8.090000 sys 0.000000 (best of 3)
1) wall 0.445354 comb 0.450000 user 0.430000 sys 0.020000 (best of 22)
2) wall 0.000389 comb 0.000000 user 0.000000 sys 0.000000 (best of 7347)
(0: 3.2.4, 1: 3.1.2, 2: this patch)
Pierre-Yves David - Jan. 4, 2015, 7:37 a.m.
On 01/02/2015 06:36 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1420248308 -32400
> #      Sat Jan 03 10:25:08 2015 +0900
> # Branch stable
> # Node ID e96450f354b1b693385d9cd1e1374fa910e1bf5f
> # Parent  4308087f2fbd90b5beaac53a71d6264684ee0c40
> revset: drop pre-lazyset optimization for stringset of subset == entire repo

this one is pushed to the clowncopter, thanks. (for stable)

The inefficiency of this case is suspicious and probably worth 
investigating.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -255,7 +255,7 @@  def stringset(repo, subset, x):
     x = repo[x].rev()
     if x == -1 and len(subset) == len(repo):
         return baseset([-1])
-    if len(subset) == len(repo) or x in subset:
+    if x in subset:
         return baseset([x])
     return baseset()