* bootstrap.conf (avoided_gnulib_modules): Avoid mbiter and
mbiterf, for the same reason we avoid mbuiter and mbuiterf: these
modules are not needed because (due to mcel-prefer) we use mcel in
preference to mbiter/mbiterf/mbuiter/mbuiterf.
* tests/dd/misc.sh: test -w /dev/tty is not a strong enough check,
we need to actually open /dev/tty to ensure it's available.
It's not available under setsid for example.
* tests/dd/misc.sh: Add test case for of=/dev/tty.
The same occurs for /dev/stdout, but that varies
in the test hardness so is best avoided.
https://github.com/coreutils/coreutils/pull/234
Adding environment variables can become quite expensive in some
admittedly unlikely situations.
$ for i in $(seq 10000); do export A$i=A$i; done
$ time ./src/date-prev -u $(yes -- -u | head -n 100000)
Sun Mar 29 01:59:49 AM UTC 2026
real 0m3.753s
user 0m3.684s
sys 0m0.050s
$ time ./src/date -u $(yes -- -u | head -n 100000)
Sun Mar 29 02:00:00 AM UTC 2026
real 0m0.061s
user 0m0.022s
sys 0m0.045s
* src/date.c (main): Only add TZ=UTC0 to the environment once.
* doc/coreutils.texi (tty invocation): Mention that POSIX.1-2001 removed
the -s option and that portable scripts can redirect standard out to
/dev/null instead.
* tests/env/env.sh: Make more portable by avoiding references to our
build dir, and avoiding names that may cause false matches in
multi-call binaries.
https://github.com/coreutils/coreutils/pull/216
We don't output an address for `od missing` or `od --strings .`,
so be consistent and suppress the address for `od .`.
* src/od.c (dump): Only output an address if no errors
or the offset is non zero.
When sort is invoked with an explicit field separator with `-t SEP`,
begfield() and limfield() scan for the separator to locate boundaries.
Right now the implementation there uses a loop that iterates over bytes
one by one, which is not ideal since we must scan past many bytes of
non-separator data one byte at a time.
Let's replace each of these loops with memchr(). On glibc systems,
memchr() uses SIMD to scan 16 bytes per step (NEON on aarch64) or 32
bytes per step (AVX2 on x86_64), rather than 1 byte at a time, so any
field longer than a handful of bytes stands to benefit quite
significantly.
Using the following input data:
awk 'BEGIN {
srand(42)
for (i = 1; i <= 500000; i++)
printf "%*d,%*d,%d\n", 4+int(rand()*9), 0,
4+int(rand()*9), 0, int(rand()*10000)
}' > short_csv_500k
awk 'BEGIN {
for (i = 1; i <= 500000; i++)
printf "%100d,%100d,%d\n", 0, 0, int(rand()*10000)
}' > wide_csv_500k
One can benchmark with:
hyperfine --warmup 10 --runs 50 \
"LC_ALL=C sort_before -t, -k3,3n short_csv_500k > /dev/null" \
"LC_ALL=C sort_after -t, -k3,3n short_csv_500k > /dev/null"
hyperfine --warmup 10 --runs 50 \
"LC_ALL=C sort_before -t, -k3,3n wide_csv_500k > /dev/null" \
"LC_ALL=C sort_after -t, -k3,3n wide_csv_500k > /dev/null"
hyperfine --warmup 10 --runs 50 \
"LC_ALL=C sort_before wide_csv_500k > /dev/null" \
"LC_ALL=C sort_after wide_csv_500k > /dev/null"
The results on i9-14900HX x86_64 with -O2:
sort -t, -k3,3n (500K lines, 4-12 byte short fields):
Before: 123.1 ms After: 108.1 ms (-12.2%)
sort -t, -k3,3n (500K lines, 100 byte wide fields):
Before: 243.5 ms After: 165.9 ms (-31.9%)
sort (default, no -k, 500K lines):
Before: 141.6 ms After: 141.8 ms (unchanged)
And on M1 Pro aarch64 with -O2:
sort -t, -k3,3n (500K lines, 4-12 byte short fields):
Before: 98.0 ms After: 92.3 ms (-5.8%)
sort -t, -k3,3n (500K lines, 100 byte wide fields):
Before: 240.8 ms After: 183.0 ms (-24.0%)
sort (default, no -k, 500K lines):
Before: 145.6 ms After: 145.6 ms (unchanged)
Looking at profiling, the improvement is larger on x86_64 in these runs
because glibc's memchr uses AVX2 to scan 32 bytes per step versus 16
bytes per step with NEON on aarch64.
This patch also fixes a bug where 'tac' would print a vague error on
some inputs:
$ seq 10000 | ./src/tac-prev > /dev/full
tac-prev: write error
$ seq 10000 | ./src/tac > /dev/full
tac: write error: No space left on device
In this case ferror (stdout) is true, but errno has been set back to
zero by a successful fclose (stdout) call.
* src/tac.c (output): Call write_error() if fwrite fails.
* tests/misc/io-errors.sh: Check that 'tac' prints a detailed write
error.
* NEWS: Mention the improvement.
* tests/misc/io-errors.sh: Support checkout for a specific error
in commands that don't run indefinitely. Currently all the explicitly
listed commands output a specific error and do not need to be tagged.
* tests/ls/non-utf8-hidden.sh: Avoid sorting in ls, to avoid:
ls: cannot compare file names ...: Illegal byte sequence
seen on FreeBSD 14.
Reported by Bruno Haible.
We disable buffering on the streams anyways, so we were effectively
calling the write system call previously despite using streams.
* src/iopoll.h (fclose_wait, fwrite_wait): Remove declarations.
(close_wait, write_wait): Add declarations.
* src/iopoll.c (fwait_for_nonblocking_write, fclose_wait, fwrite_wait):
Remove functions.
(wait_for_nonblocking_write): New function based on
fwait_for_nonblocking_write.
(close_wait): New function based on fclose_wait.
(write_wait): New function based on fwrite_wait.
* src/tee.c: Include fcntl--.h. Don't include stdio--.h.
(get_next_out): Operate on file descriptors instead of streams.
(fail_output): Likewise. Remove clearerr call since we no longer call
fwrite on stdout.
(tee_files): Operate on file descriptors instead of streams. Remove
calls to setvbuf.
* src/timeout.c (main): Save the process ID before creating a child
process. Check if the result of getppid is different than the saved
process ID instead of checking if it is 1.
* tests/timeout/init-parent.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix. Also mention that this change allows
'timeout' to work when reparented by a subreaper process instead of
init.
* src/dd.c (dd_copy): Increment the partial write count upon failure.
* tests/dd/partial-write.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/80583
* NEWS: It was ambiguous as to whether we quoted a range of
observered throughputs. Clarify this was the old and new
throughput on a single test system.
A good reference for the concepts used here is:
https://mazzo.li/posts/fast-pipes.html
We don't consider huge pages or busy loops here,
but use vmsplice(), and splice() to get significant speedups:
i7-5600U-laptop $ taskset 1 yes | taskset 2 pv > /dev/null
... [4.98GiB/s]
i7-5600U-laptop $ taskset 1 src/yes | taskset 2 pv > /dev/null
... [34.1GiB/s]
IBM,9043-MRX $ taskset 1 yes | taskset 2 pv > /dev/null
... [11.6GiB/s]
IBM,9043-MRX $ taskset 1 src/yes | taskset 2 pv > /dev/null
... [175GiB/s]
Also throughput to file (on BTRFS) was seen to increase significantly.
With a Fedora 43 laptop improving from 690MiB/s to 1.1GiB/s.
* bootstrap.conf: Ensure sys/uio.h is present.
This was an existing transitive dependency.
* m4/jm-macros.m4: Define HAVE_SPLICE appropriately.
We assume vmsplice() is available if splice() is as they
were introduced at the same time to Linux and glibc.
* src/yes.c (repeat_pattern): A new function to efficiently
duplicate a pattern in a buffer with memcpy calls that double in size.
This also makes the setup for the existing write() path more efficient.
(pipe_splice_size): A new function to increase the kernel pipe buffer
if possible, and use an appropriately sized buffer based on that (25%).
(splice_write): A new function to call vmplice() when outputting
to a pipe, and also splice() if outputting to a non-pipe.
* tests/misc/yes.sh: Verify the non-pipe output case,
(main): Adjust to always calling write on the minimal buffer first,
then trying vmsplice(), then falling back to write from bigger buffer.
and the vmsplice() fallback to write() case.
* NEWS: Mention the improvement.
* src/system.h (c32issep): A new function that is essentially
iswblank() on GLIBC platforms, and iswspace() with exceptions elsewhere.
* src/expand.c: Use it instead of c32isblank().
* src/fold.c: Likewise.
* src/join.c: Likewise.
* src/numfmt.c: Likewise.
* src/unexpand.c: Likewise.
* src/uniq.c: Likewise.
* NEWS: Mention the improvement.
Fix an unreleased issue due to the recent change
to using idx_t in commit v9.10-91-g02983e493
* src/cksum.c (output_file): Cast the idx_t before passing to printf.
$ yes abcdefghijklmnopqrstuvwxyz | head -n 200000000 > input
$ time ./src/wc-prev -l input
200000000 input
real 0m1.240s
user 0m0.456s
sys 0m0.784s
$ time ./src/wc -l input
200000000 input
real 0m0.936s
user 0m0.141s
sys 0m0.795s
* configure.ac: Use unsigned char for the buffer to avoid potential
compiler warnings. Check for the functions being used in src/wc_neon.c
after this patch.
* src/wc_neon.c (wc_lines_neon): Use vreinterpretq_s8_u8 to convert 0xff
into -1 instead of bitwise AND instructions into convert it into 1.
Perform the pairwise addition and lane extraction once every 8192 bytes
instead of once every 64 bytes.
Thanks to Lasse Collin for spotting this and reviewing a draft of this
patch.
The explicit_bzero function is a common extension, but memset_explicit
was standardized in C23. It will likely become more portable in the
future, and Gnulib provides an implementation if needed.
* bootstrap.conf (gnulib_modules): Add memset_explicit. Remove
explicit_bzero.
* gl/lib/randint.c (randint_free): Use memset_explicit instead of
explicit_bzero.
* gl/lib/randread.c (randread_free_body): Likewise.
* src/expand.c: Use mbbuf to support multi-byte input.
* src/unexpand.c: Likewise.
* tests/expand/mb.sh: New multi-byte test.
* tests/unexpand/mb.sh: Likewise.
* tests/local.mk: Reference new tests.
* NEWS: Mention the improvement.