Skip to content

Commit ab5a3e5

Browse files
committed
pack-objects: use 64-bit name hash
This change takes the "uniform" full-name hash and the "locality-preserving" name hash and combines them into a single 64-bit name hash. This increases the memory load of the packing process (by four bytes per object). By sorting by name-hash and then full-name-hash, this should put objects with same name-hash close, but broken down within that via the full-name-hash. However, this is not demonstrating significant differences in the size of the pack-files. Test HEAD~1 HEAD ------------------------------------------------------------------------------------------------ 5313.2: thin pack 0.08(0.06+0.01) 0.08(0.06+0.01) +0.0% 5313.3: thin pack size 852.7K 852.7K +0.0% 5313.4: thin pack with --full-name-hash 0.03(0.01+0.01) 0.03(0.01+0.01) +0.0% 5313.5: thin pack size with --full-name-hash 401.9K 401.9K +0.0% 5313.6: big pack 1.02(1.87+0.14) 1.11(1.91+0.20) +8.8% 5313.7: big pack size 58.5M 58.5M -0.0% 5313.8: big pack with --full-name-hash 0.91(1.46+0.12) 1.00(1.52+0.16) +9.9% 5313.9: big pack size with --full-name-hash 58.0M 58.0M +0.0% 5313.10: repack 104.65(391.84+12.31) 105.51(383.09+14.05) +0.8% 5313.11: repack size 438.6M 438.4M -0.1% 5313.12: repack with --full-name-hash 22.71(74.94+6.08) 22.91(74.73+6.16) +0.9% 5313.13: repack size with --full-name-hash 167.6M 168.3M +0.4% Signed-off-by: Derrick Stolee <[email protected]>
1 parent 0ec4b66 commit ab5a3e5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

builtin/pack-objects.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ static struct oidmap configured_exclusions;
268268
static struct oidset excluded_by_config;
269269
static int use_full_name_hash;
270270

271-
static inline uint32_t pack_name_hash_fn(const char *name)
271+
static inline uint64_t pack_name_hash_fn(const char *name)
272272
{
273273
if (use_full_name_hash)
274-
return pack_full_name_hash(name);
274+
/* Use name-hash as most-significant bits. */
275+
return (((uint64_t)pack_name_hash(name)) << 32) |
276+
(uint64_t) pack_full_name_hash(name);
277+
275278
return pack_name_hash(name);
276279
}
277280

pack-objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct object_entry {
8888
struct pack_idx_entry idx;
8989
void *delta_data; /* cached delta (uncompressed) */
9090
off_t in_pack_offset;
91-
uint32_t hash; /* name hint hash */
91+
uint64_t hash; /* name hint hash */
9292
unsigned size_:OE_SIZE_BITS;
9393
unsigned size_valid:1;
9494
uint32_t delta_idx; /* delta base object */

0 commit comments

Comments
 (0)