Patchwork [3,of,3] context: generate filtered manifest efficiently for exact matchers

login
register
mail settings
Submitter Siddharth Agarwal
Date July 13, 2014, 1:41 a.m.
Message ID <e6c10ed302aaba92013a.1405215662@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/5157/
State Accepted
Commit e6754f5e4cf79245ca16303e639491a04e3d0430
Headers show

Comments

Siddharth Agarwal - July 13, 2014, 1:41 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1405213143 25200
#      Sat Jul 12 17:59:03 2014 -0700
# Node ID e6c10ed302aaba92013aae7c4d6ca7d855851978
# Parent  9b0e9a5840aadf91fca63dd6d8cd8e45dd429a06
context: generate filtered manifest efficiently for exact matchers

When the matcher is exact, there's no reason to iterate over the entire
manifest. It's much more efficient to iterate over the list of files instead.

For a repository with approximately 300,000 files, this speeds up
hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds
to 10.5 seconds.
Matt Mackall - July 15, 2014, 10:13 p.m.
On Sat, 2014-07-12 at 18:41 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1405213143 25200
> #      Sat Jul 12 17:59:03 2014 -0700
> # Node ID e6c10ed302aaba92013aae7c4d6ca7d855851978
> # Parent  9b0e9a5840aadf91fca63dd6d8cd8e45dd429a06
> context: generate filtered manifest efficiently for exact matchers

These are queued for default, thanks.
Matt Mackall - July 15, 2014, 10:15 p.m.
On Sat, 2014-07-12 at 18:41 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1405213143 25200
> #      Sat Jul 12 17:59:03 2014 -0700
> # Node ID e6c10ed302aaba92013aae7c4d6ca7d855851978
> # Parent  9b0e9a5840aadf91fca63dd6d8cd8e45dd429a06
> context: generate filtered manifest efficiently for exact matchers

These are queued for default, thanks.
Matt Mackall - July 17, 2014, 8:22 p.m.
On Sat, 2014-07-12 at 18:41 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1405213143 25200
> #      Sat Jul 12 17:59:03 2014 -0700
> # Node ID e6c10ed302aaba92013aae7c4d6ca7d855851978
> # Parent  9b0e9a5840aadf91fca63dd6d8cd8e45dd429a06
> context: generate filtered manifest efficiently for exact matchers

These are queued for default, thanks.
Matt Mackall - July 17, 2014, 8:28 p.m.
On Sat, 2014-07-12 at 18:41 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1405213143 25200
> #      Sat Jul 12 17:59:03 2014 -0700
> # Node ID e6c10ed302aaba92013aae7c4d6ca7d855851978
> # Parent  9b0e9a5840aadf91fca63dd6d8cd8e45dd429a06
> context: generate filtered manifest efficiently for exact matchers

These are queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -71,9 +71,13 @@ 
         object oriented way for other contexts to customize the manifest
         generation.
         """
+        if match.always():
+            return self.manifest().copy()
+
+        if match.matchfn == match.exact:
+            return self.manifest().intersectfiles(match.files())
+
         mf = self.manifest().copy()
-        if match.always():
-            return mf
         for fn in mf.keys():
             if not match(fn):
                 del mf[fn]