On 2019-11-04 21:05, Sönke Ludwig wrote:
StdFileStreamis a compromise implementation using threads to support
blocking file descriptors when nothing else is available. If possible,
FileStreamis always the preferred implementation.
However, 350 kB/s is definitely far slower than it should be. The first
thing that I noticed was that the default buffer size is rather small
with just 2 kB, it should be at least 64 kB, ideally 256 kB or more.
Another thing is that the data is copied up to three times - once into a
temporary read buffer, then into the
TaskPipebuffer, and finally into
the user target buffer.
Finally, reading from a
StdFileStreamis implemented by reading a
single character at a time to ensure that data is read in real-time for
interactive pipes (terminal input). For actual disk files this is
obviously a performance hazard and there should probably a flag in the
constructor to control this behavior.
There's the "sendfile" function as well . It sends a file over a
socket directly in the kernel without copying and data to user space.
That should be the fastest option. But it's only for Posix.