Patchwork [3,of,3,V2] dirstate._walkexplicit: don't bother normalizing '.'

login
register
mail settings
Submitter Siddharth Agarwal
Date March 30, 2015, 6:36 a.m.
Message ID <64ded2aa226dbe1d2e1f.1427697373@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8372/
State Accepted
Headers show

Comments

Siddharth Agarwal - March 30, 2015, 6:36 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1427678928 25200
#      Sun Mar 29 18:28:48 2015 -0700
# Node ID 64ded2aa226dbe1d2e1f96ec476d707cabe8e56e
# Parent  a05be84438fb2a502590b7ae7d5001308b558c03
dirstate._walkexplicit: don't bother normalizing '.'

The overwhelmingly common case is running commands like 'hg diff' with no
arguments. Therefore the only file that'll be listed is the root directory.
Normalizing that's just a waste of time.

This means that for a plain 'hg diff' we'll never need to construct the
foldmap, saving us a significant chunk of time.

On case-insensitive HFS+ on OS X, for a large repository with over 200,000
files, this brings down 'hg diff' from 2.97 seconds to 2.36.
Martin von Zweigbergk - March 30, 2015, 6:43 a.m.
Thanks. This series looks good to me. I'll leave it to Matt to queue it, in
case I'm missing some reason for normpath.

On Sun, Mar 29, 2015 at 11:39 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1427678928 25200
> #      Sun Mar 29 18:28:48 2015 -0700
> # Node ID 64ded2aa226dbe1d2e1f96ec476d707cabe8e56e
> # Parent  a05be84438fb2a502590b7ae7d5001308b558c03
> dirstate._walkexplicit: don't bother normalizing '.'
>
> The overwhelmingly common case is running commands like 'hg diff' with no
> arguments. Therefore the only file that'll be listed is the root directory.
> Normalizing that's just a waste of time.
>
> This means that for a plain 'hg diff' we'll never need to construct the
> foldmap, saving us a significant chunk of time.
>
> On case-insensitive HFS+ on OS X, for a large repository with over 200,000
> files, this brings down 'hg diff' from 2.97 seconds to 2.36.
>
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -634,7 +634,9 @@
>
>          alldirs = None
>          for ff in files:
> -            if normalize:
> +            # constructing the foldmap is expensive, so don't do it for
> the
> +            # common case where files is ['.']
> +            if normalize and ff != '.':
>                  nf = normalize(ff, False, True)
>              else:
>                  nf = ff
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - March 30, 2015, 10:33 p.m.
On 03/29/2015 11:43 PM, Martin von Zweigbergk wrote:
> Thanks. This series looks good to me. I'll leave it to Matt to queue it,
> in case I'm missing some reason for normpath.

I've moved forward and this is pushed to the clowncopter. This sounds 
correct to me and if we have missed something, we will rollback it and 
add proper test cases.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -634,7 +634,9 @@ 
 
         alldirs = None
         for ff in files:
-            if normalize:
+            # constructing the foldmap is expensive, so don't do it for the
+            # common case where files is ['.']
+            if normalize and ff != '.':
                 nf = normalize(ff, False, True)
             else:
                 nf = ff