Is there a big performance difference between:
I'm curious to know what the answer is for both Windows and *nix.
EDIT: I should have asked: Does the buffer cache eliminate the difference between a temp file and a pipe?
The difference between a named pipe and a regular file in Unix is that. Pipes forbid random accessing, while regular files do allow this.
CAD file created by PIPE-FLO, a program used for designing piping systems; stores a schematic of the piping system (series, branching, or looped) and can include pipelines, pumps, compressors, control valves, and other components; used for both liquid and gas systems.
The pipe has no name; it is created for one use and both ends must be inherited from the single process which created the pipe. A FIFO special file is similar to a pipe, but instead of being an anonymous, temporary connection, a FIFO has a name or names like any other file.
A FIFO, also known as a named pipe, is a special file similar to a pipe but with a name on the filesystem. Multiple processes can access this special file for reading and writing like any ordinary file. Thus, the name works only as a reference point for processes that need to use a name in the filesystem.
One big difference is that with the pipe, processes A and B can be running concurrently, so that B gets to work on the output from A before A has finished producing it. Further, the size of the pipe is limited, so A won't be able to produce vastly more data than B has consumed; it will be made to wait for B to catch up.
If the volume of data is big, then writing to the temporary file involves disk activity, even if only for creating and then destroying the file. The data might well stay in the in-memory buffer pools - so no disk I/O there - even for surprisingly large files. Writing to the pipe 'never' involves writing to disk.
The big difference is that the first method actually uses on-disk storage, whereas a pipe will use memory (unless you get really pedantic and start thinking about swap space).
Performance-wise, memory is faster than disk (almost always). This should be generally true for all operating systems.
The only time when using a temp file really makes sense is if process B has to examine the data in multiple passes (like certain kinds of video encoding). For this use, the whole data stream would need to be buffered and if there were enough data yes it would probably negate the in-memory advantage. So for multi-pass (seek-bound) operations, go with a temp file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With