From: Kristofer Karlsson Date: Tue, 10 Nov 2026 08:09:21 GMT Subject: Re: [PATCH 2/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Message-ID: In-Reply-To: <8733t9z0mi.fsf@gmail.com> On Tue, 10 Nov 2026 at 07:08, Collin Funk wrote: > > I'm not sure if macOS 'tr' handles multibyte characters. But it might be > worth checking if they do, and if they keep a fast case for single-byte > locales. Doing that without duplicating code is quite tricky, which is > part of the reason why we haven't done it in GNU 'tr' yet (but recent > releases have improved multi-byte character support for other utilities, > so hopefully it is handled soon). Thanks, this was an interesting read (even if it may not solve the problem at hand). To answer your question about macOS tr: it does not seem to have a single-byte fast path. Apple's tr (text_cmds tr/tr.c) goes through getwchar()/putwchar() for every byte even with LC_ALL=C, which is why "genzeros | tr" takes about 2 minutes for 2GB there, compared to a few seconds with GNU tr. "yes" is nicely optimized, but without an option to drop the newlines we would still need to filter its output, and filtering is exactly what is slow on macOS. I suppose the primitive I would ideally want is something like "repeat []". In the end portability is the main problem: with tr and printf behaving this differently across platforms, a tiny test-tool helper is easier to reason about than any combination of shell tools. Thanks, Kristofer > > Collin > > [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/printf.html > [2] https://github.com/coreutils/coreutils/commit/2b1c059e6a06eebbb721d010b1221ec54200cc33 >