diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-24 12:31:34 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-24 12:31:34 -0700 |
| commit | 8023abc632ea45a9a1b7f78b13db2cf541849775 (patch) | |
| tree | b06aa8b5ec54b28bd580d80dbee0afe14b9149bc /builtin | |
| parent | 231f8100c41fdbdd49f5bca953fff775a79321db (diff) | |
| parent | 835e0aaf6f0e07e9f9a393ed0e456db7c1be33ef (diff) | |
| download | git-8023abc632ea45a9a1b7f78b13db2cf541849775.tar.xz | |
Merge branch 'ps/upload-pack-buffer-more-writes'
Reduce system overhead "git upload-pack" spends on relaying "git
pack-objects" output to the "git fetch" running on the other end of
the connection.
* ps/upload-pack-buffer-more-writes:
builtin/pack-objects: reduce lock contention when writing packfile data
csum-file: drop `hashfd_throughput()`
csum-file: introduce `hashfd_ext()`
sideband: use writev(3p) to send pktlines
wrapper: introduce writev(3p) wrappers
compat/posix: introduce writev(3p) wrapper
upload-pack: reduce lock contention when writing packfile data
upload-pack: prefer flushing data over sending keepalive
upload-pack: adapt keepalives based on buffering
upload-pack: fix debug statement when flushing packfile data
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/pack-objects.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index cd013c0b68..da1087930c 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -41,6 +41,7 @@ #include "promisor-remote.h" #include "pack-mtimes.h" #include "parse-options.h" +#include "pkt-line.h" #include "blob.h" #include "tree.h" #include "path-walk.h" @@ -1330,11 +1331,25 @@ static void write_pack_file(void) unsigned char hash[GIT_MAX_RAWSZ]; char *pack_tmp_name = NULL; - if (pack_to_stdout) - f = hashfd_throughput(the_repository->hash_algo, 1, - "<stdout>", progress_state); - else + if (pack_to_stdout) { + /* + * This command is most often invoked via + * git-upload-pack(1), which will typically chunk data + * into pktlines. As such, we use the maximum data + * length of them as buffer length. + * + * Note that we need to subtract one though to + * accomodate for the sideband byte. + */ + struct hashfd_options opts = { + .progress = progress_state, + .buffer_len = LARGE_PACKET_DATA_MAX - 1, + }; + f = hashfd_ext(the_repository->hash_algo, 1, + "<stdout>", &opts); + } else { f = create_tmp_packfile(the_repository, &pack_tmp_name); + } offset = write_pack_header(f, nr_remaining); |
