diff --git a/upload-pack.c b/upload-pack.c index c2643c0295..f8ba245616 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -270,6 +270,13 @@ static int relay_pack_data(int pack_objects_out, struct output_state *os, } } + /* + * Make sure that we buffer some data before sending it to the client. + * This significantly reduces the number of write(3p) syscalls. + */ + if (readsz && os->used < (LARGE_PACKET_DATA_MAX * 2 / 3)) + return readsz; + if (os->used > 1) { send_client_data(1, os->buffer, os->used - 1, use_sideband); os->buffer[0] = os->buffer[os->used - 1];