Pergunta

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!

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top