Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How expensive is a named pipe (fifo)?

I spawn many processes and I need each process to wait for input. Is creating a named pipe per process a good idea? Or should I consider some other way of synchronisation?

I know for certain that making a normal file for every separate process would be very bad since the processes would get slowed down by the hard disk. But how do named pipes compare in that regard? Are they as fast as signals or as slow as normal files?

like image 928
Pithikos Avatar asked Dec 05 '25 01:12

Pithikos


1 Answers

A named pipe is just a file system entry for an in-memory buffer, so access should be fast enough.

I wouldn't avoid using a real file until you prove that it is a bottleneck. Since the OS will buffer small writes to a file in memory until either an attempt to read the file is made or the buffer fills up, you may not experience any I/O delay due to your hard drive's speed.

like image 200
chepner Avatar answered Dec 06 '25 16:12

chepner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!