From: Johannes Sixt Date: Mon, 09 Nov 2026 15:38:48 GMT Subject: Re: [PATCH 2/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Message-ID: <7b2e7ddf-dc8b-4538-b736-92217e20c8f0@kdbg.org> In-Reply-To: Am 09.11.26 um 14:05 schrieb Kristofer Karlsson: > On Mon, 9 Nov 2026 at 10:33, Johannes Sixt wrote: >> test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'set up huge commit' ' >> - test-tool genzeros 2147483649 | tr "\000" "1" >expect && >> + # 3 * 715827883 == 2147483649 >> + printf %0715827883d 0 0 0 >expect && >> huge_commit=$(git commit-tree -F expect HEAD^{tree}) > > I tested this and it passes on all the macOS jobs. t4205 goes > from 800-900s to 170-280s there, so your idea works well. > > Two caveats: the printf builtin in bash 3.2 (/bin/sh on macOS) > silently prints nothing for a field wider than INT_MAX - 15, > and it builds each field in memory, so this peaks at about 2.1GB > RSS. Both go away by writing in 1MiB chunks, at the same speed: > > gen_ascii_zeros () { > _n=$1 > while test "$_n" -gt 0 > do > _chunk=$(( _n > 1048576 ? 1048576 : _n )) > printf "%0${_chunk}d" 0 || return 1 > _n=$(( _n - _chunk )) > done > } I wouldn't do that (and pay the memory price instead), because the next shell doesn't have printf as a builtin and spawns 2000 printf processes. Now let's stop painting bikeshes. I'd be fine with your previous suggestion to have both `test-tool genzeros` and `test-tool genbytes`. -- Hannes