osutil.c optimization for Win32

Patrick Mézard pmezard at gmail.com
Wed Sep 3 16:06:35 CDT 2008


Petr Kodl a écrit :
> This is an optimization taking avoiding most of the lstat calls by
> taking advantage of Win32 FindFirst/FindNext embedded iterator information.
> The speedup mileage may vary - I see factor of 2x with my average
> repository (~30k files) for simple hg stat on local repo - which makes
> it faster than Git ;-) on same tree
> 
> patch is recorded against hg-crew
> 
> 
> # HG changeset patch
> # User Petr Kodl<petrkodl at gmail.com <mailto:petrkodl at gmail.com>>
> # Date 1220467465 14400
> # Node ID b3110f7d0be144275457047ae32a3530ca5c37bc
> # Parent  5e1a867e5d65c059dc2a79e35769c5a99748c177
> lstat optimization on Win32 similar to osutil.c

[...]

> +        do
> +        {
> +            int isdir = (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
> +            int isro  = (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY);
> +            if(!isdir || (strcmp(fd.cFileName,".") &&
> strcmp(fd.cFileName,"..") && strcmp(fd.cFileName,".hg")))

Why are you excluding ".hg" here ? It makes test-hardlink-safety and test-nested-repo fail (I have not run the test suite again after this change, so it might be wrong too).

> +            {
> +                PyObject* item = PyTuple_New(keep_stat ? 3 : 2);
> +                if(!item)
> +                {
> +                    PyErr_NoMemory();
> +                    goto end;
> +                }
> +                PyTuple_SetItem(item,0,PyString_FromString(fd.cFileName));
> +                PyTuple_SetItem(item,1,PyInt_FromLong(isdir ? _S_IFDIR

--
Patrick Mézard


More information about the Mercurial-devel mailing list