This is an archive of the discontinued Mercurial Phabricator instance.

scmutil: speed up relativization of paths when it's a no-op
ClosedPublic

Authored by valentin.gatienbaron on May 26 2020, 7:19 AM.

Details

Summary

ie when calling hg from the root of a repository. This is a common
thing to do in tools, so worth optimizing. Running hg files > /tmp/a
from the root of mozilla-central on linux:

before:
real 0m1,510s
user 0m1,387s
sys 0m0,090s

after:
real 0m1,266s
user 0m1,165s
sys 0m0,073s

(there are 280k paths, so relativization was costing ~1us per path
somehow)

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

I find the comment confusing. Maybe something like Relative paths below the top-level of the repository need more processing.?

What's confusing about it? For me, the emphasis is that the slow branch defines the expected behavior, and the other branch is merely an optimization of it.

marmoute accepted this revision.May 26 2020, 10:01 AM
marmoute added a subscriber: marmoute.

I don't find the comment confusing, (but I am not agains clarification if @joerg.sonnenberger and @valentin.gatienbaron reach a consensus.

At the very least, there is missing a word like "also" or "still", but it doesn't really tell the *why*. That's what would make a comment here useful, IMO. I.e. the important point is that a repo path is a relative path from the repo root, so if the cwd is empty, no additional work is necessary.

durin42 accepted this revision.May 26 2020, 12:16 PM
durin42 added a subscriber: durin42.

I can see some room for improvement in the log message, but it's good enough IMO and I can't really figure out a better wording.

This revision is now accepted and ready to land.May 26 2020, 12:16 PM

I reworded the description/comment slightly while Augie accepted the revision, in case people care enough to want the modified commit queued.

Yes, that version is better.