Re: [PATCH] odb: do not use "blank" substitute for NULL
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 18, 2025, 06:31 UTC
- Message-ID
- <aUOfxNGdkJe8ARM1@pks.im>
- In-Reply-To
- <xmqqpl8cxy0j.fsf@gitster.g>
On Thu, Dec 18, 2025 at 12:35:40PM +0900, Junio C Hamano wrote:
Show 21 quoted lines
> When various *object_info() functions are given an extended object > info structure as NULL by a caller that does not want any details, > the code uses a file-scope static blank_oi to pass it down to the > helper functions they use, to avoid handling NULL specifically. > > The ps/object-read-stream topic graduated to 'master' recently > however had a bug that assumed that two identically named file-scope > static variables in two functions are the same, which of course is > not the case. This made "git commit" take 0.38 seconds to 1508 > seconds in some case, as reported by Aaron Plattner here: > > https://lore.kernel.org/git/f4ba7e89-4717-4b36-921f-56537131fd69@nvidia.com/ > > We _could_ move the blank_oi variable to a global scope in BSS to > fix this regression, but explicitly handling the NULL is a much > safer fix. It would also reduce the chance of errors that somebody > accidentally writes into blank_oi, making its contents dirty, which > potentially will make subsequent calls into the callpath misbehave. > > By explicitly handling NULL input, we no longer have to worry about > it.
Thanks for handling this, Junio!
I've sent out an alternative fix via a patch series that I already had cooking locally in [1]. It also goes a bit further than your series as it also recognizes the case where the caller passes a blank object info again.
That series also contains some other fixes related to reading object info where we had been inconsistent with returned results, and another performance improvement where we can skip unpacking packed objects.
I'm happy to go either route though -- I can hold off my series for a bit longer and rebase it on top of your fix, or we replace your fix with my series. Just let me know your preference.
Thanks!
Patrick
[1]: <20251218-b4-pks-odb-read-object-info-improvements-v1-7-81c8368492be@pks.im>