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

Re: [PATCH] cat-file: speed up default format

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2026, 22:21 UTC
Message-ID
<xmqqo6ha15zv.fsf@gitster.g>
In-Reply-To
<47e3cf16-217e-45d4-91e2-5a1abb4ee49e@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 38 quoted lines
> On 6/16/26 1:12 PM, Jeff King wrote:
>> On Mon, Jun 15, 2026 at 11:53:07PM +0200, René Scharfe wrote:
>> 
>>> We can also store literal characters in there.  An opcode plus with a
>>> payload char incurs an overhead of 50%, which sounds high, but at least
>>> the default format only has two of them and it's much better than
>>> storing pointer plus size for an overhead of more than 90% in case of a
>>> single char.
>> 
>> True, and it's a size win if the literal portions tend to be small
>> (fewer than 15 bytes). You do lose out on the ability to strbuf_add()
>> them in one go, though. So lots more strbuf_grow() checks, etc. If you
>> really wanted to get fancy, you could follow the opcode with a length
>> represented as a variable-sized integer, followed by the literal bytes.
>
> Or an opcode that shovels a fixed-size string.  Depends on how much
> literal text people include in their formats.
>
>> I'm not sure that Git's formatting code needs to squeeze out quite that
>> much performance, though.
>
> Good point.  Near-native performance would be necessary to make peephole
> optimizations like the special handling of the default format
> unnecessary, which I understand exists to speed up Gitaly [1], but I
> guess most users don't have such high demands.  And there's no point in
> removing a few lines of duplicate code if the necessary machinery adds a
> lot of complexity.  Though the code discussed so far was not too crazy
> IMHO.
>
> [1] https://gitlab.com/gitlab-org/gitaly/-/blob/master/internal/git/gitpipe/catfile_info.go
>
>> OK, so we managed another 1%. But I'm skeptical that this linear opcode
>> technique is where we want to go in the long run, if we're ever going to
>> unify formatters.
>
> Agreed.
>
> René

Obviously I agree with the conclusion, but it was fun to watch cute experiments from the sidelines. Thanks for entertainment ;-)

Previous: René ScharfeNext: René Scharfe
Message 8 of 10 in “cat-file: speed up default format”
  1. cat-file: speed up default formatRené Scharfe, Jun 14, 2026
  2. Patrick SteinhardtJun 15, 2026
  3. Jeff KingJun 15, 2026
  4. Jeff KingJun 15, 2026
  5. René ScharfeJun 15, 2026
  6. Jeff KingJun 16, 2026
  7. René ScharfeJun 16, 2026
  8. Junio C HamanoJun 16, 2026
  9. René ScharfeJun 15, 2026
  10. Jeff KingJun 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.