aboutsummaryrefslogtreecommitdiff
path: root/reftable/reftable-record.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-01-03 07:22:34 +0100
committerJunio C Hamano <gitster@pobox.com>2024-01-03 09:54:21 -0800
commitb31e3cc620f926273af9346fbda4ff507f60682e (patch)
tree080d5b42fa730d7546659a58d321c66d943c7791 /reftable/reftable-record.h
parent7af607c58d7985a0eb70fc3bca6eef8eb2381f14 (diff)
downloadgit-b31e3cc620f926273af9346fbda4ff507f60682e.tar.xz
reftable/record: store "val2" hashes as static arrays
Similar to the preceding commit, convert ref records of type "val2" to store their object IDs in static arrays instead of allocating them for every single record. We're using the same benchmark as in the preceding commit, with `git show-ref --quiet` in a repository with ~350k refs. This time around though the effects aren't this huge. Before: HEAP SUMMARY: in use at exit: 21,163 bytes in 193 blocks total heap usage: 1,419,040 allocs, 1,418,847 frees, 62,153,868 bytes allocated After: HEAP SUMMARY: in use at exit: 21,163 bytes in 193 blocks total heap usage: 1,410,148 allocs, 1,409,955 frees, 61,976,068 bytes allocated This is because "val2"-type records are typically only stored for peeled tags, and the number of annotated tags in the benchmark repository is rather low. Still, it can be seen that this change leads to a reduction of allocations overall, even if only a small one. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/reftable-record.h')
-rw-r--r--reftable/reftable-record.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/reftable/reftable-record.h b/reftable/reftable-record.h
index 7f3a0df635..bb6e99acd3 100644
--- a/reftable/reftable-record.h
+++ b/reftable/reftable-record.h
@@ -41,8 +41,8 @@ struct reftable_ref_record {
union {
unsigned char val1[GIT_MAX_RAWSZ];
struct {
- uint8_t *value; /* first value, malloced hash */
- uint8_t *target_value; /* second value, malloced hash */
+ unsigned char value[GIT_MAX_RAWSZ]; /* first hash */
+ unsigned char target_value[GIT_MAX_RAWSZ]; /* second hash */
} val2;
char *symref; /* referent, malloced 0-terminated string */
} value;