How expensive is a named pipe (fifo)?

I am running many processes and I need each process to wait for input . Is it a good idea to create a named pipe for each process? Or should I consider another way to sync?

I know for sure that creating a normal file for each individual process will be very unfortunate as the processes will slow down on the hard drive. But how do these idiots compare in this regard? Are they as fast as signals or slow as regular files?

+3


source to share


2 answers


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



I would not use a real file until I prove it is a bottleneck. Since the OS will buffer small writes to the file in memory until an attempt is made to read the file or the buffer fills up, you may not experience I / O delays due to the speed of your hard drive.

0


source


With pipes, your recording streams can be stopped if the reader is too slow. But this may be what you want.

If you crash, disk writes can be slow, you can use tmpfs (a file system in RAM) for your named pipe. (This makes it faster to access only your channel names). In any case, most disk operations are cached.



Perhaps you could consider d-bus for your design (which shouldn't be faster or slower): https://en.wikipedia.org/wiki/D-Bus

0


source







All Articles