[PATCH] refs: write packed_refs file using stdio

2014-09-10 Thread Jeff King
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

Re: [PATCH] refs: write packed_refs file using stdio

2014-09-10 Thread Michael Haggerty
On 09/10/2014 12:03 PM, Jeff King wrote: 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

Re: [PATCH] refs: write packed_refs file using stdio

2014-09-10 Thread Jeff King
On Wed, Sep 10, 2014 at 01:21:27PM +0200, Michael Haggerty wrote: + if (fclose(out)) + die_errno(write error); + packed_ref_cache-lock-fd = -1; It might be a minuscule bit safer to set `lock-fd = -1` *before* calling `fclose()`. Yeah, I considered that. The worst case is

Re: [PATCH] refs: write packed_refs file using stdio

2014-09-10 Thread Jeff King
On Wed, Sep 10, 2014 at 07:32:17AM -0700, Ronnie Sahlberg wrote: Even better could be to build an iovec for all the data and use writev() ? (now without gmail adding formatting) I'm not sure that would make anything easier. We're literally sprintf-ing (and calling sha1_to_hex) into a buffer so