yes command written in Go
$ go install github.com/mattn/go-yes/cmd/yes@latest
Output goes through vmsplice(2) (zero-copy) when stdout is a pipe, which
makes it roughly 2.2x faster than GNU yes:
$ yes | dd of=/dev/null bs=1M count=10240 iflag=fullblock
10737418240 bytes (11 GB, 10 GiB) copied, 1.19094 s, 9.0 GB/s
$ ./yes | dd of=/dev/null bs=1M count=10240 iflag=fullblock
10737418240 bytes (11 GB, 10 GiB) copied, 0.527356 s, 20.4 GB/s
Measured on Linux (WSL2). Numbers vary by kernel and machine. On non-Linux
platforms (or when stdout is not a pipe) it falls back to plain write(2).
Windows has no vmsplice equivalent, so the only lever there is the block size: 256 KiB instead of the 64 KiB default gives about 1.7x (5.2 -> 8.8 GB/s piped between two processes on the same machine), which lands near GNU yes on WSL2 but still roughly 2x behind the vmsplice path.
MIT
Yasuhiro Matsumoto (a.k.a. mattn)