|
|
Subscribe / Log in / New account

Utility to find ideal blocksize.

Utility to find ideal blocksize.

Posted Mar 6, 2011 15:05 UTC (Sun) by gmatht (subscriber, #58961)
Parent article: Optimizing Linux with cheap flash drives

If anyone in interested I wrote a utility to help detect the ideal blocksize and alignment for writing to a device (particularly cheap flash devices). It allows you to set the read pattern, blocksize, and offset (the offset may be useful on drives that correct for XP's weird alignment of partitions); it will then benchmark writes with those settings.
http://dansted.co.cc/scripts/detectblocksize.c

For example, I found on my device if we write sequentially, writing of blocks of 64K is sufficient to maximize the data transfer rate, while if blocks are written randomly, 4MB is required.

This utility was discussed on the linux-bcache list, but the old mail archives don't seem to be on the web. I could discuss this further if anyone is interested.


to post comments

Utility to find ideal blocksize.

Posted Mar 9, 2011 15:50 UTC (Wed) by arnd (subscriber, #8866) [Link]

The results you found are very typical, and match what the flashbench tool referenced in the last sentence of the article finds on many media. The other interesting number is how many (4MB) segments can be written to alternating, which you can find out with

flashbench --open-au --open-au-nr=<NR> --erasesize=$[4096 * 1024] [ --random ]

with varying values for NR. With low numbers, it will be fast for all block sizes, while with large numbers of open segments, the time to write all segments is basically independent of the block size, because every write forces a garbage collection on one of the other open segments.

There is usually a very sharp contrast between the slow and fast results, e.g. five being very fast but six already being very slow.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds