git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS

From
Kristofer Karlsson <krka@spotify.com>
Date
Nov 9, 2026, 13:05 UTC
Message-ID
<CAL71e4PSOJgKFfBLrTXJSAewnZTJpNEiAMC-_FbW_9cmpEvLmg@mail.gmail.com>
In-Reply-To
<ddea802a-d4f4-4de9-9108-e68201841bc4@kdbg.org>
On Mon, 9 Nov 2026 at 10:33, Johannes Sixt <j6t@kdbg.org> wrote:
Show 33 quoted lines
>
> Am 08.11.26 um 17:34 schrieb Johannes Sixt:
> > Am 08.11.26 um 13:24 schrieb Kristofer Karlsson:
> >> -       test-tool genzeros 2147483649 | tr "\000" "1" >expect &&
> >> +       printf 000000000%02147483640d 0 >expect &&
> >>
> >> I tried this out and it works on Linux but fails on macOS[1].  What
> >> happens is that printf only outputs the nine literal zeros
> >> ("000000000") there, and silently ignores the very large padding.
> >
> > Fair enough.
> >
> >> [1] https://github.com/gitgitgadget/git/actions/runs/42475956442/job/128717309586
>
> Well, this patch passed for me[2], but I have no idea whether the
> particular tests were skipped due to the EXPENSIVE prerequisite or not.
>
> [2] https://github.com/j6t/git/actions/runs/42583623620/job/129048078411
>
>
>
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 01b97c8888..5dedb9054e 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -1182,7 +1182,8 @@ unfold () {
>  '
>
>  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
    }

as a local helper in t4205. That fixes the slow test without a new test-tool, at the cost of yet another way of generating test data alongside genzeros and "genzeros | tr".

I have it ready locally as a single patch, as an alternative to this series, but perhaps it's best to wait for more people to chime in first.

Thanks, Kristofer

Previous: Johannes SixtNext: Johannes Sixt
Message 15 of 39 in “t: add "test-tool genbytes" to avoid slow tr(1) on macOS”
  1. 0/3 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 7, 2026
  2. 1/3 t/helper: rename test-genzeros.c to test-genbytes.cKristofer Karlsson via GitGitGadget, Nov 7, 2026
  3. Junio C HamanoNov 7, 2026
  4. Junio C HamanoNov 8, 2026
  5. Kristofer KarlssonNov 8, 2026
  6. Junio C HamanoNov 8, 2026
  7. Kristofer KarlssonNov 8, 2026
  8. 2/3 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 7, 2026
  9. Johannes SixtNov 8, 2026
  10. Kristofer KarlssonNov 8, 2026
  11. Johannes SixtNov 8, 2026
  12. Kristofer KarlssonNov 8, 2026
  13. Johannes SixtNov 8, 2026
  14. Johannes SixtNov 9, 2026
  15. Kristofer KarlssonNov 9, 2026
  16. Johannes SixtNov 9, 2026
  17. Collin FunkNov 10, 2026
  18. Kristofer KarlssonNov 10, 2026
  19. Junio C HamanoNov 8, 2026
  20. 3/3 t: replace "test-tool genzeros" with "genbytes NUL"Kristofer Karlsson via GitGitGadget, Nov 7, 2026
  21. Junio C HamanoNov 7, 2026
  22. Kristofer KarlssonNov 8, 2026
  23. Junio C HamanoNov 7, 2026
  24. Kristofer KarlssonNov 8, 2026
  25. 0/2 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 8, 2026
  26. 1/2 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 8, 2026
  27. Junio C HamanoNov 9, 2026
  28. Kristofer KarlssonNov 9, 2026
  29. Junio C HamanoNov 9, 2026
  30. Patrick SteinhardtNov 9, 2026
  31. Kristofer KarlssonNov 9, 2026
  32. 2/2 t: replace "test-tool genzeros" with "genbytes 00"Kristofer Karlsson via GitGitGadget, Nov 8, 2026
  33. t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 10, 2026
  34. Junio C HamanoNov 10, 2026
  35. Patrick SteinhardtNov 11, 2026
  36. Junio C HamanoNov 11, 2026
  37. Kristofer KarlssonNov 11, 2026
  38. Junio C HamanoNov 11, 2026
  39. t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.