[REF] Startup script speed tweaks

Search This thread

kenshinta

Senior Member
Dec 13, 2004
429
69
Redmi Note 10S
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

Which was the desired output?

I just posted the commands in the script in adb for quoting purpose since it was similar. I had a logcat that showed the erroneous entries but i overwrote it already. It went like this from what i recall:
Code:
cannot create ro/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
cannot create size/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
cannot create slaves/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
cannot create stat/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
cannot create subsystem/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
cannot create uevent/sys/block/stl1/queue/iosched/low_latency: directory nonexistent
so on so forth

Because the for loop as is captures as input the files inside the directory, not the directory itself as i explained.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Because the for loop as is captures as input the files inside the directory, not the directory itself as i explained.
Ah I see. It works in my configuration though - the ls is supposed to output the directories as you said (the directories being the block devices). I guess you've managed to make it work with yours also by now.
 

mathieumeuh

Senior Member
Aug 8, 2010
112
12
Paris
matfrapp.blogspot.com
My working script

That script works well on my SGS. I tested it and I didn't see any changes, but you can try as you want because these parameters will be resetted at reboot.

Code:
echo "Remount all partitions with noatime"

for k in $(mount | cut -d " " -f3)
do
        sync
        mount -o remount,noatime $k
done


echo "Tweak cfq io scheduler"

for i in $(ls /sys/block/stl*) $(ls /sys/block/mmc*) $(ls /sys/block/bml*) $(ls /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



echo "Tweak kernel VM management"
echo "0" > /proc/sys/vm/swappiness
echo "10" > /proc/sys/vm/dirty_ratio
echo "1000" > /proc/sys/vm/vfs_cache_pressure
echo "4096" > /proc/sys/vm/min_free_kbytes

echo "Tweak kernel scheduler"
echo "4000000" > /proc/sys/kernel/sched_latency_ns
echo "1000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "800000" > /proc/sys/kernel/sched_min_granularity_ns

echo "Miscellaneous tweaks"
setprop dalvik.vm.startheapsize 8m
setprop wifi.supplicant_scan_interval 90
 

initrd

Senior Member
Jan 28, 2010
70
0
Code:
# Remount all partitions with noatime
for k in $(mount | cut -d " " -f3)
do
	sync
	mount -o remount,noatime $k
done
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.

won't this also remount all partitions with only the noatime option and discard defaults? this should ideally add noatime to the list of mount options and not replace.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
won't this also remount all partitions with only the noatime option and discard defaults? this should ideally add noatime to the list of mount options and not replace.
Nope. This does what u said - it adds the noatime option and the other existing options remain the same. For example, this is my mount output *after* the script:
Code:
# mount
mount
rootfs on / type rootfs (ro,noatime)
tmpfs on /dev type tmpfs (rw,noatime,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
none on /acct type cgroup (rw,relatime,cpuacct)
/dev/block/stl6 on /mnt/.lfs type j4fs (rw,noatime)
tmpfs on /mnt/asec type tmpfs (rw,noatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
/dev/block/stl9 on /system type rfs (ro,noatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=utf8)
/dev/block/mmcblk0p2 on /data type rfs (rw,nosuid,nodev,noatime,vfat,llw,check=no,gid/uid/rwx,iocharset=utf8)
/dev/block/stl10 on /dbdata type rfs (rw,nosuid,nodev,noatime,vfat,llw,check=no,gid/uid/rwx,iocharset=utf8)
/dev/block/stl11 on /cache type rfs (rw,nosuid,nodev,noatime,vfat,llw,check=no,gid/uid/rwx,iocharset=utf8)
/dev/block/stl3 on /efs type rfs (rw,nosuid,nodev,noatime,vfat,llw,check=no,gid/uid/rwx,iocharset=utf8)
/dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allo
w_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:9 on /mnt/sdcard/external_sd type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dma
sk=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:9 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002
,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/external_sd/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
/dev/block/dm-0 on /mnt/asec/com.rovio.angrybirds-1 type vfat (ro,dirsync,nosuid,nodev,noexec,relatime,uid=1000,fmask=0222,dmask=022
2,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/dm-1 on /mnt/asec/com.gm.f1.main-1 type vfat (ro,dirsync,nosuid,nodev,noexec,relatime,uid=1000,fmask=0222,dmask=0222,code
page=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/dm-2 on /mnt/asec/com.google.android.stardroid-1 type vfat (ro,dirsync,nosuid,nodev,noexec,relatime,uid=1000,fmask=0222,d
mask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
BTW my init script runs before the vold mounts the SD cards, so those were not remounted. I still haven't figured out how to make an init script that can run after the vold mounts the SD cards.
 

initrd

Senior Member
Jan 28, 2010
70
0
BTW my init script runs before the vold mounts the SD cards, so those were not remounted. I still haven't figured out how to make an init script that can run after the vold mounts the SD cards.

that's neat. i guess it's busybox behaviour. on linux, it does replace fs options from what i gather.

cool, shall try your changes sometime! :)
 

pele78

Senior Member
Oct 5, 2010
4,814
1,918
Cambridgeshire, England
Thanks ryan for that tip, i tested the minfree with strict option..

And i noticed a fast start up, faster scan. and a smoother usage of the phone especially the app drawer ( paying attention to the bounce effect) using Zeam Launcher..

Simple lagfix - Thanks.

Im passing on this simplicity approach to Curio, so he understands the need of simplicity by the WIDER community inside and oustide of XDA.

Both of you have produced some outstanding pieces.

(and those who i have not mentioned or seen)

Good work making the Galaxy S, the peoples choice of smartphone, despite the tiny hicups!!


five million and sold cant be wrong :)
 

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
OCLF now has an option to apply (most) of these fixes. It should be up in the market shortly, or you can download it from the OCLF thread. It will hopefully make these options easier to apply for the non-kernel hackers around here. ;)
 
D

Deleted member 2086469

Guest
OCLF now has an option to apply (most) of these fixes. It should be up in the market shortly, or you can download it from the OCLF thread. It will hopefully make these options easier to apply for the non-kernel hackers around here. ;)

will OCLF(startup script tweak) works on voodoo kernel pre6 for JPM/JP6?

Thanks a lot looking forward ur release :D
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Update: Changed the script to use less aggressive values for the Task Scheduler tweaks.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Updated: Added busybox in front of mount commands. Busybox mount returns the correct format.
 

exadeci

Senior Member
Jul 21, 2010
855
316
Sydney
Thanks ryan for that tip, i tested the minfree with strict option..

And i noticed a fast start up, faster scan. and a smoother usage of the phone especially the app drawer ( paying attention to the bounce effect) using Zeam Launcher..

Simple lagfix - Thanks.

Im passing on this simplicity approach to Curio, so he understands the need of simplicity by the WIDER community inside and oustide of XDA.

Both of you have produced some outstanding pieces.

(and those who i have not mentioned or seen)

Good work making the Galaxy S, the peoples choice of smartphone, despite the tiny hicups!!


five million and sold cant be wrong :)

Same with scan and zeam but I was thinking that it was just a feeling that I had but if you felt same too seems that is real change :D
 

EarlZ

Senior Member
Jun 21, 2010
6,290
327
Does this start up tweak play well with Voodoo5 Pre 6 or this is just for RFS?
 

ch33kybutt

Retired Recognized Developer
Oct 25, 2008
635
812
Thanks for the speed tweaks, already created a version for i5700 users to test over on Samdroid.

Did some simple testing on ext2 filesystems, comparing the various schedulers [noop anticipatory deadline cfq] using quadrant advanced (average of 20 samples each), and results show only marginal differences in terms of performance, with cfq fastest and (surprisingly) deadline slowest.

However, there seem to be some differences in CFQ module between i9000 and i5700 (on CyanogenMod-6.1.0-nightlys)...
../queue/iosched/low_latency : does not exist in i5700
../queue/iosched/slice_idle : read-only, unable to change from default setting of 5
in fact here's the ls output of iosched with cfq enabled (with default values)
Code:
 back_seek_max = 16384
 back_seek_penalty = 2
 fifo_expire_async = 250
 fifo_expire_sync = 125
 quantum = 4
 slice_async = 40 
 slice_async_rq = 2
 slice_idle = 5
 slice_sync = 100

Would you have any recommendations to further tweak the above values?
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
Thanks for the speed tweaks, already created a version for i5700 users to test over on Samdroid.

Did some simple testing on ext2 filesystems, comparing the various schedulers [noop anticipatory deadline cfq] using quadrant advanced (average of 20 samples each), and results show only marginal differences in terms of performance, with cfq fastest and (surprisingly) deadline slowest.

However, there seem to be some differences in CFQ module between i9000 and i5700 (on CyanogenMod-6.1.0-nightlys)...
../queue/iosched/low_latency : does not exist in i5700
../queue/iosched/slice_idle : read-only, unable to change from default setting of 5
in fact here's the ls output of iosched with cfq enabled (with default values)
Code:
 back_seek_max = 16384
 back_seek_penalty = 2
 fifo_expire_async = 250
 fifo_expire_sync = 125
 quantum = 4
 slice_async = 40 
 slice_async_rq = 2
 slice_idle = 5
 slice_sync = 100

Would you have any recommendations to further tweak the above values?
Actually those are the same as the i9000 default values. You can try the same values that I posted here, they should improve the performance as well.

Not sure about the read-only error you encountered - you need root for this.
 

jjwa

Senior Member
Jun 24, 2010
220
10
38
Enschede
Works well with Voodoo. I've used it with Voodoo and z4mod (ext4), both are okay.
I have found one specific scenario where it does not combine nicely.
With the Doc_Kalpik rom ROM, I enabled these included startup script tweaks first from the CWM menu, and later tried to install Voodoo with the update.zip method they provided. (Method not by curio, so unsupported and unofficial.) It corrupted my installation and I had to reflash.
 

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.