To avoid unnecessary read-write-change cycles on the hard drive.
Ideally, you βoutput the dataβ as close as possible to the actual sector size.
Each time the data is written, the entire sector is read, then modified by your data, and then written back to disk.
If you wash 5 bytes at a time, this is a lot of I / O operations that must happen. Suppose you have a hard disk with a sector size of 4096, which is about 120 read-modify -write operations to complete.
While if you buffer it to the maximum, you only have to perform one read operation on the write, which will cause the harddrive to stop waiting for this task to complete.
Many operating system processes and hard drive firmware exist to wait a bit to see if more data will be added to the sector, but it is best to ensure that the write cache of the hard drive can be flushed to the disk earlier.
Interesting reading:
What happens behind the curtains during disk I / O?
http://www.seagate.com/tech-insights/advanced-format-4k-sector-hard-drives-master-ti/
source share