by rootnod3 · 1mo ago · 0 comments
It’s arsinine to optimize it to that level instead of just keeping it readable and maintainable. And portable.
The gnu version is 100% not easily portable because it has assumptions about the underlying kernel.
I don't know about oblivion, and non-portable optimizations are not good. But perhaps yes(1) and echo(1) are among the tightest inner loops of scripting. You would not want them to bottleneck the pipeline. You'd want them pumping output faster than it could be accepted or written out.
Perhaps there is an opportunity for a /dev/yes, which acts like /dev/zero, only it continually outputs whatever filename it was opened as (good luck!)
The Linux optimization just uses splice and vmsplice. If those APIs are changed to avoid zero-copy, as was considered for some time after the AF_ALG security issues, it is unlikely that another API would take their place. So, no, I do not think it needs any changes if Linux changes.