[Miscellaneous Android Development] h33x:
Hi all!

Now I have a bit of free time and can write about small tuning.

Before story:

Some time ago I read about updates and try Dirty_Unicorn and CyanogenMod with app2sd fixes. Dirty unicorn - is most faster ROM, that I tried on last year. But I can't install Gapps on it and burn last CM.

(DU has bootloop after install any compatible Gapps from DU dev thread)

Before I burn last CM, I applied repartition script from this thread (Thanks for this script to author!).

And I have the pain instead using my phone.

What happend? - phone was work deadly slow. 1 minute for Hangout start, keyboard write messages AFTER 15 seconds when I type it and more. I can't use Firefox app, because app was killed by watchdog after, that init process be done.

What occured inside phone? - I turn on system resources graph on "Developers options" and see, that any "heavy" application generate IOwaits processor queue before crashed. The "top" utility says, that IOW percentage about 40 to 100%.

I suggest, that this sympthom is /data partition problems. (this partition changed when I burn repartition pack).

And that I see on mounts:

#> mount
#some skipped
/dev/block/mmcblk0p13 /data ext4 rw,seclabel,nosuid,nodev,noatime,user_xattr,barrier=1,data=ordered,noauto_da_alloc 0 0
/dev/block/mmcblk0p6 /cache ext4 rw,seclabel,nosuid,nodev,noatime,user_xattr,barrier=1,data=ordered 0 0

And on kernel params:

/ # cat /proc/sys/vm/dirty_writeback_centisecs
500
/ # cat /proc/sys/vm/dirty_expire_centisecs
500
/ # cat /proc/sys/vm/dirty_ratio
0

And on RC script I found

swapon_all /fstab.huawei

I think "Hmm... that is standard params with small performance tuning".

But me can't forget, that phone memory is SD like memory.

What happened, when phone work?

- any directory change transaction write in "diratime" parameter on FS metadata

- FS journal and data writes in parallel, that generate twice device IO operations

- kernel run write process (flush caches) every 500 milliseconds, that reduce IO operations, but disk speed becomes the bottleneck for performance

- if free memory above 0%, system run swap process

and some more.

How I solve this problem:

(I read many manuals and recomendations before, links to most important below.

https://source.android.com/devices/tech/low-ram.html

https://developer.ridgerun.com/wiki...nce_SD_card_tuning_using_the_EXT4_file_system

http://www.westnet.com/~gsmith/content/linux-pdflush.htm

http://www.raid6.com.au/posts/fs_ext4_external_journal/

https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout

http://elinux.org/images/b/b6/EMMC-SSD_File_System_Tuning_Methodology_v1.0.pdf

https://events.linuxfoundation.org/images/stories/pdf/lf_abs12_foy.pdf

)

I planned switch off journal for /cache, set mount options like this

/dev/block/mmcblk0p6 /cache ext4 noatime,nodiratime,nosuid,nodev,barrier=0,data=writeback,noauto_da_alloc,commit=300 wait,check
/dev/block/mmcblk0p13 /data ext4 noatime,nodiratime,nosuid,nodev,barrier=0,data=writeback,noauto_da_alloc,journal_async_commit,commit=120 wait,check

but, some parameters don't applied (I don't know why, may be desalesouche can help me with this question)

First, I download latest CM ROM zip and unpack it with Android Kitchen (https://github.com/dsixda/Android-Kitchen). All changes I make on boot.img file.

I tried to change fstab file. This action been senselessly, system don't change any parameter.

After I edit RC scripts.

On init.cm.rc I added

write /sys/kernel/mm/ksm/run 1
write /proc/sys/vm/dirty_writeback_centisecs 100
write /proc/sys/vm/dirty_expire_centisecs 100

commands.

On init.huawei.rc script I change mount instructions to

mount ext4 /dev/block/mmcblk0p13 /data nosuid nodev barrier=0 noauto_da_alloc nodiratime data=writeback commit=120 journal_async_commit
mount ext4 /dev/block/mmcblk0p6 /cache nosuid nodev barrier=0 noauto_da_alloc nodiratime data=writeback commit=300 journal_async_commit

And comment "swapon" instruction.

Note: instructions below may be carefully, because they change journaling logic and if system crashed or rebooted with battery remove, you can loss some data.

noauto_da_alloc

barrier=0

data=writeback

And I switch off journaling for /cache partition.

root@u8860:/ # tune2fs -O ^has_journal /dev/block/mmcblk0p6
tune2fs 1.41.14 (22-Dec-2010)
The needs_recovery flag is set. Please run e2fsck before clearing
the has_journal flag.

Now I have a very fast phone (I happy, really XD) and this mount options:

/dev/block/mmcblk0p13 /data ext4 rw,seclabel,nosuid,nodev,noatime,nodiratime,user_xattr,barrier=1,journal_async_commit,data=writeback 0 0
/dev/block/mmcblk0p6 /cache ext4 rw,seclabel,nosuid,nodev,noatime,nodiratime,user_xattr,barrier=1,journal_async_commit,data=ordered 0 0

I offer discuss this tuning way and have two questions:

1) why some ext4 parameters don't applied? They configured on boot image by default?

2) can I try to convert /data and /cache partitions to f2fs (kernel have f2fs driver?)