• Jeff King's avatar
    refs: write packed_refs file using stdio · 9540ce50
    Jeff King authored
    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: default avatarJeff King <peff@peff.net>
    Reviewed-by: default avatarMichael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
write_or_die.c 2.12 KB