Calling 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.
A better analogy is its like a society that uses steam trains attempting to industrially compete with a society that uses bullet trains (literally similar by factor of improvement). The UK built its last steam train for national use in 1960, four years later the Shinkansen was in use in Japan. Which of those two nations has a strong international industrial base in 2024?
Linux Pipes Are Slow
51–60 of 171 posts
Re: Linux Pipes Are Slow
#52Earlier quoted context omitted.
Buffering is there for a reason and this approach will lead to weird failure modes and fragility in scripts. The core issue is that any stream producer might go slower than any given consumer. Even a momentary hiccup will totally mess up the pipe unless there is adequate buffering, and the amount needed is system-dependent.
Maybe I misunderstand, but if the ring buffer is full isn't it ok for the sender to just block?
Re: Linux Pipes Are Slow
#53Earlier quoted context omitted.
Genuine question: why does printf need a retry loop when using pipes?
It doesn't that's why no one does it. But for pipes what it means is that if whoever is reading or writing the pipe expects non blocking semantics, the other end needs to agree. And if they don't you'll eventually get an error because the reader or writer outpaced the other, and almost no program handles errors for stdin or stdout.
Re: Linux Pipes Are Slow
#54Anyway, nice article, its good to know whats going on under the hood.
Re: Linux Pipes Are Slow
#55Haha. When I read the title I smiled. Linux pipes slow? Moook.. Now try Cygwin pipes. Thats what I call slow! Anyway, nice article, its good to know whats going on under the hood.
Re: Linux Pipes Are Slow
#56Earlier quoted context omitted.
I have a project that uses a proprietary SDK for decoding raw video. I output the decoded data as pure RGBA in a way FFMpeg can read through a pipe to re-encode the video to a standard codec. FFMpeg can't include the Non-Free SDK in their source, and it would be wildly impracticable to store the pure RGBA in a file. So pipes are the only way to do it, there are valid reasons to use high throughput pipes.
What about domain sockets? It's clumsier, to be sure, but if performance is your goal, the socket should be faster.
Re: Linux Pipes Are Slow
#57Haha. When I read the title I smiled. Linux pipes slow? Moook.. Now try Cygwin pipes. Thats what I call slow! Anyway, nice article, its good to know whats going on under the hood.
I'd assumed Cygwin pipes are just Windows pipes, is that not the case?
https://cygwin.com/pipermail/cygwin-patches/2016q1/008301.ht...
Re: Linux Pipes Are Slow
#58Calling 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 have a project that uses a proprietary SDK for decoding raw video. I output the decoded data as pure RGBA in a way FFMpeg can read through a pipe to re-encode the video to a standard codec. FFMpeg can't include the Non-Free SDK in their source, and it would be wildly impracticable to store the pure RGBA in a file. So pipes are the only way to do it, there are valid reasons to use high throughput pipes.
Re: Linux Pipes Are Slow
#59Re: Linux Pipes Are Slow
#60One of my sideprojects is intended to address this: https://lwn.net/Articles/976836/ The idea is a syscall for getting a ringbuffer for any supported file descriptor, including pipes - and for pipes, if both ends support using the ringbuffer they'll map the same ringbuffer: zero copy IO, potentially without calling into the kernel at all. Would love to find collaborators for this one :)
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.