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

Re: [PATCH] http-backend: drop strbuf pre-sizing from get_info_packs()

From
YHYusuke Hayashi <yusuke8h@gmail.com>
Date
Nov 15, 2026, 09:58 UTC
Message-ID
<CAB59oQ_K=AdVk+xXVPkodP_tPfGWuLO0fqvBwJAz2tvBAxrb7g@mail.gmail.com>
In-Reply-To
<ava2WJkDag6-uthA@pks.im>
On Fri, Nov 13, 2026 at 08:03:52AM +0100, Patrick Steinhardt wrote:
Show 10 quoted lines
> So this explains that the behaviour is buggy, but that may lead the
> reader to wonder why we don't just fix the bug. And sure, we know to
> grow the buffer automatically, but the hint is intended as a performance
> improvement so that we know to allocate the buffer properly right from
> the start.
>
> Note that I'm not saying that this change doesn't make sense. But I
> think the argument that "others do it" is rather weak. The more
> important question to answer is why it's fine to skip it in this
> particular function.

Fair point -- pointing out the SHA-256 under-count and unchecked multiplication without explaining why we don't just fix the formula leaves the main question unanswered, and citing a9ce8526dc doesn't answer it for get_info_packs() either.

In this case, get_info_packs() is a one-shot CGI handler for dumb HTTP GET /objects/info/packs requests that formats a single response and exits. A typical repository only produces a few kilobytes of output, and even with thousands of packs strbuf's geometric growth only needs a couple dozen reallocations, which is negligible compared to CGI startup, scanning objects/pack to populate the pack list, and writing the HTTP response. Meanwhile, computing the hint up front requires an extra pass over the pack list.

I'll send a v2 with an updated commit message that explains this directly instead.

Thanks for the review!
Previous: Patrick SteinhardtNext: Yusuke Hayashi via B4 Relay
Message 3 of 6 in “http-backend: drop strbuf pre-sizing from get_info_packs()”
  1. http-backend: drop strbuf pre-sizing from get_info_packs()Yusuke Hayashi via B4 Relay, Nov 13, 2026
  2. Patrick SteinhardtNov 13, 2026
  3. Yusuke HayashiNov 15, 2026
  4. http-backend: drop strbuf pre-sizing from get_info_packs()Yusuke Hayashi via B4 Relay, Nov 15, 2026
  5. Patrick SteinhardtNov 16, 2026
  6. Junio C HamanoNov 16, 2026

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.