git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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>
Previous: Junio C HamanoNext: Aaron Plattner
Message 2 of 8 in “odb: do not use "blank" substitute for NULL”
  1. odb: do not use "blank" substitute for NULLJunio C Hamano, Dec 18, 2025
  2. Patrick SteinhardtDec 18, 2025
  3. Aaron PlattnerDec 18, 2025
  4. Kristoffer HaugsbakkDec 18, 2025
  5. Carlo Marcelo Arenas BelónDec 18, 2025
  6. Kristoffer HaugsbakkDec 19, 2025
  7. Junio C HamanoDec 19, 2025
  8. Patrick SteinhardtDec 18, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.