Skip to content

Commit

Permalink
cat: remove single file optimization
Browse files Browse the repository at this point in the history
Summary:
With the advent of the tree manifest, I don't think this optimization makes sense. Either way you only need to load the ancestor trees of the file path you are looking up.

This optimization was originally added in 46ead70cdff366faab1609bce666b8da77565e56 with this message:

    Special case the single file case in hg cat. This allows us to avoid
    parsing the manifest, which shaves 15% off hg cat perf. This is worth
    it, since automation often uses hg cat for retrieving single files.

"Parsing the manifest" refers to parsing the entire flat manifest to perform the walk operation, but walk is naturally optimized now via the tree manifest.

Reviewed By: MichaelCuevas

Differential Revision: D68860535

fbshipit-source-id: 5f477c332c24eb0b821313690536ab41de404a20
muirdm authored and facebook-github-bot committed Jan 31, 2025
1 parent d019406 commit a9e0bf5
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions eden/scm/sapling/cmdutil.py
Original file line number Diff line number Diff line change
@@ -3783,19 +3783,6 @@ def write(path):
fm.writebytes("data", b"%s", data)
fm.data(abspath=path, path=matcher.rel(path))

# Automation often uses hg cat on single files, so special case it
# for performance to avoid the cost of parsing the manifest.
if len(matcher.files()) == 1 and not matcher.anypats():
file = matcher.files()[0]
mfl = repo.manifestlog
mfnode = ctx.manifestnode()
try:
if mfnode and mfl[mfnode].find(file)[0]:
write(file)
return 0
except KeyError:
pass

for abs in ctx.walk(matcher):
write(abs)
err = 0

0 comments on commit a9e0bf5

Please sign in to comment.