yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] acidwashg1:
custom userinit.sh for cyanogen 4.2.1 based off of userinit.sh v0.1.5.3 by huanyu.

modified the script to force compcache v0.6+ so this script will not work for those using compcache 0.5. I just modified like 5 lines of code really. go basic scripting skill, woo!

this version should be able to do anything the original script can, I just fixed it so it can enable compcache on cyanogen 4.2.1

http://rapidshare.com/files/298467442/custom_userinit_cyanogen_4.2.1.zip

I included the default user.conf in the zip. after the install and configuration of the script, I recommend you run the following to make sure that compcache is properly enabled. the install instructions are the same as the original script. good luck, lemme know if it works.

rzscontrol /dev/block/ramzswap0 -s
or
free

edit: forgot to talk about performance...I'm running 4.2.1 with the BFS boot image and I enabled compcache with a 64mb backingswap. set swappiness to 40. so far, its blazing fast! remember what cyanogen said, this setup can cause instability, so be weary. if you're looking for stable, don't go down the BFS+compcache route. although, I must say, I haven't seen any instability yet (I don't mind some instability for performance). I tried opening 8 different windows with different pages in the browser, then went to the home screen. no lag, no home screen reloading. I don't know how locking the home screen in memory and compcache will play together, but we'll see. let me know what your results are everyone, I'm interested in the best setup for speed.
[G1 Android Development] ggrant3876:
Hate to ask a noob question but I will. Is the code to enable it the same as on page 1 through the terminal.

Thanks
[G1 Android Development] acidwashg1:
yeah, it should be the exact same
[G1 Android Development] ggrant3876:
It works until you reboot, then you have to enter the script again. It used to stay enabled once you ran the script.
[G1 Android Development] acidwashg1:
what directory do you have the files in?

thats really weird, I have the files in the following location and it automatically enables at startup.

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

did you also do the following?

su
chmod 777 /system/sd/userinit.sh
chmod 777 /system/sd/user.conf

your signature says you're using cyanogen 4.2.2, right? I am running the same setup and it works fine for me.
[G1 Android Development] crypticc:
No linux swap and multiple errors from userinit.sh

Hi I have something very similar.

I have previously used the same HW and setup with compcache and backing-swap, but on moving to CM 4.2.2 want to try linux swap.

This failed with errors from userinit.sh on reboot (see attached)

Updated - Fixed. I thought that cc_backingswap_en was enabled when compcache_en=1

Just spotted logic in .sh and comment in user.conf that cc_backingswap_en prevents Linux swap working, even if not enabled through compcache.

Question - is there such a thing as backing swap without compcache, and how does that compare to regular linux swap?

Thanks

Chris
[G1 Android Development] boulderjams:
@terence_oh: I just did an ADB remount and that issue went away for me.
[G1 Android Development] mygti02:
i cant get this working at all :( sigh......If i adjust any of the settings I get errors no matter what. If i leave it how it is and run the .sh with -c then i says, shift: cant shift that many. what am i doing wrong here? using the lates CM rom. thanks!
[G1 Android Development] acidwashg1:
there is no such thing as a backing swap without compcache. here are your possible options:

1. just compcache

2. just linux-swap (managed by the OS)

3. compcache with backing swap (the swap space is managed by compcache)

4. compcache and linux managed swap

in my experience, I get the best performance with compcache and a backing swap on any cyanogen build. not sure about hero builds.

what version of the script are you using? post up your user.conf and userinit.sh, let us check it out
[G1 Android Development] square1:
hey can anyone help me. im running cyanogenmod 4.2.3.1 and i cant seem to get compcache to work or install. i type in the commands on page 1 on better terminal emulator and it just doesnt seem to do anything. when i check the status, it says that compcache is disabled and it cant find the modules.
[G1 Android Development] jerzy448:
hey can anyone help me. im running cyanogenmod 4.2.3.1 and i cant seem to get compcache to work or install. i type in the commands on page 1 on better terminal emulator and it just doesnt seem to do anything. when i check the status, it says that compcache is disabled and it cant find the modules.

same here
[G1 Android Development] neatchee:
Changes in the compcache modules in CM have resulted in 1.5.3 userinit.sh no longer being able to properly enable compcache. rikupw and myself (find us in #cyanogenmod on irc.freenode.com) did some work and believe we have fixed the problem. We're dubbing it userinit.sh v1.5.3.1(unofficial). You can get it here: http://www.ansemreport.com/userinit.sh

Obviously the standard disclaimer of "we're not responsible if your **** breaks" applies here.

For the curious, the offending code chunk is here:

# check for kernel module directory
CHK_KERNEL_MOD_DIR()
{
uname_r=`uname -r`;
MODDIR=`find /system/modules -type d -name $uname_r`;
if [ ! -e $MODDIR/compcache/xvmalloc.ko ]; then
echo $MODDIR/compcache/xvmalloc.ko not found
MODDIR="/system/sd";
echo use $MODDIR/compcache/xvmalloc.ko instead
if [ ! -e $MODDIR/compcache/xvmalloc.ko ]; then
echo $MODDIR/compcache/xvmalloc.ko not found
echo "ERROR!!! unable to find compcache modules."
exit 1;
fi;
fi;
}

Starting with, I think, CM 4.2, xvmalloc.ko changed to ramzswap.ko There may be some other changes that rikupw made to the userinit.sh to reflect this change, but that's the main one :) Hope this works for you! It's been working on my end just fine.
[G1 Android Development] acidwashg1:
refer to my post a page back. use this version, it works for me on cyanogen 4.3.2.1. lemme know if you have any problems. I realized a while ago that the CHK_KERNEL_MOD_DIR() function was screwing things up, good catch neatchee
[G1 Android Development] mygti02:
so if i wanted to make changes to the settings, which file do i change it on? user.conf or userinit.sh?
[G1 Android Development] BrooklynAvi:
user.conf App

I created an app that allows you to visually create your user.conf file and push it (along with a proper userinit.sh file) to the system with one button. All you need to do is punch in your values and click Push Files. No need for ADB. No need for terminal. Comments, questions, suggestions welcome, especially since I am not an expert in userinit.sh files.

http://xdaforums.com/showthread.php?t=581328
[G1 Android Development] pershoot:
hi. has anyone modified userinit.sh yet for 4.2.4 so swap and compcache will work? i have not gotten a chance to look at it yet.. was up late building stericson's lockscreen source.

if no one has, ill look in to it a lil later.

thx:)
[G1 Android Development] :
it will work for linux swap but needs to be updated for compcache. i wish userinit wasn't abandoned.
[G1 Android Development] pershoot:
my swap is not being activated. i will investigate in detail and report back.
[G1 Android Development] pershoot:
had a typo. i had left 1 for ccswap (even though cc was at 0). swap is working fine.

compcache is working fine also.

you can use this one posted earlier:

http://www.ansemreport.com/userinit.sh

this takes out the odex stuff (you won't use it/need it on the cy builds), and just remove the 3 odex lines in the top of user.conf.

edit: also contains the modification of module name to be used past 4.2+
[G1 Android Development] acidwashg1:
the script pershoot posted above looks good, has the edits to work under 4.2+

I realized I didn't want or need half the stuff the script does so I just made a dead simple custom script myself, helped speed up my boot time by eliminating unnecessary functions from running at boot. works flawlessly, figured I'd post it up for anyone else.

#compcache WITHOUT backingswap
modprobe ramzswap
rzscontrol /dev/block/ramzswap0 --disksize_kb=32768 --init
sysctl -w vm.swappiness=40
swapon /dev/block/ramzswap0

#linux managed swap
#swapon /dev/block/mmcblk0p2

#cpu
echo 384000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 35 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold

the cpu stuff isn't necessary, just personal preference. enable linux managed swap by removing the # in front of "#swapon /dev/block/mmcblk0p2". you can change the size of compcache by editing the number after "--disksize_kb="...pretty self explanatory. hope it helps someone. you can add backing swap if you would like, by using the command listed on this page. I have a feeling all of this will be useless once cyanogen adds his slider for compcache into the Spare Parts app, but until then ^^^
[G1 Android Development] mlevin:
Just tried your script on 4.2.5 and it "worked" but I got this one error:

# /system/bin/sh userinit.sh

rzscontrol /dev/block/ramzswap0 --memlimit_kb=18432 --backing_swap=/dev/block/mmcblk0p3 --init

vm.swappiness = 28

[: 1: unknown operand
[G1 Android Development] skrki:
Tested linux swap using your script. It works fine, thanks a bunch!
[G1 Android Development] Charrion:
Thank you,

Thanks pershoot, that greatly improves boot time.
[G1 Android Development] pershoot:
np, but thank rikupw and neatchee (it is their modified script) :)
[G1 Android Development] Charrion:
I'll have to remember to do so, it's been a while since I've been on #cyanogenmod and that seems to be the only place they hang out now.
[G1 Android Development] :
posted in the wrong place sorry
[G1 Android Development] :
works on 4.2.6

http://www.ansemreport.com/userinit.sh
[G1 Android Development] ZailCZ:
Problem 4.2.5

I have problem with my cc. It was good but when i flash 4.2.5 it stip work - on sh /system/sd/userinit.sh this eror /dev/block/ramyswa0 no such file or dir. i found cmd on fix it but after reboot its do same eror,

Do you know how to fix it ?
[G1 Android Development] chrismfz:
Any ideas why I cannot make it work at CM 4.2.6 ? :confused:

=== user.conf ===
*** general ***
apps2sd=1
media2sd=1

*** CompCache ***
compcache_en=1
cc_memlimit=16
cc_disksize=32
cc_backingswap_en=0
cc_backingswap=/dev/block/mmcblk0p3
swappiness=60

*** Swap File ***
swap_file_en=1
linux_swap_file_size=32
linux_swap_file=/system/sd/swap.file

*** Linux Swap ***
linux_swap_en=1
linux_swap_partition=/dev/block/mmcblk0p3

*** VM ***
sys_vm_en=0
page_cluster=0
laptop_mode=0
dirty_expire_centisecs=3000
dirty_writeback_centisecs=500
dirty_background_ratio=5
dirty_ratio=10

*** CPU ***
proc_cpu_en=0
scaling_min_freq=245760
scaling_max_freq=528000
sampling_rate=2000000
powersave_bias=200
up_threshold=40

=== CompCache status ===
CompCache version 0.6+
!!!ERROR Compcache disabled
CompCache: DiskSize (system) 32768(user)
CompCache: cc_swappiness - 60(system) 60(user)

=== CompCache status output ===
Failed to open /dev/block/ramzswap0: No such file or directory

=== Linux Swap status ===
!!! Linux SWAP error: Linux swap is not enabled
Linux Swap: swappiness - 60(system) 60(user)
root@core:/home/chris/android/tools#

Tried only swap, then only compcache, then both but still

this is the only magic keyword I see "error"... in the output...
[G1 Android Development] pershoot:
make sur eyou are using a current script (it was posted a bit up) and you have compcache enabled in spare parts.

i would turn off swap file and swap section, and enable compcache backing swap.
[G1 Android Development] wesgarner:
It may be something in the CC modules (I think he doesn't include xvmalloc.ko but heck I am not sure it is even used anymore)

Also, to do just swap - just type:

busybox swapon /dev/block/mmcblk0p3;

if you are using cm, you could just pop that in a blank file adding:

#!/system/bin/sh

#

then pushing it to /system/etc/init.d (I would name it 07swap or something)
[G1 Android Development] dcorrea:
I am using a 32mb Linux-swap with swap file enabled. I have downloaded the newest userinit posted a few pages back and I have swappiness set to 50. Everything is configured properly, but I noticed that when I check my config using

adb shell sh /system/sd/userinit.sh -i,

my phone conistently shows 0 bytes free for the swap. Is it normal for the swap to be consistently full?
[G1 Android Development] AsaSpades:
Check your Spare Parts for Compcache
[G1 Android Development] inuyasha84:
I didn't understand if this is supposed to autostart at boot from /system/sd or if I have to move it somewhere else.
[G1 Android Development] skrki:
This has crossed my mind quite a few times, and I've tried it multiple times as well... Just somehow doesn't work on CM. Can you please confirm it is working? I know this should be the easiest way, and I know those files are executed, I just don't get why nothing I put in there gets executed.

EDIT: Got it working... damn permissions!
[G1 Android Development] drew16:
how can i uninstall the useninit.sh file? it seems to be causing a lot of problems and crashes and i would rather not deal with it.
[G1 Android Development] snellx:
it is located in /system/sd. Just delete it...

but if you don't know this, perhaps you don't even have one...?!
[G1 Android Development] drew16:
im not sure if its the rom or the userinit.sh file but after i installed it with the user.conf set for just linux swap at the default 60 swappiness i have had a lot of glitches nonresponsiveness and force closes. Im using cyanogen 4.2.11.1 by the way
[G1 Android Development] drew16:
Thats why i was asking. Is the userinit.sh file not going to fully work with the latest cyanogen because when i type in free in the terminal emulator it shows that i have swap and its being used? But its buggy
[G1 Android Development] skrki:
http://zerocredibility.wordpress.com/2009/08/24/why-android-swap-doesnt-make-sense/

Read through this for some general info. Something is probably wrong with your setup, because Linux swap is a good thing for the CM (and cannot be 'buggy'). You may also be using the wrong userinit.sh script, so I'd suggest you to try other methods of enabling swap: Swapper (Market app), GScript Lite (also Market), or the plain ol' Terminal:

swapon /dev/block/mmcblk0p[B]n[/B]

where n is your swap partition order number.

If you have FAT32, EXT and SWAP n=3.

If you have only FAT32 and SWAP n=2.

If you want to try GScript, use the same syntax above to create the script, then just run it from GScript.
[G1 Android Development] crypticc:
swap not being activated

Hi - I am hoping you can help me with userinit.sh

I am on cm 4.1.12.2

I was using userinit.sh with linux_swap without issue

I temporarily tried compcache just using the spare parts setting.

I temporarily tried compcache with backing_swap

I went back to linux_swap, and ever since the linux_swap isn't being enabled.

I can enable manually with mkswap and swapon, but userinit either isn't being run, or isn't working.

I have tried manually running userinit.sh and unless I have enabled myself with swapon etc I get an error that Linux swap isn't enabled.

If I manually enable swap first - it works userinit.sh -s works fine.

If I userinit.sh -c I get an error about no such file, and bash -x userinit.sh -c suggests the error is in the get_user_conf section, but ls -ltr in the /system/sd shows both userinit.sh and user.conf = -rwxr-xr-x

I rm the partition using parted, and re-created as linux-swap.

Repeatedly rebooting doesn't create the swap partition.

/proc/swaps and free don't show the swap, until I enable it manually.

Lastly, I manually added swap partition line into fstab because i saw it wasn't listed there as follows, and then repeated the process. Still no luck.

/dev/block/mmcblk0p3	none swap	sw

Here is my userinit.sh and user.conf - I hope someone can help me, because manually enabling the swap is tedious. Did enabling compcache in spareparts CM turn off the userinit.sh, and turning it off fail to re-enable?

Thanks - I appreciate it.

Chris
[G1 Android Development] tjs3783:
Here's my (modified) userinit.sh & user.conf. Been using this script for a while, and it works great for me. Currently configured for linux swap @ 30 swappiness
[G1 Android Development] danshur:
Nice, thanks. Much faster for me on cm 4.2.11. I wander if I should try 4.2.12.2 with these properties.
[G1 Android Development] tjs3783:
Working fine for me in 4.2.12.2
[G1 Android Development] crypticc:
Thanks for the file - tried that and works if run in adb shell, just rebooting... (UPDATE) Working fine. Can't explain why it didn't before when I tried either manually edited file, or the one linked about midway through this thread.

Thanks so much !

# Running this as userinit.sh

s# sh userinit.sh

sh userinit.sh

mkswap /dev/block/mmcblk0p3

Setting up swapspace version 1, size = 32305664 bytes

swapon /dev/block/mmcblk0p3

# free

free

total used free shared buffers

Mem: 97916 95664 2252 0 460

Swap: 31544 0 31544

Total: 129460 95664 33796
[G1 Android Development] sacredsoul:
Figured as much. Rebooted and ran #free :D

3.9.4 is out. Gonna upgrade with a no wipe. userinit.sh issues fixed.

EDIT: Flashed without a wipe. Boots fine. Checked if it's doing it's job. It is :D
[G1 Android Development] Pinesal:
Where do you put the files if you aren't using apps to sd? Still in the /system/sd folder?
[G1 Android Development] ShatBag1105:
Went from 3.9.2 to 3.9.4 with first version of user.conf and userinit.sh.

Booted fine. Everything is still working. :D

EDIT: i pushed the V0.1 files to 3.9.4 now i have no errors whatsoever on #sh /system/sd/userinit.sh -s report. I had a min cpu scaling error with the old files.
[G1 Android Development] ei8htohms:
settings, cpu scaling transitions and battery life

At uwonsum's request, I'm reposting this question here (this is reposted from the Cyanogen experimental thread where uwonsum noted significantly different battery life readings and cpu scaling responses):
[G1 Android Development] oneG:
im getting "Unable to set compcahe cc_swappiness to user specific "30" Current system value is '10' "

anyone else see this.

How do i fix?
[G1 Android Development] uwonsum:
Read the IBM text below before reading my comments.

The two outputs below support the IBM description of what the powersave_bias kernel option does. By default, it is disabled. I have it enabled and devsk has the default setting. He has a battery drain issue and I do not. The simple explanation behind the two different results is that his CPU is spending more time at a higher frequency without throttling through the available frequencies efficiently. Although his CPU is scaling to the minimum usable frequency and spends more time there, but that occurs only when the system is idle.

As for my system, assuming I set the powersave_bias = 250 (25%) and the governor requests 528MHz, 396MHz will become the new value demanded. Now because 396MHz is not an available frequency, in order to carry out the execution of the process, you could see a throttle similar to this form:

((384*44)+(528*4))/48 = 396

This means the CPU will spend 91.67% at frequency 384MHz and 8.33% at frequency 528MHz. This is the difference in our trans_table stats. You should notice high transitions between 384MHz and 528MHz on my table with most of the time spent at the lower frequency. devsk has higher transitions between 128MHz and 528MHz and once it scales up, it stays at the higher frequency until it finishes execution. The higher the frequency, the more power is demanded.

I have tested powersave_bias of 100, 150, 200, and 250. I am currently using 200. If the powersave_bias is set too high, you will notice longer response time. I hope this clarifies things.
[G1 Android Development] huanyu:
i am aware of this bug when the script is not executed from /...... will update the script when i got time
[G1 Android Development] huanyu:
I think you may have something else that overwrites the cc_swappiness.

can you manually try

sh /system/sd/userinit.sh

then try

sh /system/sd/userinit.sh -s

to see the result again.
[G1 Android Development] uwonsum:
See Previous Post #46

powersave_bias = 200

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
19200 0
122880 0
128000 233001
245760 11754
[B]384000[/B] 125842
528000 44625

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
From : To
: 19200 122880 128000 245760 384000 528000
19200: 0 0 0 0 0 0
122880: 0 0 0 0 0 0
128000: 0 0 0 0 0 130
245760: 0 0 61 0 0 24
384000: 0 0 70 81 0 647
528000: 0 0 0 4 798 0

powersave_bias = 0

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
19200 0
122880 0
128000 461075
245760 16970
384000 12843
[B]528000[/B] 139854

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
From : To
: 19200 122880 128000 245760 384000 528000
19200: 0 0 0 0 0 0
122880: 0 0 0 0 0 0
128000: 0 0 0 0 0 283
245760: 0 0 59 0 0 67
384000: 0 0 28 24 0 55
528000: 0 0 197 102 107 0

powersave_bias = 200

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
19200 0
122880 0
128000 1808230
245760 43695
[B]384000[/B] 128339
528000 40203

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
From : To
: 19200 122880 128000 245760 384000 528000
19200: 0 0 0 0 0 0
122880: 0 0 0 0 0 0
128000: 0 0 0 0 0 343
245760: 0 0 284 0 0 44
384000: 0 0 60 328 0 335
528000: 0 0 0 0 723 0

powersave_bias = 0

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
19200 0
122880 0
128000 749139
245760 23869
384000 22743
[B]528000[/B] 178155

# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
From : To
: 19200 122880 128000 245760 384000 528000
19200: 0 0 0 0 0 0
122880: 0 0 0 0 0 0
128000: 0 0 0 0 0 357
245760: 0 0 78 0 0 84
384000: 0 0 37 35 0 77
528000: 0 0 243 127 149 0
[G1 Android Development] huanyu:
From the results, its pretty clear that G1 switch between idle and full load at most of the time. Setting powersave_bias to 200 will force governor to use 384000 ( the closest to 422400 ) before it actually jump to max frequency, therefore, saves some battery. However, there may notice the performance drop in some applications (or its not that noticeable).

We could possible test with different sampling rate / powersave_bias configuration. Lower the sampling rate should improve the performance a bit. Make sure its not too low, because could end up wasting alot CPU time as its constantly checking for system loads. I guess these are something worth to experiment with.

#46

200 sounds like a sweet spot for G1 from your opinion? what about 150?

Thanks for your information and test results
[G1 Android Development] ei8htohms:
this is great stuff

Very informative and accompanied by compelling data. Definitely something to experiment with. Thanks!
[G1 Android Development] AsaSpades:
Hmm I feel so lost with all this Compcache stuff. I have a 32mb Linux Swap partition and im hearing that Compcache is better? Is this true? If so how do I go about switching do I jus follow the 1st post in this thread? Which config is the best?