Bug 1340 - hg log has poor performance when operating on new or untracked files
Summary: hg log has poor performance when operating on new or untracked files
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal feature
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-14 00:42 UTC by Jeremy Fitzhardinge
Modified: 2012-10-19 14:24 UTC (History)
7 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Fitzhardinge 2008-10-14 00:41 UTC
When doing an operation on an untracked file, the performance is slow.

For example, in my linux kernel tree:
: abulafia:pts/9; hg  --time log foo
Time: real 19.270 secs (user 18.490+0.000 sys 0.440+0.000)

This causes poor performance in mercurial.el when adding new files, because it
does an hg log -l1 newfile.
Comment 1 Benoit Boissinot 2008-10-14 00:53 UTC
The cause is this code snipped in cmdutil.py:
                if node is None:
                    # A zero count may be a directory or deleted file, so
                    # try to find matching entries on the slow path.
                    slowpath = True
                    break

And actually it's wrong, since it could be a directory even when there's a
filelog. A possible fix might be to check the pattern against the store (I don't
think we have the API for that).
Comment 2 Benoit Boissinot 2008-10-18 05:03 UTC
Another issue if that --limit 1, doesn't break at the first match in the slow
path...
Comment 3 Matt Mackall 2008-10-18 12:04 UTC
Fixing this will also take care of issue1302
Comment 4 Matt Mackall 2008-10-18 12:14 UTC
We might add some smarts to our new store logic to ask 'is this file/directory
in the history?' quickly.
Comment 5 Benoit Boissinot 2008-10-18 12:58 UTC
I think it would be very useful, and it could help for other things.
Comment 6 Dirkjan Ochtman 2008-11-02 08:05 UTC
I have the beginnings of a patch:

http://hg.xavamedia.nl/mercurial/djc.mq/file/434408c53ce8/store-contains

mpm has commented he wants directory support in there, and it doesn't support
fncache repos yet because it predates them.
Comment 7 Bugzilla 2012-05-12 08:54 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 08:54 EDT  ---

This bug was previously known as _bug_ 1340 at http://mercurial.selenic.com/bts/issue1340
Comment 8 Bryan O'Sullivan 2012-08-14 16:28 UTC
The localrepo.file method is now present to do the right thing for files. There's no corresponding API for directories yet, but that shouldn't be hard to add.
Comment 9 HG Bot 2012-10-10 21:12 UTC
Fixed by http://selenic.com/repo/hg/rev/6d218e47cf9b
smuralid
log: speed up hg log for untracked files (issue1340)

'hg log' on untracked files tends to be fairly slow. The root cause is that we end up using the 'slowpath' when we can't find a revlog for the files listed. This could happen if the file in question is an untracked file, or it is a directory.
This diff tries to speed up 'hg log' (by avoiding the slowpath) for files if we can determine if that file is not (and was never) a directory. We use the previously added store.__contains__ methods to test if the directory exists (or existed) in the store.
To avoid changing any existing semantics, this 'optimization' kicks in only when none of the files listed as arguments to the hg log command exist in the store.

(please test the fix)