[Miscellaneous Android Development] h33x:
File system tuning results

So, I finished some tests and can share results.

All tests about filesystem speed on differents modes.

Warning:

1) If one or more commands on backup stage returned error and you don't understand, that it mean - don't run next commands.

2) boot image for MOKEE OS, no more. Changed fstab data and init.huawei.rc scripts.

If you have another version OS - don't worry, tune2fs params applied automated after restart.

About hardware: On phone used emmc memory, that provide only 512 bytes interface and background parameters like as NAND operation block size and erase block size I can't found on datasheets. May be I can compile and run flashbench utility and solve this question.

Standard parameters after any wipe or restore or install ZIP operation is:

~ # tune2fs -l /dev/block/mmcblk0p13
tune2fs 1.41.14 (22-Dec-2010)
Filesystem volume name: <none>
Last mounted on: /data
Filesystem UUID: 57f8f4bc-abf4-655f-bf67-946fc0f9f25b
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode filetype extent sparse_super large_file uninit_bg
Filesystem flags: unsigned_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Remount read-only
Filesystem OS type: Linux
Inode count: 65536
Block count: 262140
Reserved block count: 0
Free blocks: 10967
Free inodes: 62768
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 63
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
__bionic_open_tzdata: couldn't find any tzdata when looking for localtime!
__bionic_open_tzdata: couldn't find any tzdata when looking for GMT!
__bionic_open_tzdata: couldn't find any tzdata when looking for posixrules!
Last mount time: Wed Jan 7 11:48:50 2015
Last write time: Wed Jan 7 11:54:53 2015
Mount count: 4
Maximum mount count: -1
Last checked: Thu Jan 1 00:00:00 1970
Check interval: 0 (<none>)
Lifetime writes: 1485 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size:	256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: tea
Journal backup: inode blocks

mount params

/dev/block/mmcblk0p13 on /data type ext4 (rw,seclabel,noatime,user_xattr,barrier=1,data=ordered)

test script from https://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/ with my small adaptation to busybox utils.

# cat /tmp//test.sh
#!/sbin/sh
echo "test started"
sync
echo "Big file write"
time dd if=/dev/zero of=big bs=1024 count=131072 2>>log; sync
ping -q -c 15 127.0.0.1
time /tmp/small.sh 2>>log

# cat /tmp/small.sh
#!/sbin/sh
for item in `seq 1 1024`
do
sync
dd if=/dev/zero of=test.$item bs=1024 count=16
sync
done

All test results:

1) test with standard (TWRP) params:

Mount params:

/dev/block/mmcblk0p13 on /data type ext4 (rw,seclabel,noatime,user_xattr,barrier=1,data=ordered)

Test results:

Large file:

real	0m 10.68s

user	0m 0.07s

sys	0m 2.00s

Small files:

real	0m 47.19s

user	0m 0.63s

sys	0m 2.57s

2) Test /data filesystem with tuned params:

without journal

without barriers

with small block size

/tmp/mkfs.ext4 -O ^ext_attr,^has_journal,^huge_file -b 1024 -m 0 -F /dev/block/mmcblk0p13

mount -t ext4 -o noatime,nodiratime,rw,seclabel,user_xattr,barrier=0,data=writeback /dev/block/mmcblk0p13 /data

Results:

Large file:

real	0m 12.59s

user	0m 0.08s

sys	0m 1.57s

Small files:

real	0m 40.74s

user	0m 0.42s

sys	0m 2.63s

Hmm. Not better.

3) Test with small blocks, with barrier.

mount -t ext4 -o noatime,nodiratime,rw,seclabel,user_xattr,barrier=1,data=writeback /dev/block/mmcblk0p13 /data

Test results:

Large file:

real	0m 12.71s

user	0m 0.06s

sys	0m 1.53s

Small files:

real	0m 41.19s

user	0m 0.53s

sys	0m 2.98s

4)

Test it again with 4096 block size

/tmp/mkfs.ext4 -O ^ext_attr,^has_journal,^huge_file -b 4096 -m 0 -F /dev/block/mmcblk0p13

mount -t ext4 -o noatime,nodiratime,rw,seclabel,user_xattr,barrier=0,data=writeback /dev/block/mmcblk0p13 /data

Large file:

real	0m 6.63s

user	0m 0.09s

sys	0m 2.07s

Small files:

real	0m 38.99s

user	0m 0.55s

sys	0m 2.34s

5) test with barrier

mount -t ext4 -o noatime,nodiratime,rw,seclabel,user_xattr,barrier=1,data=writeback /dev/block/mmcblk0p13 /data

Large file:

real	0m 9.44s

user	0m 0.09s

sys	0m 1.54s

Small files:

real	0m 48.61s

user	0m 0.63s

sys	0m 3.87s

6) Try to test with very big blocks - unfortunately impossible.

/tmp/mkfs.ext4 -O ^ext_attr,^has_journal,^huge_file -b 8192 -m 0 -F /dev/block/mmcblk0p13

Warning: blocksize 8192 not usable on most systems.

mke2fs 1.41.12 (17-May-2010)

Warning: 8192-byte blocks too big for system (max 4096), forced to continue

warning: 16 blocks unused.

And don't mount.

7) - Variants of best result ( test 4), commit=15

real	0m 12.06s

user	0m 0.15s

sys	0m 2.03s

real	0m 39.46s

user	0m 0.55s

sys	0m 2.38s

8) - Variant of test 4, commit=1

real	0m 9.34s

user	0m 0.08s

sys	0m 1.52s

real	0m 38.97s

user	0m 0.54s

sys	0m 2.41s

Best params:

4096 bytes on block, no journal, no barrier.

Some mounting parames don't provide better results.

So, I see on every test results, that when script write small files FS speed is non linear and I create a graph (on attachments).

What you think about? I guess, that this a block aligment problem (or phone's memory chip end of life).

Result actions:

all commands run over adb in recovery mode.

0) prepare (on host)

- unzip repartition.zip and send utils to temp

on host:

adb push ./mkfs.ext4 /tmp/
adb push ./fsck.ext4 /tmp/

on phone:

chmod +x /tmp/mkfs.ext4
chmod +x /tmp/fsck.ext4

All commands below running on phone.

1) backup:

/tmp/fsck.ext4 -p /dev/block/mmcblk0p13
mount -t ext4 /dev/block/mmcblk0p13 /data
tar -cpvf /sdcard/TWRP/BACKUPS/data.tar /data

2) re-format

2.1 - data

umount /data
/tmp/mkfs.ext4 -O ^ext_attr,^has_journal,^huge_file -b 4096 -L DATA -m 0 -F /dev/block/mmcblk0p13
tune2fs -e continue -o ^user_xattr,journal_data_writeback,nobarrier,nodelalloc /dev/block/mmcblk0p13

2.2 - cache

umount /cache
/tmp/mkfs.ext4 -O ^ext_attr,^has_journal,^huge_file -b 4096 -m 0 -F /dev/block/mmcblk0p6
tune2fs -e continue -o ^user_xattr,journal_data_writeback,nobarrier,nodelalloc /dev/block/mmcblk0p6

3) change boot image

mount -t vfat /dev/block/mmcblk0p1 /boot

On PC:

adb push ./boot.img /boot/image/

On phone:

umount /boot

4) restore data (run on / of FS)

mount -t ext4 /dev/block/mmcblk0p13 /data
tar -xvf /sdcard/TWRP/BACKUPS/data.tar
umount /data

Now all done, reboot phone.