-
Notifications
You must be signed in to change notification settings - Fork 9
Tuning SD Card Speed
(provided by Fred777)
Many SD cards have fast sequential speed (20..90MB/s) but only slow random access performance. But for Android Apps running smoothly, random read / write performance with blocksize 4k is most important. You can check this on Windows with CrystalDiskMark (4k, QD=1) and on Linux with fio. Fio is also included with CM12.1 (/system/xbin/fio). For fio, use parameter sets fsync=1,size=32m,rw=randwrite and fsync=1,size=128m,rw=randread.
Some benchmark results:
Xperia Pro internal eMMC flash random 4k read, yaffs2: 4876KB/s
Xperia Pro internal eMMC flash random 4k write, yaffs2: 1987KB/s
Sandisk Ultra 32GB UHC-1 random 4k read, fat32: 3746KB/s
Sandisk Ultra 32GB UHC-1 random 4k read, ext4 : 2594KB/s
Sandisk Ultra 32GB UHC-1 random 4k write, fat32: 2095KB/s
Sandisk Ultra 32GB UHC-1 random 4k write, ext4 : 220KB/s
Samsung Evo+ 32GB UHC-1 random 4k read, fat32: 7450KB/s
Samsung Evo+ 32GB UHC-1 random 4k read, ext4 : 7400KB/s
Samsung Evo+ 32GB UHC-1 random 4k read, f2fs : 4900KB/s (on smartphone!)
Samsung Evo+ 32GB UHC-1 random 4k read, f2fs : 7960KB/s (on pc!)
Samsung Evo+ 32GB UHC-1 random 4k write, fat32: 4300KB/s
Samsung Evo+ 32GB UHC-1 random 4k write, ext4 : 1000KB/s
Samsung Evo+ 32GB UHC-1 random 4k write, f2fs : 820KB/s (on smartphone!)
Samsung Evo+ 32GB UHC-1 random 4k write, f2fs : 1704KB/s (on pc!)
In general, random write is slower on ext4 than on fat32 due to journaling and meta data.
You can check if your sdcard speed is a bottle neck as follows:
- run adb shell via USB
- invoke vmstat command and look at [wa] column
If [wa] is high during app usage / app start / whatever, your phone most probably is busy with sd card access.
If [us] or [sy] is high, your CPU is busy.
All of these value range from 0 to 100 while 100 meaning 100% load.
Also, when partitioning the SD card, proper partitition alignment is crucial. This involves making start sectors of all partitions divisible by erasure block size and adding stride / striping parameters on ext4 creation. Here you'll find some tutorials on this topic:
- https://wiki.gentoo.org/wiki/SDCard
- https://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/
- https://wiki.ubuntuusers.de/Installation_auf_Flashmedien
For a particular Samsung Evo+ 32GB UHC-1 card, erasure block size turned out to be 16MiB, i.e. stripe-width=2048
. The following partition layout turned out to be optimal:
Disk /dev/sdi: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdi1 8192 54132734 54099967 25.8G c W95 FAT32 (LBA)
/dev/sdi2 54132735 62521343 8388609 4G 83 Linux
According to the rule, start sector for partition 1 should have been 32768, but this resulted in slower fat32 random 4k write performance (3773KB/s instead of 4300KB/s).