← Back to context

Comment by rootnod3

15 days ago

The 99% use case is for just `yes` though. That is optimized for such a niche corner-case...

What downsides does it have for end users?

  • It makes the code way less auditable and more prone to bugs and errors. Or let the kernel change its paging mechanism and now your fucking “yes” tool needs an update to be “efficient”. The tool has one job…print yes or another word you give it. It by definition does not have to optimized to oblivion. Same goes for echo.

    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.

    • > It by definition does not have to optimized to oblivion. Same goes for echo.

      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!)

      1 reply →

    • The current implementation works on any system with read and write system calls.

      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.