Issue1955

Title hg qrefresh should not traverse the entire working directory when given explicit paths
Priority bug Status resolved
Superseder Nosy List djc, mg, mpm, nicdumz, pmezard, timeless, tonfa
Assigned To Topics mq

Created on 2009-12-16.20:36:13 by timeless, last changed 2012-01-31.22:27:01 by mpm.

Messages
msg18824 (view) Author: mpm Date: 2012-01-31.22:27:01
Presumed fixed by recent copies refactoring
msg11363 (view) Author: pmezard Date: 2010-01-03.12:33:18
Stumbled on issue1967 while digging in copies.copies(). Suggested
optimizations depend on what we intend to do in that case.
msg11336 (view) Author: pmezard Date: 2009-12-31.15:53:53
Actually no, that would speed up diff --git --rev, copies.copies() already
has a fast path for working directory and first parent.
msg11335 (view) Author: pmezard Date: 2009-12-31.15:51:00
Even with --short a repository wide status() is done in patch.diff() to
detect copies when using --git patches.

If the diff (ie patch being refreshed + local changes) references only
updated files and not added or removed, we could avoid the copy detection
completely. I am not fond of this solution because it's partial and would
trigger hard to understand slowdowns.

We might make copies.copies() take a matcher object, at least in linear
cases. That would speed up diff --git for large repositories at least with
explicit file lists, and probably in all cases.
msg11266 (view) Author: timeless Date: 2009-12-17.00:42:32
timeless-mbp-2:mozilla-central timeless$ hg --profile qref --short -e
js/src/xpconnect/idl/nsIJSContextStack.idl
xpfe/appshell/public/nsIAppShellService.idl
xpfe/appshell/src/nsAppShellService.cpp
   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
           3            0     89.4304     89.3227   mercurial.dirstate:425(walk)
      +41806            0      0.0123      0.0123  
+mercurial.match:74(<lambda>)
      +44777            0      0.0102      0.0102  
+mercurial.dirstate:474(<lambda>)
       +4157            0      0.0680      0.0058  
+mercurial.match:79(__call__)
       +2971            0      0.0058      0.0058  
+mercurial.dirstate:122(_join)
       +2964            0      0.0036      0.0036   +<method 'pop' of 'list'
objects>
        2747            0      4.1411      4.1411   <posix.lstat>
         282            0      3.8042      3.8042   <posix.stat>
         459            0      2.5298      2.5298   <method 'read' of 'file'
objects>
           1            0      1.6088      1.6088   <posix.waitpid>
       11782            0      1.3649      1.3649   <zlib.decompress>
         141           65      0.4257      0.4172   <__import__>
          +1            0      0.0024      0.0003   +hashlib:52(<module>)
          +1            0      0.0039      0.0002   +mercurial.patch:9(<module>)
          +1            0      0.0006      0.0002  
+mercurial.context:8(<module>)
          +1            0      0.0065      0.0002  
+mercurial.revlog:12(<module>)
          +1            0      0.0017      0.0001   +random:39(<module>)
           4            0      0.3360      0.3360   <posix.symlink>
           5            0      0.2546      0.2546  
<mercurial.parsers.parse_manifest>
         129            0      0.2625      0.2406  
mercurial.revlog:164(loadblock)
        +129            0      0.0207      0.0207   +<method 'read' of
'file' objects>
        +129            0      0.0011      0.0011   +<method 'seek' of
'file' objects>
        +258            0      0.0001      0.0001   +<len>
          +8            0      0.0000      0.0000   +<max>
timeless-mbp-2:mozilla-central timeless$ hg --profile qref -e
js/src/xpconnect/idl/nsIJSContextStack.idl
xpfe/appshell/public/nsIAppShellService.idl
xpfe/appshell/src/nsAppShellService.cpp
   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
       43357            0     62.8692     62.8692   <posix.lstat>
           3            0    100.3195     40.9557   mercurial.dirstate:425(walk)
          +2            0     59.0724      0.1631   +<zip>
          +5            0      0.0465      0.0465   +<sorted>
      +43581            0      0.0308      0.0308  
+mercurial.dirstate:122(_join)
      +82418            0      0.0210      0.0210  
+mercurial.match:74(<lambda>)
      +44775            0      0.0119      0.0119  
+mercurial.dirstate:474(<lambda>)
         459            0      5.6153      5.6153   <method 'read' of 'file'
objects>
         282            0      2.4765      2.4765   <posix.stat>
         141           65      1.6750      1.6650   <__import__>
          +1            0      0.2211      0.0004   +hashlib:52(<module>)
          +1            0      0.0007      0.0003  
+mercurial.context:8(<module>)
          +1            0      0.0040      0.0003   +mercurial.patch:9(<module>)
          +1            0      0.3805      0.0002  
+mercurial.revlog:12(<module>)
          +1            0      0.0061      0.0002   +random:39(<module>)
           1            0      1.5505      1.5505   <posix.waitpid>
       11782            0      1.2381      1.2381   <zlib.decompress>
         146            0      0.4902      0.4902   <method 'seek' of 'file'
objects>
           9            0      0.4038      0.4038   <posix.unlink>
         129            0      0.9399      0.2754  
mercurial.revlog:164(loadblock)
        +129            0      0.5796      0.5796   +<method 'read' of
'file' objects>
        +129            0      0.0846      0.0846   +<method 'seek' of
'file' objects>
        +258            0      0.0002      0.0002   +<len>
          +8            0      0.0000      0.0000   +<max>

so, yeah, --short gets rid of 40,610 lstat's and roughly a minute of time.
But it doesn't actually help enough.
msg11264 (view) Author: mg Date: 2009-12-16.21:57:28
The --short option should do what you want. I cannot immediately come up
with a reason for why this option is not the default when you mention files
on the qrefresh command line.
msg11263 (view) Author: timeless Date: 2009-12-16.20:36:13
timeless-mbp-2:mozilla-central timeless$ hg --profile qref -e
xpcom/base/nsTraceRefcntImpl.cpp 
   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
       43337            0     39.9530     39.9530   <posix.lstat>
           3            0     58.9544     20.1982   mercurial.dirstate:425(walk)
          +2            0     38.5489      0.1598   +<zip>
          +5            0      0.0465      0.0465   +<sorted>
      +43579            0      0.0311      0.0311  
+mercurial.dirstate:122(_join)
      +82418            0      0.0187      0.0187  
+mercurial.match:74(<lambda>)
      +44773            0      0.0114      0.0114  
+mercurial.dirstate:474(<lambda>)
           1            0      2.9634      2.9634   <posix.waitpid>
         270            0      1.6362      1.6362   <posix.stat>
       11802            0      1.1576      1.1576   <zlib.decompress>
         141           65      0.7360      0.7267   <__import__>
          +1            0      0.1513      0.0004   +hashlib:52(<module>)
          +1            0      0.0045      0.0002   +mercurial.patch:9(<module>)
          +1            0      0.2412      0.0002  
+mercurial.revlog:12(<module>)
          +1            0      0.0005      0.0002  
+mercurial.context:8(<module>)
          +1            0      0.0219      0.0002   +random:39(<module>)
      234591            0      0.6781      0.2609  
mercurial.revlog:269(__getitem__)
     +234591            0      0.3072      0.1849   +struct:77(unpack)
         +46            0      0.1099      0.0002   +mercurial.revlog:264(load)
           3            0     59.2859      0.2576  
mercurial.dirstate:568(status)
          +3            0     58.9544     20.1982  
+mercurial.dirstate:425(walk)
       +1173            0      0.0006      0.0006   +mercurial.match:93(exact)
       +1176            0      0.0002      0.0002   +<method 'append' of
'list' objects>
          +1            0      0.0731      0.0000   +mercurial.util:149(__get__)
          +3            0      0.0000      0.0000   +<method 'iteritems' of
'dict' objects>
         129            0      0.2470      0.2284  
mercurial.revlog:164(loadblock)
        +129            0      0.0176      0.0176   +<method 'read' of
'file' objects>
        +129            0      0.0009      0.0009   +<method 'seek' of
'file' objects>
        +258            0      0.0001      0.0001   +<len>
          +8            0      0.0000      0.0000   +<max>
           5            0      0.2078      0.2078  
<mercurial.parsers.parse_manifest>
timeless-mbp-2:mozilla-central timeless$ cat .hg/hgrc 
[paths]
default = https://hg.mozilla.org/mozilla-central

this is hg clone -r ea06f16ef9e7 https://hg.mozilla.org/mozilla-central + 2
mq patches (qbase, qtip)

personally, as a user, i expect that telling qrefresh precisely which files
or directories are interesting should result in the following behavior:

visit only:
all files currently listed in `hg qtop`
all files and directories explicitly provided as arguments

it should not look at any other files or directories in the working
directory (it is free to look at whichever files in the .hg/ tree it needs
to in order to get its job done).
History
Date User Action Args
2012-01-31 22:27:01mpmsetstatus: chatting -> resolved
nosy: + mpm
messages: + msg18824
2010-01-03 15:18:48tonfasetnosy: + tonfa
2010-01-03 12:33:18pmezardsetnosy: pmezard, mg, djc, timeless, nicdumz
messages: + msg11363
2009-12-31 15:53:53pmezardsetnosy: pmezard, mg, djc, timeless, nicdumz
messages: + msg11336
2009-12-31 15:51:00pmezardsetnosy: pmezard, mg, djc, timeless, nicdumz
messages: + msg11335
2009-12-29 10:51:52pmezardsetnosy: + pmezard
2009-12-17 09:12:58djcsetnosy: + djc
2009-12-17 00:42:33timelesssetmessages: + msg11266
2009-12-17 00:05:10nicdumzsetnosy: + nicdumz
2009-12-16 21:57:29mgsetstatus: unread -> chatting
messages: + msg11264
2009-12-16 21:54:11mgsetnosy: + mg
2009-12-16 20:36:13timelesscreate