dd86k / ddgst

#️⃣ dd's hashing utility with a twist
Creative Commons Zero v1.0 Universal
10 stars 0 forks source link

Optimal block read size #7

Open dd86k opened 2 years ago

dd86k commented 2 years ago

Under a few operating systems, there are various ways to obtain the optimal block size for file read and write operations.

For Posix systems using fstat, it is possible to obtain the optimal block size for file operations. The stat field in question is st_blksize.

For Windows, a StackOverflow answer suggests using GetDiskFreeSpace and multiplying the lpBytesPerSector and lpSectorsPerCluster from the resulting structure. This should be the filesystem's cluster size.

Typical block sizes should be around 64 KiB for Linux systems and 4 KiB for Windows.

Of course, benchmarks should be made available.

dd86k commented 5 months ago

While ddgst 3.0 sees its new default from 16 KiB to 1 MiB, this might be implemented.