Re: [PATCH v2] fetch: limit shared symref check only for local branches
- From
Orgad Shaneh <orgads@gmail.com>
- Date
- May 17, 2022, 10:41 UTC
- Message-ID
- <CAGHpTBK_K+GK5z3XD-7ob7JPLrUnohfMCRVD2wrwbMhDyy3TEw@mail.gmail.com>
- In-Reply-To
- <xmqqtu9oxxmv.fsf@gitster.g>
On Tue, May 17, 2022 at 1:27 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> > Orgad Shaneh <orgads@gmail.com> writes: > > >> Another thing that is surprising is that you say this loop is > >> expensive when there are many tags or branches. Do you mean it is > >> expensive when there are many tags and branches that are updated, or > >> it is expensive to merely have thousands of dormant tags and > >> branches? If the latter, I wonder if it is sensible to limit the > >> check only to the refs that are going to be updated. > > > > It's expensive even when *nothing* is updated. I have a repo with 44K > > tags, 13K of the tags are annotated, 134 remote branches and 4 > > worktrees (except the main repo) with 33 local branches. > > > > I counted the calls to find_shared_symref - it was called 35755 times, > > and refs_read_raw_ref was called 357585 times. > > That is exactly why I asked, as the above number hints that it could > be a viable optimization to omit calls for refs whose old_ and > new_oid are the same, just like you omit calls for refs that are not > inside refs/heads/ in your patch, perhaps?
This would require shuffling the code. check_not_current_branch() is called by do_fetch before fetch_and_consume_refs (which updates ref->old_oid and ref->new_oid).
- Orgad