Raspberry Piに増設したSDカードの速度を測る 1bitモードと4bitモードの比較
Raspberry Piに増設したSDカードのパフォーマンスをfioで測ってみました。
増設方法は以下で紹介しています。
tshell.hatenablog.com
実は前の記事のようにdtboファイルを作らなくても以下の設定を/boot/config.txtに追記するだけで使えました。
dtoverlay=sdio,poll_once=off,sdio_overclock=50
前回はbus_width=1
を指定して動作させ,とりあえず動いて喜んでいましたがこれを指定すると1bitモードで動作するようです。せっかくDAT0〜3まで結線しているのにDAT0しか使っていません。
今回はbus_width=1の指定を外してデフォルトの4bitモードで動作させ,どれくらい速度が違うのか測ってみます。
環境
以下のものを使用しました。
- Raspberry Pi Compute Module 3+(8GBモデル)
- Compute Module IO
- Raspbian Buster Lite
- MicroSDカード(SDSDQAF3-008G-I) datasheet
測り方
SDカードをマウントしたあと,fioを使用してSDカードへの書き込み速度を測ってみます。
以下のコマンドを実行します。
$ sudo mount -t ext4 /dev/mmcblk1 /mnt/sdcard $ fio -filename=/mnt/sdcard/test1g -direct=1 -rw=write -bs=4k -size=1G -name=file1
/mnt/sdcardに1GBのファイルをブロックサイズ4kBで書き込んでアクセス速度を測ります。
1bitモード
まずは/boot/config.txtへの追記内容を以下のようにしたときの速度を測ってみます。
dtoverlay=sdio,poll_once=off,bus_width=1,sdio_overclock=50
結果は以下のようになりました。
file1: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1 fio-3.12 Starting 1 process file1: Laying out IO file (1 file / 1024MiB) Jobs: 1 (f=1): [W(1)][100.0%][w=1628KiB/s][w=407 IOPS][eta 00m:00s] file1: (groupid=0, jobs=1): err= 0: pid=667: Mon Dec 2 04:37:06 2019 write: IOPS=406, BW=1626KiB/s (1665kB/s)(1024MiB/644787msec); 0 zone resets clat (usec): min=1602, max=20014, avg=2442.16, stdev=763.70 lat (usec): min=1603, max=20019, avg=2444.70, stdev=763.72 clat percentiles (usec): | 1.00th=[ 1926], 5.00th=[ 1975], 10.00th=[ 2040], 20.00th=[ 2073], | 30.00th=[ 2089], 40.00th=[ 2114], 50.00th=[ 2147], 60.00th=[ 2311], | 70.00th=[ 2507], 80.00th=[ 2900], 90.00th=[ 3064], 95.00th=[ 3294], | 99.00th=[ 3851], 99.50th=[ 9110], 99.90th=[10814], 99.95th=[11338], | 99.99th=[13042] bw ( KiB/s): min= 1552, max= 1736, per=100.00%, avg=1626.02, stdev=20.09, samples=1289 iops : min= 388, max= 434, avg=406.50, stdev= 5.02, samples=1289 lat (msec) : 2=8.00%, 4=91.17%, 10=0.61%, 20=0.22%, 50=0.01% cpu : usr=0.59%, sys=7.93%, ctx=265811, majf=0, minf=23 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued rwts: total=0,262144,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=1 Run status group 0 (all jobs): WRITE: bw=1626KiB/s (1665kB/s), 1626KiB/s-1626KiB/s (1665kB/s-1665kB/s), io=1024MiB (1074MB), run=644787-644787msec Disk stats (read/write): mmcblk1: ios=0/262310, merge=0/279, ticks=0/592877, in_queue=592690, util=91.91%
IOPS(1秒あたりのIO数)が406,アクセス速度は1665kB/sでした。
4bitモード
次に/boot/config.txtの追記内容を以下のようにして4bitモードでの速度を測ってみます。
dtoverlay=sdio,poll_once=off,sdio_overclock=50
結果は以下のようになりました。
file1: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1 fio-3.12 Starting 1 process Jobs: 1 (f=1): [W(1)][100.0%][w=2312KiB/s][w=578 IOPS][eta 00m:00s] file1: (groupid=0, jobs=1): err= 0: pid=530: Mon Dec 2 04:47:50 2019 write: IOPS=577, BW=2310KiB/s (2366kB/s)(1024MiB/453837msec); 0 zone resets clat (usec): min=921, max=21609, avg=1715.19, stdev=743.28 lat (usec): min=922, max=21611, avg=1717.64, stdev=743.29 clat percentiles (usec): | 1.00th=[ 1205], 5.00th=[ 1254], 10.00th=[ 1319], 20.00th=[ 1352], | 30.00th=[ 1369], 40.00th=[ 1385], 50.00th=[ 1418], 60.00th=[ 1582], | 70.00th=[ 1795], 80.00th=[ 2114], 90.00th=[ 2311], 95.00th=[ 2376], | 99.00th=[ 3228], 99.50th=[ 8029], 99.90th=[ 9503], 99.95th=[10159], | 99.99th=[11207] bw ( KiB/s): min= 2160, max= 2504, per=100.00%, avg=2310.03, stdev=34.79, samples=907 iops : min= 540, max= 626, avg=577.46, stdev= 8.71, samples=907 lat (usec) : 1000=0.01% lat (msec) : 2=75.77%, 4=23.49%, 10=0.68%, 20=0.06%, 50=0.01% cpu : usr=0.77%, sys=3.67%, ctx=263680, majf=0, minf=26 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued rwts: total=0,262144,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=1 Run status group 0 (all jobs): WRITE: bw=2310KiB/s (2366kB/s), 2310KiB/s-2310KiB/s (2366kB/s-2366kB/s), io=1024MiB (1074MB), run=453837-453837msec Disk stats (read/write): mmcblk1: ios=1/262264, merge=0/91, ticks=1/435935, in_queue=435340, util=95.99%
IOPSは577,アクセス速度は2366kB/sです。
まとめ
アクセス速度を比較すると1bitモードのとき1665kB/s,4bitモードのとき2366kB/sで,4bitモードにすると1.4倍ほど速くなります。
データシートにはシーケンシャル書き込みは最大50MB/sと書いてありますが,ブロックサイズを大きくすればこれくらい出るということかもしれません。