DEV Community

OptiJava
OptiJava

Posted on

How to optimize the performance of write files.

Thank you.

Top comments (3)

Collapse
 
deciduously profile image
Ben Lovy

Use an in-memory buffer. 4K is a good default size. Instead of invoking the write syscall for every single byte, you fill your buffer, then invoke the syscall just once and write the whole chunk at the same time. Then you can clear the buffer and do it again until EOF.

Collapse
 
optijava profile image
OptiJava • Edited

Thanks.It's a good idea.I'm going to try memory buffer.

Collapse
 
shailendra profile image
donkey sama

Welcome.