Repository navigation
pr-2301/spkrka/test-tool-genbytes-v3
tagged this
10 Nov 18:26
From: Kristofer Karlsson <krka@spotify.com> Several tests create fixture data consisting of a single repeated character with "test-tool genzeros <count> | tr '\000' <char>". This works well on platforms where tr(1) is implemented efficiently. The implementation of tr(1) on macOS supports multi-byte characters, and processes its input one character at a time through getwchar() and putwchar(), even in the C locale. For small inputs that does not matter, but t4205 generates more than 2GB of data this way, which makes that test much slower on macOS than on Linux: on the macOS CI runners, tr(1) alone spends 95 to 123 seconds of CPU time on it, compared to about 6 seconds on Linux. Fix this by adding "test-tool genbytes <char> [<count>]" next to "genzeros", sharing the same code, which writes the requested character directly. Use it in all tests that piped "genzeros" through tr(1), not just t4205, so that it is the obvious choice for new tests. Callers that want NUL bytes keep using "genzeros". While at it, parse the count with git_parse_signed(), so that an invalid count is reported as a usage error instead of being silently treated as 0. This makes t4205 much faster on macOS in CI. The Linux jobs, shown for comparison, show smaller differences, which may partly be due to normal run-to-run variation: job before after change osx-gcc 821.1s 243.3s -70.4% osx-reftable 911.0s 194.0s -78.7% linux-asan-ubsan 226.7s 222.1s -2.0% linux-leaks 320.2s 298.8s -6.7% Signed-off-by: Kristofer Karlsson <krka@spotify.com> Submitted-As: https://lore.kernel.org/git/pull.2301.v3.git.1794335168170.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2301.git.1794063565.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2301.v2.git.1794165304.gitgitgadget@gmail.com