summaryrefslogtreecommitdiff
path: root/csum-file.h
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-05-18 18:32:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-19 07:41:21 (GMT)
commit2ca245f8be56e3269d02076b658e825b91236e5d (patch)
treeef5896f7799d8049983f21703c40cf5ecec83c0e /csum-file.h
parent68142e117c080b7a563d681dc34c7df2ab945df5 (diff)
downloadgit-2ca245f8be56e3269d02076b658e825b91236e5d.zip
git-2ca245f8be56e3269d02076b658e825b91236e5d.tar.gz
git-2ca245f8be56e3269d02076b658e825b91236e5d.tar.bz2
csum-file.h: increase hashfile buffer size
The hashfile API uses a hard-coded buffer size of 8KB and has ever since it was introduced in c38138c (git-pack-objects: write the pack files with a SHA1 csum, 2005-06-26). It performs a similar function to the hashing buffers in read-cache.c, but that code was updated from 8KB to 128KB in f279894 (read-cache: make the index write buffer size 128K, 2021-02-18). The justification there was that do_write_index() improves from 1.02s to 0.72s. Since our end goal is to have the index writing code use the hashfile API, we need to unify this buffer size to avoid a performance regression. There is a buffer, 'check_buffer', that is used to verify the check_fd file descriptor. When this buffer increases to 128K to fit the data being flushed, it causes the stack to overflow the limits placed in the test suite. To avoid issues with stack size, move both 'buffer' and 'check_buffer' to be heap pointers within 'struct hashfile'. The 'check_buffer' member is left as NULL unless check_fd is set in hashfd_check(). Both buffers are cleared as part of finalize_hashfile() which also frees the full structure. Since these buffers are now on the heap, we can adjust their size based on the needs of the consumer. In particular, callers to hashfd_throughput() are expecting to report progress indicators as the buffer flushes. These callers would prefer the smaller 8k buffer to avoid large delays between updates, especially for users with slower networks. When the progress indicator is not used, the larger buffer is preferrable. By adding a new trace2 region in the chunk-format API, we can see that the writing portion of 'git multi-pack-index write' lowers from ~1.49s to ~1.47s on a Linux machine. These effects may be more pronounced or diminished on other filesystems. The end-to-end timing is too noisy to have a definitive change either way. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.h')
-rw-r--r--csum-file.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/csum-file.h b/csum-file.h
index e54d53d..3044bd1 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -16,7 +16,9 @@ struct hashfile {
const char *name;
int do_crc;
uint32_t crc32;
- unsigned char buffer[8192];
+ size_t buffer_len;
+ unsigned char *buffer;
+ unsigned char *check_buffer;
};
/* Checkpoint */