From: Junio C Hamano <gitster@pobox.com>
To: "Scott Bauersfeld via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Scott Bauersfeld <sbauersfeld@g.ucla.edu>
Subject: Re: [PATCH] index-pack, unpack-objects: increase input buffer from 4 KiB to 128 KiB
Date: Sat, 25 Apr 2026 19:21:05 +0900 [thread overview]
Message-ID: <xmqqldeb9w8e.fsf@gitster.g> (raw)
In-Reply-To: <pull.2282.git.git.1777058098756.gitgitgadget@gmail.com> (Scott Bauersfeld via GitGitGadget's message of "Fri, 24 Apr 2026 19:14:58 +0000")
"Scott Bauersfeld via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Scott Bauersfeld <sbauersfeld@g.ucla.edu>
>
> Both index-pack and unpack-objects read pack data from stdin through
> a 4 KiB static buffer (input_buffer[4096]). On each fill(), consumed
> bytes are flushed to the output pack file via write_or_die(), so
> every write(2) moves at most 4 KiB.
Micronit. Output of unpack-objects obviously does not get flushed
to "the output pack file".
> On FUSE-backed filesystems every write(2) is a synchronous round
> trip through the FUSE protocol (userspace -> kernel -> userspace ->
> back), so the 4 KiB buffer turns a clone into many unnecessary tiny
> writes with noticeable latency overhead.
>
> Increase the buffer from 4 KiB to 128 KiB, matching the default
> already used by the hashfile layer in csum-file.c.
Quite sensible reasoning presented very nicely.
It may probably be a #leftoverbit but these three instances of (128
* 1024) may want to have a common symbolic constant, like
#define DEFAULT_IOBUFFER_SIZE_IN_BYTES (128 * 1024)
in a bit more central header file. Especially for the one in
csum-file.c where there is no symbolic constant used for that
purpose.
> Testing with strace on HTTPS clones of git/git (~296 MB pack, 5 runs
> per variant, isolated builds from the same v2.54.0 source) shows:
>
> index-pack pack file writes: 72,465 -> 24,943 avg (66% reduction)
> total write() syscalls: 310,192 -> 259,530 avg (17% reduction)
> writes of exactly 4096 bytes: ~40,077 -> 0 (eliminated)
Hmph, I would have expected more like (1 - 4/128) ~ 97% reduction.
The difference between that and 66% is coming from where? There are
inherently short writes that do not utilize the new larger buffer
beyond 4kB? If so, another number of interest might be the number
of writes smaller than 4096 bytes, perhaps?
next prev parent reply other threads:[~2026-04-25 10:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 19:14 [PATCH] index-pack, unpack-objects: increase input buffer from 4 KiB to 128 KiB Scott Bauersfeld via GitGitGadget
2026-04-25 10:21 ` Junio C Hamano [this message]
2026-04-27 12:36 ` Derrick Stolee
2026-04-28 1:46 ` Junio C Hamano
2026-04-28 2:09 ` Jeff King
2026-04-27 16:08 ` [PATCH v2] " Scott Bauersfeld via GitGitGadget
2026-04-27 17:23 ` Derrick Stolee
2026-04-27 19:26 ` [PATCH v3] " Scott Bauersfeld via GitGitGadget
2026-04-27 20:12 ` Derrick Stolee
2026-04-28 1:47 ` Junio C Hamano
2026-04-28 14:47 ` [PATCH v4] " Scott Bauersfeld via GitGitGadget
2026-05-12 5:51 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqldeb9w8e.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=sbauersfeld@g.ucla.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox