Re:A Little Story About the `yes` Unix Command
by kibwen on Wednesday October 11, 2017 @08:37PM
(#15454784)
For a program like this, execution is I/O bound rather than CPU bound, so even if Python is generally less CPU efficient than Rust the effect is overwhelmed by a different I/O strategy. It's just like how Node has greater max throughput for trivial server workloads than a naive C implementation.
[ Parent
| on HN ]
Re:A Little Story About the `yes` Unix Command
by glandium on Wednesday October 11, 2017 @08:48PM
(#15454828)
According to empirical evidence in my sibling post, that's not true in this case.
Re:A Little Story About the `yes` Unix Command
by benaiah on Wednesday October 11, 2017 @09:04PM
(#15454891)
Your post seems to demonstrate _exactly_ what the post you're replying to is saying: most of the speed has to do with I/O strategy (buffering and syscall usage), not the actual speed of the involved language. Maybe I'm missing a distinction you're making, but I'm not following how your previous comment leads to what you're saying here.
Re:A Little Story About the `yes` Unix Command
by glandium on Wednesday October 11, 2017 @09:28PM
(#15454999)
The rust version that does exactly what python does (buffered output) is an order of magnitude faster (even if I force the rust buffer size to be 4KiB like with python2).
Re:A Little Story About the `yes` Unix Command
by kibwen on Wednesday October 11, 2017 @09:31PM
(#15455015)
To head off this comment chain, I've softened the language in my original comment to "overwhelmed by" rather than implying that non-I/O factors are wholly irrelevant. :)
Re:A Little Story About the `yes` Unix Command
by katastic on Wednesday October 11, 2017 @08:48PM
(#15454823)
That doesn't make a whole lot of sense when the guy above you posted that two versions of python (2 vs 3) have significantly different output throughput rates.
If it's I/O bound why are they changing at all?
Re:A Little Story About the `yes` Unix Command
by benaiah on Wednesday October 11, 2017 @09:02PM
(#15454886)
It is I/O bound, but Python 2 and 3 do I/O differently. From the same comment that you're referring to:
> Python 2 emits writes of 4096 bytes, and python 3... 8193 bytes (edit: not a typo, this is 8KiB + 1).