[REF] Startup script speed tweaks

Search This thread

[kab]

Senior Member
Jan 29, 2007
61
0
nope, "-l" (L) should not be used, it give you long output.
"-1" give 'one file per line' option, which did not supported (yet)
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
On my GNU/Linux system I've set vm.swappiness to 10, because I've got plenty MiB of RAM and I don't want my system to swap a lot. Is this swappiness the same as Linux? Because that would mean having the system to use more RAM, and since we don't have much of that available by default, I'm just surprised you didn't set a higher value. (I'm not saying you don't know what you're doing, I just want to learn how it works!)
By the way, this script is going to be a must-have, I think you've put an excellent effort on i9000 Android development! :) Thanks for sharing!
Hi. For vm.swappiness, a value of 0 means "do not swap unless out of free RAM", a value of 100 means "swap whenever possible". The default is 60 which is okay for normal Linux installations.

Swap = move portions of programs in RAM to disk (swap partition or file), to free up RAM so that more programs can run.

However Android by default doesn't have any swap partition or files (there is nowhere to swap to). It doesn't really need it though, since it has its own memory management system, so swap is never used. Nevertheless, I feel safer setting it to 0.
 
Last edited:

[kab]

Senior Member
Jan 29, 2007
61
0
quandart

anyone test IO benchmark in quadrant before and after applying this tweaks?
any change?
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
btw, "ls -1 /sys/block/mmc*" in adb give us:
Code:
ls -1 /sys/block/mmc*
-1: No such file or directory
/sys/block/mmcblk0
/sys/block/mmcblk1
so, "-1" key is useless
That's strange. Could be different busybox versions. I am using busybox 1.17. The idea is to get a list of directories. If that doesn't work, you can manually put in the list of correct devices.
 

[kab]

Senior Member
Jan 29, 2007
61
0
yes, quadrant is bull$hit for cpu (because it's mostly checking FPU performance, which rarely used in real life), but IO performance (just creating a lot of files or read/write some data from /dbdata) should be near to real usage...
 

thunderteaser

Senior Member
Jul 22, 2010
830
296
Hi. For vm.swappiness, a value of 0 means "do not swap unless out of free RAM", a value of 100 means "swap whenever possible". The default is 60 which is okay for normal Linux installations.

Swap = move portions of programs in RAM to disk (swap partition or file), to free up RAM so that more programs can run.

However Android by default doesn't have any swap partition or files (there is nowhere to swap to). It doesn't really need it though, since it has its own memory management system, so swap is never used. Nevertheless, I feel safer setting it to 0.

Thank you, it's clearer now! :) I didn't know that Android doesn't have a swap partition!
 

zenkinz

Senior Member
Apr 21, 2005
2,374
65
www.zenyee.com
That's strange. Could be different busybox versions. I am using busybox 1.17. The idea is to get a list of directories. If that doesn't work, you can manually put in the list of correct devices.

that's because the ls (and mount) commands are executed from /system/bin instead of /system/xbin, therefore the syntax and format of output is not supported.

either add PATH=/system/xbin:$PATH before the execution of rest of scripts, or add alias, e.g.

alias ls='/system/xbin/ls'
alias mount='/system/xbin/mount'

I put them into a script for downloadable..

edit: btw, I applied the tweak and it feels much snappier than before. Thanks!
 

Attachments

  • tweak.zip
    618 bytes · Views: 221
Last edited:

neldar

Retired Recognized Developer
Jul 4, 2010
569
363
twitter.com
I can confirm that the read/write performance to rfs partitions do increase by this.

From write 1,5 mb/s to 2,2 mb/s and read 55 mb/s to 86 mb/s.


test for write: dd if=/dev/zero of=/data/test count=30000
test for read: dd if=/data/test of=/dev/zero
 

[kab]

Senior Member
Jan 29, 2007
61
0
this script for sure should be reworked.
i have no /system/sbin/ls, only usual ls.
btw, "-1" option non required, because "ls" anyway print 1 file per line (at least at JP6 stock firmware).

second,
Code:
# mount | cut -d " " -f3
mount | cut -d " " -f3
rootfs
tmpfs
devpts
proc
sysfs
cgroup
j4fs
tmpfs
cgroup
rfs
rfs
rfs
rfs
rfs
vfat
vfat
vfat
tmpfs
#

and moreover, "mount" require "device" at JP6:
Code:
# mount -o remount,rw /system
mount -o remount,rw /system
Usage: mount [-r] [-w] [-o options] [-t type] device directory
#
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Code:
# mount | cut -d " " -f3
mount | cut -d " " -f3
rootfs
tmpfs
devpts
proc
sysfs
cgroup
j4fs
tmpfs
cgroup
rfs
rfs
rfs
rfs
rfs
vfat
vfat
vfat
tmpfs
I use busybox 1.17.
The expected output of the command should be:

mount | cut -d " " -f3
/
/dev
/dev/pts
/proc
/sys
/acct
/mnt/.lfs
/mnt/asec
/dev/cpuctl
/system
/data
/dbdata
/cache
/efs

You can also put in the names of the mount points manually.
 

trasig

Senior Member
Nov 29, 2009
273
137
kernel.1ug.org
theres no fstab in my JP6 so i cant really use the remount thing since need both device name and directory.. maybe use awk or sed instead of cut?
 

kenshinta

Senior Member
Dec 13, 2004
430
69
Redmi Note 10S
# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done


Does the above as-is run without issue on your phones? Cause the output I get are single line display of the files in the directory. I think expected behaviour is the directory itself?

Like:
NOW
Code:
adb shell ls -1 /sys/block/bml10
bdi
capability
dev
ext_range
holders
power
queue
range
removable
ro
size
slaves
stat
subsystem
uevent

SHOULD BE:
Code:
adb shell ls -d -1 /sys/block/bml*
/sys/block/bml0!c
/sys/block/bml1
/sys/block/bml10
/sys/block/bml2
/sys/block/bml3
/sys/block/bml4
/sys/block/bml5
/sys/block/bml6
/sys/block/bml7
/sys/block/bml8
/sys/block/bml9

in order to make the script work.

To do so I added " -d " to the ls command, ex. "ls -d -1 /sys/block/bml*"
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
theres no fstab in my JP6 so i cant really use the remount thing since need both device name and directory.. maybe use awk or sed instead of cut?
It doesn't need fstab to work. Maybe the output of your mount command is different? The idea is to get a list of all the mount points. Or just manually put them in.


Sent from my GT-I9000 using XDA App
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Does the above as-is run without issue on your phones? Cause the output I get are single line display of the files in the directory. I think expected behaviour is the directory itself?

Like:
NOW
Code:
adb shell ls -1 /sys/block/bml10
bdi
capability
dev
ext_range
holders
power
queue
range
removable
ro
size
slaves
stat
subsystem
uevent

SHOULD BE:
Code:
adb shell ls -d -1 /sys/block/bml*
/sys/block/bml0!c
/sys/block/bml1
/sys/block/bml10
/sys/block/bml2
/sys/block/bml3
/sys/block/bml4
/sys/block/bml5
/sys/block/bml6
/sys/block/bml7
/sys/block/bml8
/sys/block/bml9

in order to make the script work.

To do so I added " -d " to the ls command, ex. "ls -d -1 /sys/block/bml*"
That's the desired output. I think it's not running because u issued the command using adb.

Try
Adb shell
su



Sent from my GT-I9000 using XDA App
 

zenkinz

Senior Member
Apr 21, 2005
2,374
65
www.zenyee.com
because mount in /system/sbin has different output format than mount in /system/xbin (which is from busybox), and thereofre it appears to have wrong syntax when it's becasue the device is retrieved wrongly from the cut command.

use the script posted above, it'll work correctly.


this script for sure should be reworked.
i have no /system/sbin/ls, only usual ls.
btw, "-1" option non required, because "ls" anyway print 1 file per line (at least at JP6 stock firmware).

second,
Code:
# mount | cut -d " " -f3
mount | cut -d " " -f3
rootfs
tmpfs
devpts
proc
sysfs
cgroup
j4fs
tmpfs
cgroup
rfs
rfs
rfs
rfs
rfs
vfat
vfat
vfat
tmpfs
#

and moreover, "mount" require "device" at JP6:
Code:
# mount -o remount,rw /system
mount -o remount,rw /system
Usage: mount [-r] [-w] [-o options] [-t type] device directory
#
 

Top Liked Posts

  • There are no posts matching your filters.
  • 19
    Hi guys,

    UPDATE: Over time, I've modified some of these values in my SpeedMod kernel. The values here may not be the best ones.

    NOTE: These tweaks are now included in kernels based on sztupy's Universal Lagfix, for example:
    http://xdaforums.com/showthread.php?t=822756
    But they must be manually activated from the recovery menu.

    I've been using Linux kernel tweaks in a startup script to make the phone smoother.

    With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.

    These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.

    Code:
    # Tweak cfq io scheduler
    for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
    do echo "0" > $i/queue/rotational
    echo "1" > $i/queue/iosched/low_latency
    echo "1" > $i/queue/iosched/back_seek_penalty
    echo "1000000000" > $i/queue/iosched/back_seek_max
    echo "3" > $i/queue/iosched/slice_idle
    done
    # Remount all partitions with noatime
    for k in $(busybox mount | grep relatime | cut -d " " -f3)
    do
    sync
    busybox mount -o remount,noatime $k
    done
    
    # Tweak kernel VM management
    echo "0" > /proc/sys/vm/swappiness
    #echo "10" > /proc/sys/vm/dirty_ratio
    #echo "4096" > /proc/sys/vm/min_free_kbytes
    
    # Tweak kernel scheduler, less aggressive settings
    echo "18000000" > /proc/sys/kernel/sched_latency_ns
    echo "3000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
    echo "1500000" > /proc/sys/kernel/sched_min_granularity_ns
    
    # Misc tweaks for battery life
    echo "2000" > /proc/sys/vm/dirty_writeback_centisecs
    echo "1000" > /proc/sys/vm/dirty_expire_centisecs
    EDIT: Explanations:

    # Remount all partitions with noatime
    atime is a setting where the filesystem updates the access time of a file. This creates a write-after-every-read which slows things down. By default all partitions are mounted with relatime, which is an optimized version of atime. noatime is the fastest, and afaik we don't need atime.

    # Tweak cfq io scheduler
    Tweaked settings of the disk io scheduler more for flash memory. Defaults are optimized for spinning harddisks. Lowered the idle wait, re-enable the low latency mode of cfq, removed the penalty for back-seeks and explicitly tell the kernel the storage is not a spinning disk.

    # Tweak kernel VM management
    Set tendency of kernel to swap to minimum, since we don't use swap anyway.
    Lower the amount of unwritten write cache to reduce lags when a huge write is required.
    Increase tendency of kernel to keep block-cache to help with slower RFS filesystem.
    Increase minimum free memory, in theory this should make the kernel less likely to suddenly run out of memory.

    # Tweak kernel scheduler
    Make the task scheduler more 'fair' when multiple tasks are running. This has a huge effect on UI and App responsiveness. These values (less aggressive settings) are 20% of the Linux defaults, and about half of the Android defaults.

    # Miscellaneous tweaks
    Increase the write flush timeouts to save some battery life.

    ___________________________________

    EDIT: How to create/use a startup script:

    You need root and busybox for this.

    This procedure is adapted from the old OCLF which used this method to create a startup script in /system/userinit.sh

    Check if the file /system/userinit.sh exists. If it does, u should just edit that file as the startup script and DO NOT do the procedure below.

    Here's how to do it manually. Do this only if some other lagfix/patch has not already done the playlogos hack, otherwise u might overwrite the other script!

    Create the startup script on your PC. Use adb to push it to /sdcard/userinit.sh

    adb push userinit.sh /sdcard/userinit.sh

    On your PC, create a file called playlogos1 with this content:

    #!/system/bin/sh
    sh /data/userinit.sh
    playlogosnow

    Use adb to push the playlogos1 file to /sdcard/playlogos1

    adb push playlogos1 /sdcard/playlogos1

    Now use adb shell, su and do this:

    busybox mount -o remount,rw /system;
    busybox cp /sdcard/userinit.sh /data/userinit.sh;
    busybox mv /system/bin/playlogos1 /system/bin/playlogosnow;
    busybox cp /sdcard/playlogos1 /system/bin/playlogos1;

    chmod 755 /system/bin/playlogos1;
    chmod 755 /data/userinit.sh;

    The startup script will be /data/userinit.sh

    The reason I put the startup script in /data is so that if you mess up the startup script and get stuck during boot, you can do a "clear data" from recovery, and the startup script will be erased.
    2
    Hi hardcore,
    I've got a question.
    I followed the steps in the first post.
    As far as I can see everything is set up as you described.
    With Root Explorer I've checked whether userinit.sh was in data,
    and it is.
    What I don't know though,
    do I have to go trough the steps in this post as well?
    http://xdaforums.com/showthread.php?t=819580
    I suppose that topic is part of the startup script you posted here..
    because I see similar code.
    Or does the [HOWTO] Optimal ext4 mount options tutorial give other advantages when combined with this tutorial?
    I've made it to the step
    * Repeat the above for all other ext4 partitions.
    As I am not really sure how to apply to the other partitions..

    hope you can help me.
    Startup scripts r a bit tricky if the kernel doesn't support it. I suggest u check out my speedmod kernel which already has these tweaks and also startup script support.
    1
    you could make a script/app for this so everyone else can try it ?

    +1, pretty plz, also, is this compatible with voodoo?
    1
    Hello :)

    Values description for each one and why is welcome ;)
    1
    Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?

    I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
    setprop windowsmgr.max_events_per_sec 10 and still, no difference.

    The aosp windowmanager (android framework) ignores values <35. (Samsung could have changed something here, but that is very unlikely).

    That value does not affect the framerate, but how many touch events are reported to the apps; this saves some cpu if the user keeps touching the screen.