[PATCH V2 RESEND] win32: improve the performance of win32.unlink() over CIFS

Simon Heimberg simohe at besonet.ch
Wed Feb 19 13:47:01 CST 2014


On 2014-02-17 04:02, Kaz Nishimura:
> # HG changeset patch
> # User Kaz Nishimura <kazssym at vx68k.org>
> # Date 1381984037 -32400
> #      Thu Oct 17 13:27:17 2013 +0900
> # Node ID 95a976e04589e3d33f69805dff56a249bee250ae
> # Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
> win32: improve the performance of win32.unlink() over CIFS
>
> Emulating POSIX unlink() behavior with os.rename() and os.unlink() is often slow
> especially over CIFS from Windows clients due to its protocol overhead. This
> patch changes win32.unlink() to try first an exclusive open with the Win32
> delete-on-close flag, and if a sharing violation is detected, to fall back to
> the original emulation.

LGTM, only some minor details. No new test failure on my windows machine.
And it seems to run quicker on my machine too, on a local hard drive. (I 
did not try on CIFS.) Not really sure about the times, they vary too 
mucht. My results are at the end.
I checked that the new case is used by printing some output else.

>
> This patch also removes a test with os.path.isdir() since we expect opening a
> directory shall fail as os.unlink() would.

No knowledge about this. I guess os.path.isdir really is unnecessary. 
Maybe move this in a separate 1st patch.

>
> Example measurements (repeated 3-times after 1-time calibration):
>
> (Without this patch: hg update from null to default)
> 127 files updated, 0 files merged, 0 files removed, 0 files unresolved
> time: real 19.871 secs (user 0.328+0.000 sys 1.794+0.000)
> time: real 19.622 secs (user 0.312+0.000 sys 2.044+0.000)
> time: real 19.138 secs (user 0.250+0.000 sys 1.872+0.000)
>
You could add the hash or a tag instead of "default". (Minor detail. You 
did this in a follow up mail.) Did you mention it is the mercurial 
source repo?

> (Without this patch: hg update from default to null)
> 0 files updated, 0 files merged, 127 files removed, 0 files unresolved
> time: real 35.158 secs (user 0.156+0.000 sys 2.512+0.000)
> time: real 35.272 secs (user 0.250+0.000 sys 2.512+0.000)
> time: real 36.569 secs (user 0.203+0.000 sys 2.387+0.000)
>
> (With this patch: hg update from null to default)
> 127 files updated, 0 files merged, 0 files removed, 0 files unresolved
> time: real 17.893 secs (user 0.328+0.000 sys 1.700+0.000)
> time: real 18.512 secs (user 0.265+0.000 sys 1.529+0.000)
> time: real 20.238 secs (user 0.312+0.000 sys 1.685+0.000)
>
> (With this patch: hg update from default to null)
> 0 files updated, 0 files merged, 127 files removed, 0 files unresolved
> time: real 12.312 secs (user 0.250+0.000 sys 0.811+0.000)
> time: real 12.471 secs (user 0.156+0.000 sys 0.889+0.000)
> time: real 9.727 secs (user 0.125+0.000 sys 0.858+0.000)
>
> diff -r 0e2877f8605d -r 95a976e04589 mercurial/win32.py
> --- a/mercurial/win32.py
> +++ b/mercurial/win32.py

running in a mercurial source repo
$ time hg up -r $REV

with this patch
$ hg up -r 0e2877f8605d
1038 files updated, 0 files merged, 0 files removed, 0 files unresolved

real	0m5.946s user	0m0.000s sys	0m0.015s	#high load?
real	0m6.246s user	0m0.000s sys	0m0.015s	#high load?
real	0m3.198s user	0m0.015s sys	0m0.000s
real	0m2.387s user	0m0.000s sys	0m0.030s

$ hg up -r null
0 files updated, 0 files merged, 1038 files removed, 0 files unresolved

real	0m1.033s user	0m0.016s sys	0m0.031s
real	0m1.006s user	0m0.015s sys	0m0.015s
real	0m2.102s user	0m0.000s sys	0m0.030s
real	0m0.850s user	0m0.030s sys	0m0.015s


without this patch
$ hg up -r 0e2877f8605d
1038 files updated, 0 files merged, 0 files removed, 0 files unresolved

real	0m3.222s user	0m0.000s sys	0m0.046s
real	0m2.475s user	0m0.030s sys	0m0.000s
real	0m4.500s user	0m0.000s sys	0m0.030s
real	0m2.709s user	0m0.000s sys	0m0.030s
         (was 32s once!)

$ hg up -r null
0 files updated, 0 files merged, 1038 files removed, 0 files unresolved

real	0m6.435s user	0m0.000s sys	0m0.015s
real	0m2.565s user	0m0.000s sys	0m0.015s
real	0m2.400s user	0m0.000s sys	0m0.030s
real	0m2.559s user	0m0.000s sys	0m0.030s



More information about the Mercurial-devel mailing list