User:Arete74
Boot Android from sdcard
Android partionio 4.2
df output
Filesystem Size Used Free Blksize /cub/block 395M 0K 395M 4096 /dev 396M 32K 396M 4096 /mnt/secure 396M 0K 396M 4096 /mnt/asec 396M 0K 396M 4096 /mnt/obb 396M 0K 396M 4096 /system 503M 430M 73M 4096 /tmp 396M 0K 396M 4096 /data 1007M 156M 851M 4096 /cache 314M 5M 309M 4096 /mnt/private 15M 8K 15M 4096 /mnt/sdcard 1G 64K 1G 4096 /mnt/secure/asec: Permission denied
mount output
rootfs / rootfs rw 0 0 devtmpfs /cub/block devtmpfs rw,relatime,size=404692k,nr_inodes=101173,mode=755 0 0 tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0 devpts /dev/pts devpts rw,relatime,mode=600 0 0 proc /proc proc rw,relatime 0 0 sysfs /sys sysfs rw,relatime 0 0 none /acct cgroup rw,relatime,cpuacct 0 0 tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0 tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0 tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0 none /dev/cpuctl cgroup rw,relatime,cpu 0 0 /dev/block/system /system ext4 rw,nodev,noatime,nobarrier,data=ordered 0 0 tmpfs /tmp tmpfs rw,relatime,mode=755,gid=1000 0 0 /dev/block/data /data ext4 rw,nosuid,nodev,noatime,journal_checksum,noauto_da_alloc,data=ordered 0 0 /dev/block/cache /cache ext4 rw,nosuid,nodev,noatime,journal_checksum,noauto_da_alloc,data=ordered 0 0 /dev/block/private /mnt/private vfat rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=continue 0 0 /dev/block/vold/93:80 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,noatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=continue 0 0 /dev/block/vold/93:80 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,noatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=continue 0 0 tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
Optimize sdcard partition
http://docs.pikatech.com/display/DEV/Optimizing+File+System+Parameters+of+SD+card+for+use+on+WARP+V3
http://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/
http://www.thomas-krenn.com/en/wiki/Partition_Alignment#fdisk_from_Version_2.17.1
Determine parameters of SD card
Now we need wish to determine the parameters of the SD card with FlashBench tool. It get be download it and compile it using the following instructions:
git clone git://git.linaro.org/people/arnd/flashbench.git cd flashbench make
For determine the parameters execute the flashbench using the following command line:
./flashbench -a /dev/mmcblk0 --blocksize=1024
align 2147483648 pre 1.47ms on 1.98ms post 1.68ms diff 407µs align 1073741824 pre 1.45ms on 2ms post 1.67ms diff 441µs align 536870912 pre 1.36ms on 1.91ms post 1.68ms diff 390µs align 268435456 pre 1.35ms on 1.91ms post 1.67ms diff 393µs align 134217728 pre 1.36ms on 1.92ms post 1.68ms diff 399µs align 67108864 pre 1.33ms on 1.91ms post 1.69ms diff 401µs align 33554432 pre 1.36ms on 1.93ms post 1.69ms diff 401µs align 16777216 pre 1.36ms on 1.9ms post 1.69ms diff 378µs align 8388608 pre 1.35ms on 1.92ms post 1.68ms diff 402µs align 4194304 pre 1.36ms on 1.91ms post 1.69ms diff 388µs align 2097152 pre 1.6ms on 1.93ms post 1.76ms diff 252µs align 1048576 pre 1.59ms on 1.91ms post 1.74ms diff 244µs align 524288 pre 1.56ms on 1.94ms post 1.76ms diff 280µs align 262144 pre 1.59ms on 1.92ms post 1.74ms diff 258µs align 131072 pre 1.55ms on 1.93ms post 1.74ms diff 283µs align 65536 pre 1.59ms on 1.92ms post 1.73ms diff 265µs align 32768 pre 1.56ms on 1.89ms post 1.68ms diff 269µs align 16384 pre 1.58ms on 1.89ms post 1.69ms diff 261µs align 8192 pre 1.38ms on 1.91ms post 1.81ms diff 314µs align 4096 pre 1.57ms on 1.58ms post 1.55ms diff 23.8µs align 2048 pre 1.65ms on 1.65ms post 1.61ms diff 23.4µs
The most interesting parts of this result is that the diff changes drastically at two points:
- from 4194304 (4MB) to 2097152 (2MB). Based on the example readme in flashbench, this indicates that there was no performance overhead reading two blocks over the 2MB boundary, but there was for 4MB boundary. The guess then, is that the erasure block is 4MB large on the sd-card.
- At 8192 (8kB).
We can determine two things from this.
- Ext4 should have a block size of 4k, and the “stride” value should be 2. This will cause ext4 to think that units of 2 blocks (8k) can and should be treated as one.
- Ext4 should have the stripe-size set to 256. This value was calculated by taking 2M (guessed erasure block size) dividing by 8K (size of a stride, 2 times block size (4K)). This should cause ext4 to try to align writes so that erasure blocks are written continuously and make it avoid sub-block updates.
- BLOCK_ERASURE = 4194304 il piu grande valore per il quale il tempo diventa vicino al doppio di quello precedente
- BLOCK_SIZE(PAGE_SIZE) = 4096 il piu' piccolo valore per il quale il tempo diventa significamente superiore al precedente
- ALIGN_PARTITION = $BLOCK_ERASURE/512 = 8192
- prima part 64M 65536 block
- seconda part 1G=1024*1000/$ALIGN_PARTITION=125 parte intera
- 2_BLOCK_SIZE=125*$ALIGN_PARTITION -1
Device Boot Start End Blocks Id System /dev/mmcblk0p1 8192 73727 65535 83 Linux /dev/mmcblk0p2 73728 7268351 2097152 83 Linux
Format with ext4 fs
EXT4_STRIPSIZE=$BLOCK_ERASURE/$BLOCK_SIZE=4194304 / 4096 = 1024
- fdisk -lu disk
- start block delle partizioni deve essere divisibile per BLOCK_ALIGN
mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=$EXT4_STRIPSIZE -b 4096 /dev/mmcblk0p1
UUID=<some_long_uuid_number> / ext4 errors=remount-ro,noatime,nodiratime 0 1 elevator=noop
Benchmark
Optimze partition
Big file
sync; rm -f bigfile; sync; time ( dd if=/dev/zero of=bigfile bs=16k count=10000; sync) ;
10000+0 records in 10000+0 records out 163840000 bytes (164 MB) copied, 5.22952 s, 31.3 MB/s
real 0m15.791s user 0m0.010s sys 0m0.680s
small files
sync; rm -rf smallfiles_*; sync; time ( for i in `seq 1 100`; do dd if=/dev/zero of=smallfiles_$i bs=16k count=10; sync; done; ) ; rm -rf smallfiles_*
10+0 records in 10+0 records out 163840 bytes (164 kB) copied, 0.00119938 s, 137 MB/s
real 0m12.759s user 0m0.040s sys 0m0.120s
normal part
Big file
10000+0 records in 10000+0 records out 163840000 bytes (164 MB) copied, 13.2991 s, 12.3 MB/s real 0m18.182s user 0m0.030s sys 0m0.760s
small files
10+0 records out 163840 bytes (164 kB) copied, 0.00121955 s, 134 MB/s
real 0m25.218s user 0m0.060s sys 0m0.100s