Patchwork D9503: copies: avoid materializing a full directory map during copy tracing

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2020, 7:43 p.m.
Message ID <differential-rev-PHID-DREV-p3yttre7utuweyxu5k7v-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47785/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2020, 7:43 p.m.
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Materializing a full copy of every directory in a treemanifest repo can be quite
  expensive, even with a narrow matcher. For flat manifest repos, this should be
  equivalent - it will still materialize (and cache) a dict of all of the dirs
  inside of the manifest object, we just don't get a copy of it.
  
  In a repo I have here, this brings the time for a simple rebase from 11.197s to
  4.609s.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9503

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -929,8 +929,6 @@ 
               merge.manifestmerge() won't care about
     addedfiles: added files on the other side (compared to ctx)
     """
-    # generate a directory move map
-    d = ctx.dirs()
     invalid = set()
     dirmove = {}
 
@@ -941,7 +939,7 @@ 
         if dsrc in invalid:
             # already seen to be uninteresting
             continue
-        elif dsrc in d and ddst in d:
+        elif ctx.hasdir(dsrc) and ctx.hasdir(ddst):
             # directory wasn't entirely moved locally
             invalid.add(dsrc)
         elif dsrc in dirmove and dirmove[dsrc] != ddst:
@@ -954,7 +952,7 @@ 
     for i in invalid:
         if i in dirmove:
             del dirmove[i]
-    del d, invalid
+    del invalid
 
     if not dirmove:
         return {}, {}