Earlier quoted context omitted.
This post has gone to the top of hacker news, so I think we should give him some slack Looks like an amazing article, and so much to learn on what happens under the hood
HN generates ~20k page views over the course of a day with a peak of 2k/h: https://harrisonbroadbent.com/blog/hacker-news-traffic-spike... . At ~1MB per page load - not sure how accurate this is, I don't think it fully loaded - this static blogpost requires 0.55MB/s to meet demand. An original raspberry pi B (10mpbs ethernet) on the average french mobile internet connection (8mbps) provides double that. I don't mean…
Linux Pipes Are Slow
121–130 of 171 posts
Re: Linux Pipes Are Slow
#122Earlier quoted context omitted.
> and for pipes, if both ends support using the ringbuffer they'll map the same ringbuffer Is there planned to be a standardized way to signal to the other end of the pipe that ring buffers are supported, so this could be handled transparently in libc? If not, I don't really see what advantage it gets you compared to shared memory + a futex for synchronization—for pipes that is.
Presumably the same interface still works if the other side is using read/write.
Re: Linux Pipes Are Slow
#123just never use pipes. they are some weird archaism that need to die :P the only time ive used them is external constraints. they are just not useful.
I agree with this but with a much more nuanced take: avoid pipes if either reader or writer expects to do async i/o and you don't own both the reader and writer. In fact if you ever set O_NONBLOCK on a pipe you need to be damn sure both the reader and writer expect non-blocking i/o because you'll get heisenbugs under heavy i/o when either the reader/writer outpace each other and one expects blocking i/o. When's the l…
Not sure what printf has to do with, it isn't designed to be used with a non-block writer (but that only concerns one side). How will the reader being non-block change the semantics of the writer? It doesn't.
You can't set O_NONBLOCK on a pipe fd you expect to use with stdio, but that isn't unique to pipes. Whether the reader is O_NONBLOCK will not affect you if you're pushing the writer with printf/stdio.
(This is also a reason why I balk a bit when people refer to O_NONBLOCK as "async IO", it isn't the same and leads to this confusion)
Re: Linux Pipes Are Slow
#124Earlier quoted context omitted.
This isn’t code in some project that will run only a few billion times in its lifetime; it is used frequently on millions, if not billions, of computers. Because of that, it is economical to spend lots of time optimizing it, even if it only makes the code marginally more efficient.
Citation needed. Pipes aren't used everywhere in production in hot paths. That just doesn't happen.
Re: Linux Pipes Are Slow
#125Re: Linux Pipes Are Slow
#126Earlier quoted context omitted.
Sometimes the best answer really is a faster Corolla! https://www.toyota.com/grcorolla/ (These machines have amazing engineering and performance, and their entire existence is a hack to work around rules making it unviable to bring the intended GR Yaris to the US market.. Maybe just enough eng/perf/hack/market relevance to HN folk to warrant my lighthearted reply. Also, the company president is still on the tools.
There's no replacement for displacement.
Re: Linux Pipes Are Slow
#127Earlier quoted context omitted.
There's no replacement for displacement.
Apparently there is, because that car only has a 1.6L 3-cylinder engine and yet produces a whopping 300 horsepower.
Re: Linux Pipes Are Slow
#128Calling Linux pipes "slow" is like calling a Toyota Corolla "slow". It's fast enough for all but the most extreme use cases. Are you racing cars? In a sport where speed is more important than technique? Then get a faster car. Otherwise stick to the Corolla.
Re: Linux Pipes Are Slow
#129Calling Linux pipes "slow" is like calling a Toyota Corolla "slow". It's fast enough for all but the most extreme use cases. Are you racing cars? In a sport where speed is more important than technique? Then get a faster car. Otherwise stick to the Corolla.
I'm not sure that logic makes sense. Making a thing that's used ubiquitously a few percent faster it's absolutely a worthwhile investment of effort. Individual operations might but be very much faster but it's (in aggregate) a ton of electricity and time globally.
Donald Knuth thinks the same: https://en.wikipedia.org/wiki/Program_optimization#When_to_o...