]> git.ipfire.org Git - thirdparty/git.git/commit
index-pack, unpack-objects: increase input buffer from 4 KiB to 128 KiB
authorScott Bauersfeld <sbauersfeld@g.ucla.edu>
Tue, 28 Apr 2026 14:47:40 +0000 (14:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2026 12:44:03 +0000 (21:44 +0900)
commit007062ab4e01b8a1b1fe497610b8be4a57b76f4e
treeada7da8fd559d987a3af422cff783f2b17a75e73
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
index-pack, unpack-objects: increase input buffer from 4 KiB to 128 KiB

index-pack and unpack-objects both read pack data from stdin through
a 4 KiB static buffer. In index-pack, each fill() flushes consumed
bytes to the pack file via write_or_die(), capping every write(2)
at 4 KiB. unpack-objects uses the same buffer pattern for reads.

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. Introduce a shared
DEFAULT_IO_BUFFER_SIZE constant in git-compat-util.h (next to
MAX_IO_SIZE) and use it in index-pack, unpack-objects, and the
hashfile layer in csum-file (which already used 128 KiB but
hardcoded the value).

Pack file writes to a FUSE filesystem with writeback caching
disabled during HTTPS clones of git/git (~293 MB pack):

  74,958 -> 4,687 (94% fewer)

Wall-clock time of git clone over HTTPS onto a FUSE passthrough
filesystem with writeback caching disabled, 3 runs per variant:

  vscode (~1.26 GB pack): 84.5s -> 75.7s avg (10% faster)
  git/git (~306 MB pack):  22.6s -> 20.0s avg (11% faster)

Signed-off-by: Scott Bauersfeld <sbauersfeld@g.ucla.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
builtin/unpack-objects.c
csum-file.c
git-compat-util.h