Patchwork [2,of,2] checkunknown: audit path before checking if it's a file or link

login
register
mail settings
Submitter Durham Goode
Date Feb. 12, 2016, 1:24 a.m.
Message ID <7095c706e37d8fc748b6.1455240255@dev8486.prn1.facebook.com>
Download mbox | patch
Permalink /patch/13123/
State Accepted
Headers show

Comments

Durham Goode - Feb. 12, 2016, 1:24 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1455240190 28800
#      Thu Feb 11 17:23:10 2016 -0800
# Node ID 7095c706e37d8fc748b6867f356fea4a11bedfe7
# Parent  127e46787efbcec30834c7334ed1d4f509da9c3a
checkunknown: audit path before checking if it's a file or link

Previously we would lstat the file to see if it was a file or a link before
attempting to process it. If the file happened to exist across a symlink, and if
that symlink was pointing to a network file system, that check could be very
expensive.

The new logic audit's the path to avoid symlinks before performing the lstat on
the file itself.

In our situation, this shaved 10 minutes off of certain hg updates.
300 files * (2 seconds - the network filesystem lookup time)
Pierre-Yves David - Feb. 12, 2016, 3:11 p.m.
On 02/12/2016 01:24 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1455240190 28800
> #      Thu Feb 11 17:23:10 2016 -0800
> # Node ID 7095c706e37d8fc748b6867f356fea4a11bedfe7
> # Parent  127e46787efbcec30834c7334ed1d4f509da9c3a
> checkunknown: audit path before checking if it's a file or link

pretty nice catch, pushed to the clowcopter.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -598,8 +598,8 @@  def _getcheckunknownconfig(repo, section
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None:
         f2 = f
-    return (repo.wvfs.isfileorlink(f)
-        and repo.wvfs.audit.check(f)
+    return (repo.wvfs.audit.check(f)
+        and repo.wvfs.isfileorlink(f)
         and repo.dirstate.normalize(f) not in repo.dirstate
         and mctx[f2].cmp(wctx[f]))