Merge branch 'ds/name-hash-tweaks'

"git pack-objects" and its wrapper "git repack" learned an option
to use an alternative path-hash function to improve delta-base
selection to produce a packfile with deeper history than window
size.

* ds/name-hash-tweaks:
  pack-objects: prevent name hash version change
  test-tool: add helper for name-hash values
  p5313: add size comparison test
  pack-objects: add GIT_TEST_NAME_HASH_VERSION
  repack: add --name-hash-version option
  pack-objects: add --name-hash-version option
  pack-objects: create new name-hash function version
This commit is contained in:
Junio C Hamano
2025-02-12 10:08:51 -08:00
22 changed files with 389 additions and 16 deletions

70
t/perf/p5313-pack-objects.sh Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
test_description='Tests pack performance using bitmaps'
. ./perf-lib.sh
GIT_TEST_PASSING_SANITIZE_LEAK=0
export GIT_TEST_PASSING_SANITIZE_LEAK
test_perf_large_repo
test_expect_success 'create rev input' '
cat >in-thin <<-EOF &&
$(git rev-parse HEAD)
^$(git rev-parse HEAD~1)
EOF
cat >in-big <<-EOF &&
$(git rev-parse HEAD)
^$(git rev-parse HEAD~1000)
EOF
cat >in-shallow <<-EOF
$(git rev-parse HEAD)
--shallow $(git rev-parse HEAD)
EOF
'
for version in 1 2
do
export version
test_perf "thin pack with version $version" '
git pack-objects --thin --stdout --revs --sparse \
--name-hash-version=$version <in-thin >out
'
test_size "thin pack size with version $version" '
test_file_size out
'
test_perf "big pack with version $version" '
git pack-objects --stdout --revs --sparse \
--name-hash-version=$version <in-big >out
'
test_size "big pack size with version $version" '
test_file_size out
'
test_perf "shallow fetch pack with version $version" '
git pack-objects --stdout --revs --sparse --shallow \
--name-hash-version=$version <in-shallow >out
'
test_size "shallow pack size with version $version" '
test_file_size out
'
test_perf "repack with version $version" '
git repack -adf --name-hash-version=$version
'
test_size "repack size with version $version" '
gitdir=$(git rev-parse --git-dir) &&
pack=$(ls $gitdir/objects/pack/pack-*.pack) &&
test_file_size "$pack"
'
done
test_done

31
t/perf/p5314-name-hash.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
test_description='Tests pack performance using bitmaps'
. ./perf-lib.sh
GIT_TEST_PASSING_SANITIZE_LEAK=0
export GIT_TEST_PASSING_SANITIZE_LEAK
test_perf_large_repo
test_size 'paths at head' '
git ls-tree -r --name-only HEAD >path-list &&
wc -l <path-list &&
test-tool name-hash <path-list >name-hashes
'
for version in 1 2
do
test_size "distinct hash value: v$version" '
awk "{ print \$$version; }" <name-hashes | sort | \
uniq -c >name-hash-count &&
wc -l <name-hash-count
'
test_size "maximum multiplicity: v$version" '
sort -nr <name-hash-count | head -n 1 | \
awk "{ print \$1; }"
'
done
test_done