• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Compcache userinit.sh tutorial for Cyanogen 367

Search This thread

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,474
1,647
Detroit, Mi
nice job...

I did some script which allows users to specify the parameters in user.conf file. It maybe a good idea if you can integrate this into your script.

Would it be possible to add something like:
# Experimental settings
echo 1 > /proc/sys/vm/page-cluster; # default: 3 Changes Page clustering from 8 to 2.
echo 5 > /proc/sys/vm/laptop_mode; # default: 0 Helps keep SSD from getting worn.
echo 5000 > /proc/sys/vm/dirty_expire_centisecs; # default: 3000
echo 800 > /proc/sys/vm/dirty_writeback_centisecs; # default: 500
echo 10 > /proc/sys/vm/dirty_background_ratio; # default: 5
echo 16 > /proc/sys/vm/dirty_ratio; # default: 10
to the user.conf file? I don't even know where to begin with scripts and when I tried to add it to the userinit.sh file it stuck it's tongue out at me and called me names. (metaphorically speaking)

Thanks
 

huanyu

Senior Member
Apr 26, 2009
125
14
Would it be possible to add something like:

to the user.conf file? I don't even know where to begin with scripts and when I tried to add it to the userinit.sh file it stuck it's tongue out at me and called me names. (metaphorically speaking)

Thanks

I have update the script with these parameters but i haven't test it yet. Let me know if you had any problem. if i got time over the weekend, i will try to clean up the script.
 

Attachments

  • cc.zip
    2 KB · Views: 50
Last edited:

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,474
1,647
Detroit, Mi
I have update the script with these parameters but i haven't test it yet. Let me know if you had any problem. if i got time over the weekend, i will try to clean up the script.

You haven't tested this yet? Really? Well... everything worked just fine!
Thanks a lot! This gives us a lot more flexiblity with fine tuning on our G1's.

I'll share this with Cyanogen's thread. I'm sure they'll be happy to see it.

Thanks again.
 

uwonsum

Senior Member
Jul 16, 2008
203
0
I have update the script with these parameters but i haven't test it yet. Let me know if you had any problem. if i got time over the weekend, i will try to clean up the script.

I just looked at the script...very well done. Good job!
Would you consider adding this option...may be after a while Cyanogen will feel comfortable enough to add it to the builds.
Code:
echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

This is my current setting:
Code:
#!/system/bin/sh
## adb push userinit.sh /system/sd

uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
insmod=/system/bin/insmod

$insmod $moddir/compcache/xvmalloc.ko;
#$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768;
#$insmod $moddir/compcache/ramzswap.ko memlimit_kb=32768 backing_swap=/dev/block/mmcblk0p3;
$insmod $moddir/compcache/ramzswap.ko backing_swap=/dev/block/mmcblk0p3;

mknod /dev/ramzswap0 b 253 0;
echo 24 > /proc/sys/vm/swappiness; # default: 60

## *Experimental* RAM settings
echo 1 > /proc/sys/vm/page-cluster; # default: 3
echo 5 > /proc/sys/vm/laptop_mode; # defaul: 0
echo 5000 > /proc/sys/vm/dirty_expire_centisecs; # default:: 3000
echo 800 > /proc/sys/vm/dirty_writeback_centisecs; # default: 500
echo 10 > /proc/sys/vm/dirty_background_ratio; # default:5
echo 16 > /proc/sys/vm/dirty_ratio; # default: 10
##

swapon /dev/ramzswap0;
#swapon /dev/block/mmcblk0p3;

## *Experimental* CPU settings
echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate; # cm <= 3.9.1
echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq; # default: 245760
echo 200 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias; # default: 0
##

exit;

## commands to display useful system info
## **Do not uncomment**

# free
# top -m 8; displays only 8 processes 
# cat /proc/swaps 
# cat /proc/ramzswap0
# cat /proc/meminfo
# sysctl -a | grep vm
# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
# vmstat -d 5 -n 10
 
Last edited:

ttabbal

Senior Member
Jul 1, 2009
2,076
723
Samsung Galaxy S21 Ultra
Has anyone been able to get backing_swap AND memlimit_kb working? If I enable backing_swap, it ignores the memlimit setting and I get 14MB used. I've never seen it use that much though, so that RAM is wasted. I'd really like to get it down to about 8MB as I've only ever seen it use about 6MB. Sounds like a bug in the module, but someone might have found a workaround.
 

uwonsum

Senior Member
Jul 16, 2008
203
0
Has anyone been able to get backing_swap AND memlimit_kb working? If I enable backing_swap, it ignores the memlimit setting and I get 14MB used. I've never seen it use that much though, so that RAM is wasted. I'd really like to get it down to about 8MB as I've only ever seen it use about 6MB. Sounds like a bug in the module, but someone might have found a workaround.

This is a confirmed issue. If you notice in my script above, the line with mem limit is commented out though that is the right instruction--it just does not work.
 

overpower

Senior Member
Sep 15, 2008
60
0
Compcache .6.x

Supposedly the latest build of .6.x is working with some stats corruption from the built in module.

If someone can compile it against the cyanogen's kernel and post it then we can probably set the memlimit option.

Anyone have it? I haven't been able to figure out how to cross compile on a Mac, but if someone points me the right direction I can try to do it.
 

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,474
1,647
Detroit, Mi
I have update the script with these parameters but i haven't test it yet. Let me know if you had any problem. if i got time over the weekend, i will try to clean up the script.

uwonsom pointed out something to me in your userinit.sh file you have this code:

echo insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko ${CC_DISKSIZE_FLAG} ${CC_MEMSIZE_FLAG} ${CC_BACKINGSWAP_FLAG};

Shouldn't that be uname_r?
 

namsir

Senior Member
Jan 17, 2009
437
143
i'm running cyanogen 3.9.2 and i did use the userinit.sh and it didn't work when i do the #free command......swap is 0 and the cat /proc/ramzswap didn't work either ....can anyone help?
 

uwonsum

Senior Member
Jul 16, 2008
203
0
i'm running cyanogen 3.9.2 and i did use the userinit.sh and it didn't work when i do the #free command......swap is 0 and the cat /proc/ramzswap didn't work either ....can anyone help?

Yes the script has a little issue. I am debugging it now. I will post the fix soon as am done testing...

edit: Fixed/update
-Resolved Linux-swap not turning on
-VM configuration works with Linux-swap
-Compcache works with any kernel version
-Ensure backing_swap is not always the default

Added:
-Minimum CPU scaling frequency
-CPU sampling rate (You should not touch this unless you know why it was added and what it means)
-Power bias

The fix/update is now posted. I take no credit for this script.

adb push userinit.sh /system/sd
adb push user.conf /system/sd

user.conf usage

To use only linux-swap
-set compcache=0
-set linux_swap_eanable=1

To use only compcache without backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=32 (32*1024 = 32768kb = 32MB)
-set cc_memlimit=0

To use compcache with backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=0 (doesn't really matter so long cc_memlimit != 0)
-set cc_memlimit=8 (doesn't matter the number used, it will default to 15% of total RAM--known issue)



These are default system settings:

page-cluster=3
laptop_mode=0
dirty_expire_centisecs=3000
dirty_writeback_centisecs=500
dirty_background_ratio=5
dirty_ratio=10
swappiness=60

sampling_rate=2000000 (200000 depending on kernel version)
scaling_min_freq=245760
powersave_bias=0

Update:

I re-uploaded the file due to clarification regarding Cyanogen's comments here that the sampling_rate should be configured to the power of 6 instead of 5 which some previous ROMs were using. There is no need to re-download. This has the same configurations as the previous.

Run these command to see your current settings and system info:
Code:
free
top -m 8; displays only 8 processes 
cat /proc/swaps 
cat /proc/ramzswap0
cat /proc/meminfo
sysctl -a | grep vm
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
vmstat -d 5 -n 10
 

Attachments

  • cc_update.zip
    2.4 KB · Views: 49
Last edited:

uansari1

Senior Member
Jul 27, 2008
3,549
92
Karachi
Yes the script has a little issue. I am debugging it now. I will post the fix soon as am done testing...

edit: Fixed/update
-Resolved linux-swap not turning on
-VM configuration works with Linux-swap
-Compcache works with any kernel version
-Ensure backing_swap is not always the default

Added:
-Minimum CPU scaling frequency
-CPU sampling rate (You should not touch this unless you know why it was added and what it means)
-Power bias

What post is the updated script in? I'm having the same problem with the swap coming up as 0 when I run the #free in Terminal Emulator...

I had pushed the userinit.sh to /system/sd, and have created the three partitions on my SD card.
 

Janis

Senior Member
Jul 26, 2006
746
37
Minneapolis, MN US
I did want some, got some!

I know this is bad form for ROMs, but I've noticed this thread is much shorter and no one's posted this, exactly, yet:

This worked for me on Cyanogen's 3.9.2

I was stumped, but I think this will allow me to run the apps I want to run with a near-normal number of fc/w clicks and some livable, actually very decent speed.

Just curious, what's wrong with clocking down to 128 when idle?

Thanks for the hard work!
 

namsir

Senior Member
Jan 17, 2009
437
143
this update gonna work on cm 3.9.2 ?




Yes the script has a little issue. I am debugging it now. I will post the fix soon as am done testing...

edit: Fixed/update
-Resolved Linux-swap not turning on
-VM configuration works with Linux-swap
-Compcache works with any kernel version
-Ensure backing_swap is not always the default

Added:
-Minimum CPU scaling frequency
-CPU sampling rate (You should not touch this unless you know why it was added and what it means)
-Power bias

The fix/update is now posted. I take no credit for this script.

adb push userinit.sh /system/sd
adb push user.conf /system/sd

user.conf usage

To use only linux-swap
-set compcache=0
-set linux_swap_eanable=1

To use only compcache without backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=32 (32*1024 = 32768kb = 32MB)
-set cc_memlimit=0

To use compcache with backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=0 (doesn't really matter so long cc_memlimit != 0)
-set cc_memlimit=8 (doesn't matter the number used, it will default to 15% of total RAM--known issue)



These are default system settings:

page-cluster=3
laptop_mode=0
dirty_expire_centisecs=3000
dirty_writeback_centisecs=500
dirty_background_ratio=5
dirty_ratio=10
swappiness=60

sampling_rate=2000000 (200000 depending on kernel version)
scaling_min_freq=245760
powersave_bias=0
 

yukkio

Senior Member
May 19, 2009
1,375
109
Yes the script has a little issue. I am debugging it now. I will post the fix soon as am done testing...

edit: Fixed/update
-Resolved Linux-swap not turning on
-VM configuration works with Linux-swap
-Compcache works with any kernel version
-Ensure backing_swap is not always the default

Added:
-Minimum CPU scaling frequency
-CPU sampling rate (You should not touch this unless you know why it was added and what it means)
-Power bias

The fix/update is now posted. I take no credit for this script.

adb push userinit.sh /system/sd
adb push user.conf /system/sd

user.conf usage

To use only linux-swap
-set compcache=0
-set linux_swap_eanable=1

To use only compcache without backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=32 (32*1024 = 32768kb = 32MB)
-set cc_memlimit=0

To use compcache with backing_swap
-set compcache=1
-set linux_swap_eanable=0
-set cc_disksize=0 (doesn't really matter so long cc_memlimit != 0)
-set cc_memlimit=8 (doesn't matter the number used, it will default to 15% of total RAM--known issue)



These are default system settings:

page-cluster=3
laptop_mode=0
dirty_expire_centisecs=3000
dirty_writeback_centisecs=500
dirty_background_ratio=5
dirty_ratio=10
swappiness=60

sampling_rate=2000000 (200000 depending on kernel version)
scaling_min_freq=245760
powersave_bias=0

Update:

I just re uploaded the file due to an unresolved issue. Cyanogen posted here that the sampling_rate should be configured to the power of 6 instead of 5 that his previous ROMs were using. I initially set it to this new value but defaulted back to the old number until there is clarification.

The new file will default to the old setting. You can re-download the files or just change this in the user.conf file (sampling_rate=20000). It is currently set to 2000000.

Without the userinit.sh present, you can run this command to see your current setting:
Code:
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate

Hi mate, I've downloaded your script updated. I've pushed to /system/sd with 755 permissions. I have to change any value from user.conf to use with cm-3.9.2 or actual values are ok?
Great job man.
Thank you.
BR.
 

uwonsum

Senior Member
Jul 16, 2008
203
0
Hi mate, I've downloaded your script updated. I've pushed to /system/sd with 755 permissions. I have to change any value from user.conf to use with cm-3.9.2 or actual values are ok?
Great job man.
Thank you.
BR.

I cannot take credit for the script, I just added a couple things to it. Here is original version. You don't have to change anything for it to work, but you can play with the user.conf file to see what works best for you.
 

yukkio

Senior Member
May 19, 2009
1,375
109
Ok. I've seen the value of the variable laptop_mode is 0. Is it better 0 than 5?
Thanks.
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq shows 245000 instead 128000 when display is off. Is it normal?
BR.
 
Last edited: