]> git.ipfire.org Git - thirdparty/coreutils.git/commit
shuf: avoid locking standard output when using --input-range
authorCollin Funk <collin.funk1@gmail.com>
Sat, 21 Feb 2026 08:06:01 +0000 (00:06 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 22 Feb 2026 03:20:07 +0000 (19:20 -0800)
commit89735ea830b293d50a9323770d6089bac7324aab
tree73044778f3443d6408c9c6c34fae9ab2c69324bb
parentd233ebd7d9e36208f5bc03935f910de4c3283dd1
shuf: avoid locking standard output when using --input-range

Here is the throughput before this patch:

    # write_permuted_numbers
    $ ./src/shuf-prev -i 0-100000000 | pv -r > /dev/null
    [ 153MiB/s]

    # write_random_numbers
    $ timeout 10 ./src/shuf-prev -i 0-100000 -r | pv -r > /dev/null
    [78.6MiB/s]

Here is the throughput after this patch:

    # write_permuted_numbers
    $ timeout 10 ./src/shuf -i 0-100000000 | pv -r > /dev/null
    [ 308MiB/s]

    # write_random_numbers
    $ timeout 10 ./src/shuf -i 0-100000 -r | pv -r > /dev/null
    [ 196MiB/s]

* NEWS: Mention the performance improvement.
* src/shuf.c (write_permuted_numbers, write_random_numbers): Prefer
fputs and fputc which may be unlocked over printf which locks standard
output.
NEWS
src/shuf.c