[PATCH v2 07/11] test-tool synthesize: use the unsafe hash for speed
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 4, 2026, 17:08 UTC
- Message-ID
- <859e93e7a9f1d5ba965dc2b9891b5885a6c167ef.1777914508.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2102.v2.git.1777914508.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Jeff King pointed out on the mailing list [1] that t5608's new >4GB test cases dominate the entire test suite runtime: 160 seconds on his laptop when the rest of the suite finishes in under 90 seconds, and 305-850 seconds across CI jobs. The bottleneck is that the synthesize helper hashes roughly 8 GB of data through SHA-1 (4 GB for the pack checksum plus 4 GB for the blob OID) for a 4 GB+1 blob.
Since the helper generates known test data, collision detection is unnecessary. Switch from repo->hash_algo to unsafe_hash_algo(), which uses hardware-accelerated SHA-1 (via OpenSSL or Apple CommonCrypto) when available.
Benchmarks on an x86_64 machine generating a 4 GB+1 pack (2 runs each, interleaved):
SHA-1 backend Run 1 Run 2 SHA1DC (safe) 75s 80s OpenSSL (unsafe) 21s 19s
The effect scales linearly. At 64 MB with 10 randomized interleaved runs, the OpenSSL unsafe backend shows a 5.4x improvement (median 0.202s vs 1.088s) with tight variance (stdev 0.028s vs 0.095s).
The speedup is only realized when the build has a fast unsafe backend compiled in. The CI's linux-TEST-vars job already sets OPENSSL_SHA1_UNSAFE=YesPlease; macOS benefits from Apple CommonCrypto when configured. On builds without a separate unsafe backend (such as the default Windows builds), unsafe_hash_algo() returns the regular collision-detecting implementation and the change is a no-op.
[1] https://lore.kernel.org/git/20260501063805.GA2038915@coredump.intra.peff.net/
Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- t/helper/test-synthesize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/helper/test-synthesize.c b/t/helper/test-synthesize.c index 3ce7078078..e2faaad7b4 100644 --- a/t/helper/test-synthesize.c +++ b/t/helper/test-synthesize.c @@ -217,7 +217,7 @@ static int cmd__synthesize__pack(int argc, const char **argv, setup_git_directory_gently(&non_git); repo = the_repository; - algo = repo->hash_algo; + algo = unsafe_hash_algo(repo->hash_algo); argc = parse_options(argc, argv, NULL, options, usage, PARSE_OPT_KEEP_ARGV0);
-- gitgitgadget