0

I recently read a suggestion for using Java's BufferedOutputStream more efficiently by setting the buffer size to 8MB to "reduce throughput hits from disk seeking".

I am intrigued by this last statement: reducing throughput hits from disk seeking?!?

What does this mean/imply? Why is 8MB a magic number? Thanks in advance!

1 Answers1

0

I don't think it is a magic number or anything. It just buffers data up to that limit before it actually writes it to the disc. So if you have short data blocks you can batch them and just write once instead of many times. This save disc seeks because the disc would need to find the correct location at the beginning of each block.

So it simply safes a couple of the expensice (not so expensive when using a SSD) disc seeks, when write many small chunks of data.

Update: 8MB is just one unit larger than the default buffer size which is 8kb.

ssindelar
  • 2,833
  • 1
  • 17
  • 36
  • Thanks @Casey (+1) - but you said "*which meanns you can read it without additional seeks...*" Here's I'm strictly talking about **writing** to a file, not reading. Can you please confirm that your answer also applies to writes (and not just reads), or modify your answer to address writes? Thanks again! –  Jul 08 '13 at 14:38
  • Upps, I was completely at BufferedInputStream. But it is also true for writes. Updated the answer – ssindelar Jul 08 '13 at 14:44