The default buffer size is 8k in BufferedWriter
of somewhere else. Why use 8k? Does larger buffer size improve the performance?
stream with a default 512-byte buffer size. Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.
It uses the following algorithm to determine the default size of the cursor buffer: If one row fits in a 4096-byte buffer, the default buffer size is 4096 bytes (4 kilobytes). If the size of one row exceeds 4096 bytes, the default buffer size is the size of that row.
Initializes a new instance of the BufferedStream class with a default buffer size of 4096 bytes.
Buffer size means the time to store data from Network temporarily while downloading.
The buffer reduces the number of write system calls and thereby optimizes the output. Depending on your program's activity a bigger write buffer may improve performance, it's always best to test with a bigger buffer with a workload comparable to what your program does. Also, the buffer's importance is higher when the underlying filesystem's cache is write-through (no write cache), because a write-behind cache will delay/group the physical write operations anyways.
I think the historical reason for the 8k is related to the traditional allocation sizes on disk, often 2k or a multiple thereof.
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