]> git.ipfire.org Git - thirdparty/git.git/commit - cache.h
refs: write packed_refs file using stdio
authorJeff King <peff@peff.net>
Wed, 10 Sep 2014 10:03:52 +0000 (06:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Sep 2014 17:58:32 +0000 (10:58 -0700)
commit9540ce5030853ffbb7e11c30aa59a5e45095d32c
treedaaa9507ddd96312a5c41708d3554ccf5cf0169b
parent0c72b98f31bf6eabd75be565a08ffcf0d8e74b1f
refs: write packed_refs file using stdio

We write each line of a new packed-refs file individually
using a write() syscall (and sometimes 2, if the ref is
peeled). Since each line is only about 50-100 bytes long,
this creates a lot of system call overhead.

We can instead open a stdio handle around our descriptor and
use fprintf to write to it. The extra buffering is not a
problem for us, because nobody will read our new packed-refs
file until we call commit_lock_file (by which point we have
flushed everything).

On a pathological repository with 8.5 million refs, this
dropped the time to run `git pack-refs` from 20s to 6s.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
refs.c
write_or_die.c