Buffer size of a FileOutputStream


#1

I‘m about to write a class that stores a realtime datastream into a file. In order to not Block the realtime thread with disk I/O, I want to use a lock free fifo, that is fed with realtime data and a thread that reads from the fifo and stores new data to the file. Both will be synchronized by a WaitableEvent.

Now with this setup, does it make sense to set the buffer size of the FileOutputStream that‘s used to store the data to the disk to 0 as I have the fifo as my own buffer, or would it still make sense to have a certain buffersize here?


#2

You could remove the buffer if you’re writing big chunks. Wouldn’t expect it to make much difference either way.

You know there’s a class that does this: AudioFormatWriter::ThreadedWriter?


#3

The chunks will be somewhere around 64000 Bytes. But if it wouldn‘t make any difference I‘ll just leave it at it’s default value.

Yes I know, but I‘m not dealing with audio here, I‘m processing complex valued RF samples in an Software Defined Radio application that will be stored in a MATLAB compatible matrix file format, so I‘ll have to build my own. But I will take a look at the sourcecode of the ThreadedWriter for some inspiration!