Re: [PATCH v3 3/4] revision: avoid loading object headers multiple times
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 2, 2021, 19:40 UTC
- Message-ID
- <xmqq5ywnws6v.fsf@gitster.g>
- In-Reply-To
- <b9897e102afbcab3bfee58ed8bda24257d8b54fb.1627896460.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 14 quoted lines
> When loading references, we try to optimize loading of commits by using > the commit graph. To do so, we first need to determine whether the > object actually is a commit or not, which is why we always execute > `oid_object_info()` first. Like this, we'll unpack the object header of > each object first. > > This pattern can be quite inefficient in case many references point to > the same commit: if the object didn't end up in the cached objects, then > we'll repeatedly unpack the same object header, even if we've already > seen the object before. > ... > Assuming that in almost all repositories, most references will point to > either a tag or a commit, we'd have a modest increase in memory > consumption of about 12.5% here.
I wonder if we can also say almost all repositories, the majority of refs point at the same object. If that holds, this would certainly be a win, but otherwise, it is not so clear.