Skip to content

Commit 764d09c

Browse files
committed
Merge branch 'ps/upload-pack-buffer-more-writes' into seen
Reduce system overhead "git upload-pack" spends relaying "git pack-objects" output to the "git fetch" running on the other end of the connection. * ps/upload-pack-buffer-more-writes: upload-pack: reduce lock contention when writing packfile data upload-pack: fix debug statement when flushing packfile data
2 parents 9f429eb + 9e35f29 commit 764d09c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

upload-pack.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ static int relay_pack_data(int pack_objects_out, struct output_state *os,
270270
}
271271
}
272272

273+
/*
274+
* Make sure that we buffer some data before sending it to the client.
275+
* This significantly reduces the number of write(3p) syscalls.
276+
*/
277+
if (readsz && os->used < (LARGE_PACKET_DATA_MAX * 2 / 3))
278+
return readsz;
279+
273280
if (os->used > 1) {
274281
send_client_data(1, os->buffer, os->used - 1, use_sideband);
275282
os->buffer[0] = os->buffer[os->used - 1];
@@ -457,11 +464,9 @@ static void create_pack_file(struct upload_pack_data *pack_data,
457464
}
458465

459466
/* flush the data */
460-
if (output_state->used > 0) {
467+
if (output_state->used > 0)
461468
send_client_data(1, output_state->buffer, output_state->used,
462469
pack_data->use_sideband);
463-
fprintf(stderr, "flushed.\n");
464-
}
465470
free(output_state);
466471
if (pack_data->use_sideband)
467472
packet_flush(1);

0 commit comments

Comments
 (0)