| 1 |
= flashbench -- identify characteristics of flash media = |
| 2 |
|
| 3 |
This is the tool used to identify the properties of |
| 4 |
SD cards and other media for the Linaro flash memory |
| 5 |
survey at [1]. The latest version should be available |
| 6 |
at [2]. Please also check out the article on lwn.net [3]. |
| 7 |
|
| 8 |
A short introduction to the most useful commands follows. |
| 9 |
|
| 10 |
== Guess erase block and page sizes == |
| 11 |
|
| 12 |
''flashbench -a <device>'' |
| 13 |
|
| 14 |
This is a simple read-only test doing small reads |
| 15 |
across boundaries of various sizes. Example: |
| 16 |
|
| 17 |
$ sudo ./flashbench -a /dev/mmcblk0 --blocksize=1024 |
| 18 |
align 134217728 pre 735µs on 1.08ms post 780µs diff 324µs |
| 19 |
align 67108864 pre 736µs on 1.05ms post 763µs diff 300µs |
| 20 |
align 33554432 pre 722µs on 1.04ms post 763µs diff 294µs |
| 21 |
align 16777216 pre 727µs on 1.05ms post 772µs diff 302µs |
| 22 |
align 8388608 pre 724µs on 1.04ms post 768µs diff 299µs |
| 23 |
align 4194304 pre 741µs on 1.08ms post 788µs diff 317µs |
| 24 |
align 2097152 pre 745µs on 950µs post 811µs diff 171µs |
| 25 |
align 1048576 pre 745µs on 945µs post 807µs diff 169µs |
| 26 |
align 524288 pre 743µs on 936µs post 799µs diff 165µs |
| 27 |
align 262144 pre 746µs on 948µs post 809µs diff 171µs |
| 28 |
align 131072 pre 737µs on 935µs post 804µs diff 165µs |
| 29 |
align 65536 pre 735µs on 925µs post 796µs diff 159µs |
| 30 |
align 32768 pre 735µs on 925µs post 800µs diff 157µs |
| 31 |
align 16384 pre 745µs on 911µs post 781µs diff 148µs |
| 32 |
align 8192 pre 785µs on 808µs post 725µs diff 53.3µs |
| 33 |
align 4096 pre 784µs on 788µs post 779µs diff 5.85µs |
| 34 |
align 2048 pre 787µs on 793µs post 789µs diff 4.65µs |
| 35 |
|
| 36 |
This shows the access times to do two 1024 byte reads around |
| 37 |
the boundaries of power-of-two aligned blocks. Reading at |
| 38 |
the end of a 128 MB unit takes around 735 microseconds, reading x |
| 39 |
the last block of this unit together with the first block of |
| 40 |
the next one takes about 1080 microseconds and reading the first |
| 41 |
two blocks in a 128 MB unit takes around 780 microseconds. |
| 42 |
|
| 43 |
The most interesting number here is the last one, the difference |
| 44 |
between the second number and the average of the first and the third |
| 45 |
is 324 microseconds. These numbers all stay roughly the same for |
| 46 |
all units between 4 MB and 128 MB. |
| 47 |
|
| 48 |
However, from 2 MB down to 16 KB, the last column has a much lower |
| 49 |
value. This indicates that whatever the memory card does on a 4 MB |
| 50 |
boundary does not happen at other boundaries. The educated guess |
| 51 |
here is that 4 MB is the erase block size, also called the segment |
| 52 |
or allocation unit size. This erase blocksize will need to be |
| 53 |
used in other tests following this one. |
| 54 |
|
| 55 |
Similarly, both 16 KB and 8 KB boundaries are special. The logical |
| 56 |
explanation for this is that the card has 8 KB pages, but can use |
| 57 |
multi-plane accesses to read two 8 KB pages simultaneously. |
| 58 |
|
| 59 |
Some cards only show a clear pattern using accesses with certain |
| 60 |
block sizes, other cards do not show any pattern, which means |
| 61 |
that the numbers need to be determined differently. |
| 62 |
|
| 63 |
Also, cards that were never fully written may show a different |
| 64 |
behaviour because access times on pre-erased segments are different |
| 65 |
from those that have been written. |
| 66 |
|
| 67 |
== Create a scatter plot of access times == |
| 68 |
|
| 69 |
''flashbench -s <device> --scatter-order=<n> --scatter-span=<m> -o <file>'' |
| 70 |
|
| 71 |
Writes a scatter plot into a file that can be used as input |
| 72 |
for a ''gnuplot -p -e 'plot "file"' '' |
| 73 |
|
| 74 |
== Finding the number of open erase blocks == |
| 75 |
|
| 76 |
''flashbench --open-au <device> --open-au-nr=<nr> --erasesize=<size> [--random]'' |
| 77 |
|
| 78 |
Example: |
| 79 |
|
| 80 |
$ sudo ./flashbench -O --erasesize=$[4 * 1024 * 1024] \ |
| 81 |
--blocksize=$[256 * 1024] /dev/mmcblk0 --open-au-nr=2 |
| 82 |
4MiB 8.79M/s |
| 83 |
2MiB 7.41M/s |
| 84 |
1MiB 6.87M/s |
| 85 |
512KiB 6.39M/s |
| 86 |
256KiB 6.27M/s |
| 87 |
$ sudo ./flashbench -O --erasesize=$[4 * 1024 * 1024] \ |
| 88 |
--blocksize=$[256 * 1024] /dev/mmcblk0 --open-au-nr=3 |
| 89 |
4MiB 7.75M/s |
| 90 |
2MiB 5.03M/s |
| 91 |
1MiB 3.24M/s |
| 92 |
512KiB 1.76M/s |
| 93 |
256KiB 912K/s |
| 94 |
|
| 95 |
In this case, trying 2 open AUs shows fast accesses for small |
| 96 |
block sizes, but trying 3 open AUs is much slower, and degrades |
| 97 |
further at smaller sizes. |
| 98 |
|
| 99 |
Try varying numbers until hitting the cut-off point. |
| 100 |
For cards that are fast when using --random, this will find |
| 101 |
the cut-off more reliably. |
| 102 |
|
| 103 |
Some cards can do more open segments in linear mode than they |
| 104 |
can in random mode. |
| 105 |
|
| 106 |
== References == |
| 107 |
|
| 108 |
[1] https://wiki.linaro.org/WorkingGroups/KernelConsolidation/Projects/FlashCardSurvey |
| 109 |
[2] git clone git://git.linaro.org/people/arnd/flashbench.git |
| •110 |
[3] http://lwn.net/Articles/428584 |
| 111 |
|
| 112 |
Feel free to reach the author by email for any questions |
| 113 |
about the latest version, Arnd Bergmann <[email protected]>, |
| 114 |
or use the [email protected] mailing list for discussions. |
| 115 |
|
| 116 |
If you use this tool to measure memory cards, USB sticks |
| 117 |
or SSDs and get useful results, please share them |
| 118 |
at [email protected]. |