gitgram/aitimemachine/git/t/perf/p5332-multi-pack-reuse.sh
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

82 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
test_description='tests pack performance with multi-pack reuse'
. ./perf-lib.sh
. "${TEST_DIRECTORY}/perf/lib-pack.sh"
packdir=.git/objects/pack
test_perf_large_repo
find_pack () {
for idx in $packdir/pack-*.idx
do
if git show-index <$idx | grep -q "$1"
then
basename $idx
fi || return 1
done
}
repack_into_n_chunks () {
git repack -adk &&
test "$1" -eq 1 && return ||
find $packdir -type f | sort >packs.before &&
# partition the repository into $1 chunks of consecutive commits, and
# then create $1 packs with the objects reachable from each chunk
# (excluding any objects reachable from the previous chunks)
sz="$(($(git rev-list --count --all) / $1))"
for rev in $(git rev-list --all | awk "NR % $sz == 0" | tac)
do
pack="$(echo "$rev" | git pack-objects --revs \
--honor-pack-keep --delta-base-offset $packdir/pack)" &&
touch $packdir/pack-$pack.keep || return 1
done
# grab any remaining objects not packed by the previous step(s)
git pack-objects --revs --all --honor-pack-keep --delta-base-offset \
$packdir/pack &&
find $packdir -type f | sort >packs.after &&
# and install the whole thing
for f in $(comm -12 packs.before packs.after)
do
rm -f "$f" || return 1
done
rm -fr $packdir/*.keep
}
for nr_packs in 1 10 100
do
test_expect_success "create $nr_packs-pack scenario" '
repack_into_n_chunks $nr_packs
'
test_expect_success "setup bitmaps for $nr_packs-pack scenario" '
find $packdir -type f -name "*.idx" | sed -e "s/.*\///" |
git multi-pack-index write --stdin-packs --bitmap \
--preferred-pack="$(find_pack $(git rev-parse HEAD))"
'
for reuse in single multi
do
test_perf "clone for $nr_packs-pack scenario ($reuse-pack reuse)" "
git for-each-ref --format='%(objectname)' refs/heads refs/tags >in &&
git -c pack.allowPackReuse=$reuse pack-objects \
--revs --delta-base-offset --use-bitmap-index \
--stdout <in >result
"
test_size "clone size for $nr_packs-pack scenario ($reuse-pack reuse)" '
test_file_size result
'
done
done
test_done