Re: [PATCH v3] fetch-pack.c: use oidset to check existence of loose object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2018-03-10 3:00 GMT+09:00 Junio C Hamano <gitster@xxxxxxxxx>:
> Takuto Ikuta <tikuta@xxxxxxxxxxxx> writes:
>
>> Yes, I just wanted to say 'git fetch' invokes fetch-pack.
>> fetch-pack is skipped when running git fetch repeatedly while
>> remote has no update by quickfetch. So I disabled it to see the
>> performance of fetch-pack. In chromium repository, master branch
>> is updated several times in an hour, so git fetch invokes fetch-pack
>> in such frequency.
>
> I do understand that if you run "git fetch" against the same place
> in quick succession three times, the first one may cost a lot (not
> just that it has to do the everything_local() computation that you
> care about, it also has to actually do the network transfer), while
> the second and third ones that are done before anything new happens
> on the other end will not involve everything_local() overhead thanks
> to quickfetch.
>
> A "fetch" that is run against a remote that has nothing new, but
> still triggers everything_local() only because quickfetch is
> disabled, is an artificial case that has no relevance to the real
> world, I suspect, because the quickfetch optimization is to solve
> the "there is nothing to be done, still do_fetch_pack() spends so
> much cycles only to realize that it does not have anything to do,
> why?" issue.
>

I changed not to say "disabling quickfetch" in v5 description.
Actually, I'd like to take several stats on linux because the perf difference
is small and it can be affected by network and quickfetch.

> Isn't running the "git fetch" command with the "--dry-run" option
> many times in quick succession a lot closer to what you really want
> to measure, I wonder?  That way, your first fetch won't be touching
> the state of the local side to affect your second and subsequent
> fetches.
>

Looks no? Even when I use --dry-run, second run did not invoke fetch-pack.

>>> In any case, do_fetch_pack() tries to see if all of the tip commits
>>> we are going to fetch exist locally, so when you are trying a fetch
>>> that grabs huge number of refs (by the way, it means that the first
>>> sentence of the proposed log message is not quite true---it is "When
>>> fetching a large number of refs", as it does not matter how many
>>> refs _we_ have, no?), everything_local() ends up making repeated
>>> calls to has_object_file_with_flags() to all of the refs.
>>
>> I fixed description by changing 'refs' to 'remote refs'. In my understanding,
>> git tries to check existence of remote refs even if we won't fetch such refs.
>
> During fetch, everything_local() tries to mark common part by
> walking the refs the other side advertised upon the first contact,
> so it is correct that the number of checks is not reduced in a fetch
> that does not fetch many refs, but the number of remote-tracking refs
> you have has no effect, so I doubt such a rephrasing would make the
> description more understandable.  "When fetching from a repository
> with large number of refs" is probably what you want to say, no?
>

For refs existing in local repository, everything_local looks to be able to find
corresponding object from packed or loose objects. And if it exists,
I think, cost of lstat(2) is relatively smaller than other operations.
But for remote refs, everything_local fails to find it from packed
object (this check is fast)
and it tries to find loose object by using lstat(2), and this fails and slow.
My patch is to skip this lstat(2) to non-existing ref objects for repositories
having large number of remote refs.

2018-03-10 4:41 GMT+09:00 Junio C Hamano <gitster@xxxxxxxxx>:
> Junio C Hamano <gitster@xxxxxxxxx> writes:
>
>>> Yes. But I think the default limit for the number of loose objects, 7000,
>>> gives us small overhead when we do enumeration of all objects.
>>
>> Hmph, I didn't see the code that does the estimation of loose object
>> count before starting to enumerate, though.
>
> Another thing the code could do to avoid negative consequences on
> projects that look quite different from yours (e.g. the other side
> does not have insane number of refs, but there are locally quite a
> few loose objects) is to count how many entries are on *refs list
> before we decide to enumerate all loose objects.  When the refs list
> is relatively shorter than the estimated number of loose objects
> (you can actually do the estimation based on sampling, or just rely
> on your assumed 7k), it may be a win _not_ to trigger the new code
> you are adding to this codepath with this patch.  I would imagine
> that the simplest implementaion may just count
>
>         for (ref = *refs, count = 0; ref && count++ < LIMIT; ref = ref->next)
>                 ;
>         use_oidset_optim = (LIMIT <= count);
>
> assuming your "up to 7k loose objects" and then experimenting to
> determine the LIMIT which is a rough number of refs that makes the
> oidset optimization worthwhile.
>
> We need a bit better/descriptive name for the LIMIT, if we go that
> route, though.
>

Sorry, 7000 was wrong. I wanted to say the default number of gc.auto, 6700.
I changed to count refs in for_each_loose_object(), and use it to
determine whether
we use oidset or not.

2018-03-10 4:54 GMT+09:00 Junio C Hamano <gitster@xxxxxxxxx>:
> Takuto Ikuta <tikuta@xxxxxxxxxxxx> writes:
>
>> In repository having large number of remote refs, because to check
>
> Isn't this "When fetching from a repository with large number of
> refs,"?  The number of refs (whether it is local or remote-tracking)
> the local side has has nothing to do with the issue you are
> addressing, no?
>

Yes it has nothing to do with the issue. At least, my patch won't change
performance of git fetch for the repository having large number of local refs.

>> existence of each refs in local repository, 'git fetch' ends up doing a
>> lot of lstat(2) calls to see if it exists in loose form, which makes it
>> slow.
>
> Other than that, the above description reads much better and makes
> the result easier to understand.
>
>> This patch enumerates loose objects in hashmap beforehand and uses it to
>> check existence instead of using lstat(2) to improve performance of
>> fetch-pack for repositories having large number of remote refs compared
>> to the number of loose objects.
>
> We'd rather write this paragraph as if giving an order to the
> codebase "to be like so", e.g.
>
>         Instead of making as many lstat(2) calls as the refs the
>         remote side advertised to see if these objects exist in the
>         loose form, first enumerate all the existing loose objects
>         in hashmap beforehand and use it to check existence of
>         them...
>

Thanks, I changed description like it.

>> I took time stat of `git fetch` disabling quickfetch, so that fetch-pack
>
> I still do not know if a benchmark with quickfetch disabled gives
> relevant numbers, for reasons I gave earlier.  The relative numbers
> between Linux and MacBook look quite convincing, as they illustrate
> differences of lstat(2) performance on these platforms.
>
>>       for (ref = *refs; ref; ref = ref->next) {
>>               struct object *o;
>> +             unsigned int flags = OBJECT_INFO_QUICK;
>>
>> -             if (!has_object_file_with_flags(&ref->old_oid,
>> -                                             OBJECT_INFO_QUICK))
>> -                     continue;
>> +             if (!oidset_contains(&loose_oid_set, &ref->old_oid)) {
>> +                     /* I know this does not exist in the loose form,
>> +                      * so check if it exists in a non-loose form.
>> +                      */
>
>         /*
>          * Our multi-line comment looks like this,
>          * with opening slash-asterisk and closing
>          * asterisk-slash on their own lines.
>          */
>

I fixed.


Thanks, Takuto



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux