WindowsX
Member of the Trade: Fidelizer Audio
- Joined
- Apr 27, 2007
- Posts
- 1,962
- Likes
- 369
Since @Lurker0 demanded for my explanation and I don't want to derail the discussion in main DX90 topic any further, I decided to start a new topic here so people who're interested in modding firmware can discuss without disturbing ordinary users.
To make it simpler to understand, I decided to build a firmware without adding or removing any single line of tweak this time so you'll see the changes clearly. I'll use only existing configuration in original DX90 firmware and only main boot configuration from kernel image and build configuration from main ROM files that'll be optimized. Let's see how far we can go. I'll start with DX90 first.
I'll start modding from line to line below with some brief explanation. I'll explain with assumptions that you already understand each configuration so please do your homework by studying what each one does by yourself because explaining every one of them will take forever to finish this post.
First, I'll start with main boot configuration file from kernel image. Here we go!
Now let's see how build configuration file from ROM image looks like.
Though it's not even half of what I usually did but looks like I've done more than I imagined before starting this project. Right now I'm kinda busy so I'll dig up DX50 firmware some other time. There's still a lot more to be done with recent 2.2.0 firmware such as new parameters and init.d scripts, etc. but for now it should be enough to prove that you can still do more with 2.2.0 firmware.
I don't know how much of my explanation will reach you guys, I'm not really good at it. I hope you'll consider your listening experience with my modified ROM as means to evaluate the changes I made. And no matter how senseless my tweaks may seem to be, it's my opinion and mine alone. It's my decision to configure it this way and please respect my opinion and my work being shared here.
http://www.mediafire.com/download/wy8pvbfhbbr4351
To make it simpler to understand, I decided to build a firmware without adding or removing any single line of tweak this time so you'll see the changes clearly. I'll use only existing configuration in original DX90 firmware and only main boot configuration from kernel image and build configuration from main ROM files that'll be optimized. Let's see how far we can go. I'll start with DX90 first.
I'll start modding from line to line below with some brief explanation. I'll explain with assumptions that you already understand each configuration so please do your homework by studying what each one does by yourself because explaining every one of them will take forever to finish this post.
First, I'll start with main boot configuration file from kernel image. Here we go!
write /proc/cpu/alignment 4 >> 0
Since mango is only running process and not likely to be killed off, setting to 0 make it does nothing which isn't anything about the sound but I prefer it this way personally.
write /proc/sys/kernel/sched_latency_ns 10000000 >> 1500000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 >> 30000
I normally set sched_latency_ns to 1000000 and leave sched_min_granularity_ns with 100000. According to the rule, I can't set the latter so let's leave it at that for MangoPlayer being only process.
write /proc/sys/kernel/sched_compat_yield 1 >> 0
Setting to 0 will make process running in completely fair scheduler having each CPU running at 50% rather than 99% in one core. That should help handling I/O operations better and reduce weird stabilty issues.
write /proc/sys/kernel/randomize_va_space 2 >> 0
This will disable ASLR meaning no more randomized virtual address. Since this is DAP with only mango running, disabling it for static mapping is better for performance-wise, no matter how small it is.
write /proc/sys/kernel/kptr_restrict 2 >> 0
This will disable kernel pointer's restriction. Disabling it makes kernel pointers work with less instructions without going through restriction check.
write /proc/sys/kernel/dmesg_restrict 1 >> 0
This will allow non-admin level user to read messages. Might be useful in future but not really matter.
write /proc/sys/vm/mmap_min_addr 32768 >> 4096
I tuned this value down for mapping address block at 4096 instead of every 32768 for less overhead. I'm bufferless fan and hate to see large overhead.
write /proc/sys/kernel/sched_rt_runtime_us 950000 >> -1
write /proc/sys/kernel/sched_rt_period_us 1000000 >> 10000
write /dev/cpuctl/cpu.shares 1024
write /dev/cpuctl/cpu.rt_runtime_us 950000 >> -1
write /dev/cpuctl/cpu.rt_period_us 1000000 >> 10000
write /dev/cpuctl/apps/cpu.shares 1024
write /dev/cpuctl/apps/cpu.rt_runtime_us 800000 >> -1
write /dev/cpuctl/apps/cpu.rt_period_us 1000000 >> 10000
write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000 >> -1
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000 >> 10000
Runtime tasks will work without reserving percentage for lower priority. I also reduced period size to smallest possible at 10000. This makes kernel resource utilization becoming more linear for better audio performance.
write /proc/sys/vm/min_free_order_shift 4 >> 1
Since DX90 doesn't run with large order of chunks like server scale, setting to 1 will improve allocation times.
write /proc/sys/vm/dirty_expire_centisecs 200 >> 6000
write /proc/sys/vm/dirty_background_ratio 5 >> 30
Increase dirty expiration to 1 minute and increase background ratio for longer idle time and less battery consumption.
service console /system/bin/sh
class core
console
disabled
user shell >> root
Changing user to root will allow shell command to run as root. init.d script works better with root access.
service vold /system/bin/vold
class core
socket vold stream 0660 root mount
ioprio be 2 >> ioprio rt 2
Improving volume storage service performance by changing itd I/O priority to real-time scheduiling category with order 2 (after MangoPlayer/usbhifi).
service mango /system/bin/MangoPlayer
class main
user root
group audio graphics
ioprio rt 4 >> ioprio rt 0
Increase priority of MangoPlayer to highest order 0. That should be better.
service usbd /system/bin/usbhifi
class main
user root
group audio graphics
ioprio rt 4 >> ioprio rt 1
Increase priority of MangoPlayer to order 1 (after MangoPlayer).
Since mango is only running process and not likely to be killed off, setting to 0 make it does nothing which isn't anything about the sound but I prefer it this way personally.
write /proc/sys/kernel/sched_latency_ns 10000000 >> 1500000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 >> 30000
I normally set sched_latency_ns to 1000000 and leave sched_min_granularity_ns with 100000. According to the rule, I can't set the latter so let's leave it at that for MangoPlayer being only process.
write /proc/sys/kernel/sched_compat_yield 1 >> 0
Setting to 0 will make process running in completely fair scheduler having each CPU running at 50% rather than 99% in one core. That should help handling I/O operations better and reduce weird stabilty issues.
write /proc/sys/kernel/randomize_va_space 2 >> 0
This will disable ASLR meaning no more randomized virtual address. Since this is DAP with only mango running, disabling it for static mapping is better for performance-wise, no matter how small it is.
write /proc/sys/kernel/kptr_restrict 2 >> 0
This will disable kernel pointer's restriction. Disabling it makes kernel pointers work with less instructions without going through restriction check.
write /proc/sys/kernel/dmesg_restrict 1 >> 0
This will allow non-admin level user to read messages. Might be useful in future but not really matter.
write /proc/sys/vm/mmap_min_addr 32768 >> 4096
I tuned this value down for mapping address block at 4096 instead of every 32768 for less overhead. I'm bufferless fan and hate to see large overhead.
write /proc/sys/kernel/sched_rt_runtime_us 950000 >> -1
write /proc/sys/kernel/sched_rt_period_us 1000000 >> 10000
write /dev/cpuctl/cpu.shares 1024
write /dev/cpuctl/cpu.rt_runtime_us 950000 >> -1
write /dev/cpuctl/cpu.rt_period_us 1000000 >> 10000
write /dev/cpuctl/apps/cpu.shares 1024
write /dev/cpuctl/apps/cpu.rt_runtime_us 800000 >> -1
write /dev/cpuctl/apps/cpu.rt_period_us 1000000 >> 10000
write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000 >> -1
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000 >> 10000
Runtime tasks will work without reserving percentage for lower priority. I also reduced period size to smallest possible at 10000. This makes kernel resource utilization becoming more linear for better audio performance.
write /proc/sys/vm/min_free_order_shift 4 >> 1
Since DX90 doesn't run with large order of chunks like server scale, setting to 1 will improve allocation times.
write /proc/sys/vm/dirty_expire_centisecs 200 >> 6000
write /proc/sys/vm/dirty_background_ratio 5 >> 30
Increase dirty expiration to 1 minute and increase background ratio for longer idle time and less battery consumption.
service console /system/bin/sh
class core
console
disabled
user shell >> root
Changing user to root will allow shell command to run as root. init.d script works better with root access.
service vold /system/bin/vold
class core
socket vold stream 0660 root mount
ioprio be 2 >> ioprio rt 2
Improving volume storage service performance by changing itd I/O priority to real-time scheduiling category with order 2 (after MangoPlayer/usbhifi).
service mango /system/bin/MangoPlayer
class main
user root
group audio graphics
ioprio rt 4 >> ioprio rt 0
Increase priority of MangoPlayer to highest order 0. That should be better.
service usbd /system/bin/usbhifi
class main
user root
group audio graphics
ioprio rt 4 >> ioprio rt 1
Increase priority of MangoPlayer to order 1 (after MangoPlayer).
Now let's see how build configuration file from ROM image looks like.
ro.build.display.id=rk3026-eng 4.2.2 JDQ39 eng.liuwenlong.20140123.133948 test-keys >> DX90 - Fidelity Edition LITE by Windows X
Since I won't add any lines at all, spare me one line for making note to know it's my tuned ROM here.
dalvik.vm.heapstartsize=5m >> 8m
dalvik.vm.heapgrowthlimit=48m >> 32m
dalvik.vm.heapsize=256m
dalvik.vm.heaptargetutilization=0.75
dalvik.vm.heapminfree=512k >> 256k
dalvik.vm.heapmaxfree=2m >> 1m
Tuned Dalvik heap size for better allocation balancing in DX90. Some what affect sonic performance.
persist.usb.debug=0 >> 1
Enable USB debugging. I usually enable it on my devices so I'll do with DX90 as well.
dalvik.vm.dexopt-flags=m=y >> v=n,o=v,u=n,m=n
Optimize dalvik flags for no verification/optimization applied. Pure solid performance is way to go.
Since I won't add any lines at all, spare me one line for making note to know it's my tuned ROM here.
dalvik.vm.heapstartsize=5m >> 8m
dalvik.vm.heapgrowthlimit=48m >> 32m
dalvik.vm.heapsize=256m
dalvik.vm.heaptargetutilization=0.75
dalvik.vm.heapminfree=512k >> 256k
dalvik.vm.heapmaxfree=2m >> 1m
Tuned Dalvik heap size for better allocation balancing in DX90. Some what affect sonic performance.
persist.usb.debug=0 >> 1
Enable USB debugging. I usually enable it on my devices so I'll do with DX90 as well.
dalvik.vm.dexopt-flags=m=y >> v=n,o=v,u=n,m=n
Optimize dalvik flags for no verification/optimization applied. Pure solid performance is way to go.
Though it's not even half of what I usually did but looks like I've done more than I imagined before starting this project. Right now I'm kinda busy so I'll dig up DX50 firmware some other time. There's still a lot more to be done with recent 2.2.0 firmware such as new parameters and init.d scripts, etc. but for now it should be enough to prove that you can still do more with 2.2.0 firmware.
I don't know how much of my explanation will reach you guys, I'm not really good at it. I hope you'll consider your listening experience with my modified ROM as means to evaluate the changes I made. And no matter how senseless my tweaks may seem to be, it's my opinion and mine alone. It's my decision to configure it this way and please respect my opinion and my work being shared here.
http://www.mediafire.com/download/wy8pvbfhbbr4351