You could make "yes" faster with the tee() syscall. Keep duplicating data from the same fdin (doesn't actually copy) and it becomes entirely zero-copy.
And pv on the other side of the pipe should use splice().
Now that would be a complete zero-copy I/O path, purely limited by the CPU, not by memory bandwidth. It would benchmark at hundreds of GB/s :)
Good catch, I just noticed that it does.
https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes...
Edit: I optimized further and now get 123 GB/s See https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes...
I've realised straight tee() is actually wrong - it works fine for piping to something but "zcyes > /dev/null" won't work, it needs vmsplice() like mrb said.
core2duo e8400, 4.8 kernel, coreutils 8.25
> yes | dd bs=1M count=10000 of=/dev/null iflag=fullblock
10485760000 bytes (10 GB, 9.8 GiB) copied, 4.1901 s, 2.5 GB/s
> ./zcyes | dd bs=1M count=10000 of=/dev/null iflag=fullblock
10485760000 bytes (10 GB, 9.8 GiB) copied, 1.8542 s, 5.7 GB/s