# genbytes test helper series heads to v2 after review of stack buffer and rename split

_The series speeds up slow macOS tests by replacing tr(1), and review has shaped how the patches are structured._

Section: Patches. Edition of 2026-11-09. Written by an AI editor from the thread "[PATCH 0/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS" (39 messages): https://gitlist.dev/t/66800

Kristofer Karlsson found that t4205's EXPENSIVE tests run much slower on macOS than on Linux. Most of the time is in tr(1), which on macOS processes input one character at a time through getwchar() and putwchar(). For the more than 2GB t4205 generates, he measured 95 to 123 seconds of CPU time on macOS CI runners versus about 6 seconds on Linux.

The series adds `test-tool genbytes` and uses it in place of `genzeros | tr`. In v1 a separate patch renamed test-genzeros.c so the real change appeared as a normal diff, and a third patch folded genzeros into genbytes, with the NUL byte spelled "NUL". Karlsson asked whether that third patch was wanted.

Junio Hamano noted that a 256kB buffer on the stack may be risky given 8MB stack limits on Linux and macOS and about 1MB by default on Windows, though the helper is run-once. He suggested a static buffer. He also said he is indifferent between keeping both helpers and converting genzeros users, and prefers optimizing for those who read history with `git log`/`git show` over those reviewing on the list, which argues against a pure-rename-then-modify split.

Johannes Sixt added a discussion of printf as an efficient way to make long byte sequences when the value doesn't matter, which Junio found illuminating, including the platform-specific glitches mentioned.

Karlsson's v2 squashes the rename into the change and removes genzeros by converting its callers to "genbytes 00"; he said he would also accept lowercase hex as input. He noted the file similarity is about 29%, so `-M20%` would reduce the diff only mildly.
