[PATCH] remotefilectx: use manifest.find() to look for a single file

Martin von Zweigbergk martinvonz at google.com
Tue Oct 11 19:13:21 EDT 2016


On Tue, Oct 11, 2016 at 3:37 PM, Durham Goode <durham at fb.com> wrote:
> Sorry for the delay in reviewing this. I am a terrible person.
>
>
> On 9/27/16 5:19 PM, Martin von Zweigbergk wrote:
>>
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz at google.com>
>> # Date 1475020863 25200
>> #      Tue Sep 27 17:01:03 2016 -0700
>> # Node ID 38faebcddb68e8425fd5fcc64b58b61002ce0eaa
>> # Parent  69eeafa68cd0e62916dab43e1c5bcdc62069e19d
>> remotefilectx: use manifest.find() to look for a single file
>>
>> The find() method on the manifest class (i.e. the revlog) is optimized
>> for both flat and treemanifests, so use that where we're only looking
>> for a single file.
>>
>> diff -r 69eeafa68cd0 -r 38faebcddb68 remotefilelog/remotefilectx.py
>> --- a/remotefilelog/remotefilectx.py    Tue Aug 30 10:18:24 2016 -0700
>> +++ b/remotefilelog/remotefilectx.py    Tue Sep 27 17:01:03 2016 -0700
>> @@ -68,7 +68,7 @@
>>               if path in data[3]: # checking the 'files' field.
>>                   # The file has been touched, check if the hash is what
>> we're
>>                   # looking for.
>> -                if fileid == ma.readfast(data[0]).get(path):
>> +                if fileid == ma.find(data[0], path)[0]:
>
> Even though find is optimized for finding the file quickly within the
> manifest, doesn't it require that we decompress the entire manifest first?
> That adds 500+ms to every invocation here (which is in a tight loop over the
> changelog).

Good point. Maybe I need to handle it differently for flat and tree,
because for tree manifests ma.find() calls slow_slowreaddelta()
(ironic, I know).


More information about the Mercurial-devel mailing list