yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] overpower:
According to the compcache author one thing having a compcache managed backing_swap allows is to clear space out of the ramzswap and to offload it into the backing_swap. Are you running with a compcache managed backing_swap? e.g.

insmod {path}/ramzswap memlimit_kb=64000 backing_swap=/dev/{whatever}

As I use a partition file, I haven't used a compcache managed backing_swap but I do use a linux-managed, and I experience the same issues as ramzswap fills up.

Just out of curiosity, since my only experience is with cyanogen memory stats, can you post or pm me your 'cat /proc/ramzswap', 'cat /proc/swaps' and 'free'?

I think part of the issue is that even with swap files, android's basic assumption of no virtual memory may be leading to very poor memory allocation and release giving us all what appear to be memory leaks.

Here's mine below (Cyanogen 3.9) 12 MB Ramzswap, 32 MB Partition File:

Filename	Type	Size	Used	Priority
/dev/ramzswap0 partition	12284	11808	-1
/system/sd/swapfile.swp file	31596	0	-2
DiskSize:	12288 kB
NumReads:	523
NumWrites:	3026
FailedReads:	0
FailedWrites:	0
InvalidIO:	0
PagesDiscard:	0
ZeroPages:	123
GoodCompress:	71 %
NoCompress:	5 %
PagesStored:	2849
PagesUsed:	946
OrigDataSize:	11396 kB
ComprDataSize:	3750 kB
MemUsedTotal:	3784 kB
total used free shared buffers
Mem: 97876 96144 1732 0 552
Swap: 43880 11808 32072
Total: 141756 107952 33804

I just spent some time checking the behavior of compcache swap, which may also be the same with linux managed swap (just didn't get to that point yet).

If you cycle between the default browser with the google home page, and the home screen, whenever the homescreen or browser has been low memory killed and has to reload, the swap usage will increase. It looks like compcache isn't reclaiming the memory but just reallocating. I'm gonna disable compcache and try with a linux_swap next.

If anyone has a compcache managed linux_backing, please try this. For collecting 'free' do it through adb shell.

Use the default browser with the default google start page.

Hit home to go back. [note whether it had to reload]

Collect 'free' stats for the swap.

Try to start the browser. (search-b makes this easier). [note whether homepage had to redownload]

Collect 'free'.

Goto 2.

Note

If the browser or home page are always snappy, then you'll probably need some load on the system to force processes to close. Try playing mp3s.

Edit

I played with just a pure linux swapfile and here are my observations.

Swapspace in this case is the linux partition/file.

Compcache continues to grow as processes are restarted.

As compcache fills performance gets worse and worse.

Swapspace grows at a lesser rate and tends to plateau as processes are restarted.

As swapspace fills performance seems to remain static.

In my best case, swapspace seems less responsive then compcache, but only when compcache is fresh. (This may be related to a class 2 sdcard/swap file and not partition)
[G1 Android Development] h.nocturna:
I am using compcache with backing_swap enabled in the userinit.sh:

Filename Type Size Used Pr

/dev/ramzswap0 partition 64236 14668 -1
/dev/block/mmcblk0p3 partition 32120 0 -2

c:\android>adb shell cat /proc/ramzswap
DiskSize: 64240 kB
NumReads: 3535
NumWrites: 4562
FailedReads: 0
FailedWrites: 0
InvalidIO: 0
PagesDiscard: 0
ZeroPages: 274
GoodCompress: 77 %
NoCompress: 4 %
PagesStored: 4288
PagesUsed: 1332
OrigDataSize: 17152 kB
ComprDataSize: 5285 kB
MemUsedTotal: 5328 kB

total used free shared buffers
Mem: 97876 96016 1860 0 92
Swap: 96356 14668 81688
Total: 194232 110684 83548
[G1 Android Development] overpower:
You seem to have a linux-managed backing_swap (/proc/swaps). To get the second listed would have required another "swapon." A pure compcache managed backing_swap doesn't require another swapon besides for ramzswap. No idea though if compcache would prevent you from 'swapon' what it's using. It might even stop managing it, but I'm not sure without testing.

I can't tell if it's compcache managed because the version of compcache we're all using seems to either not output the stats, or doesn't seem to work on the G1.

Can you try the test I proposed earlier to see if you can consistently force the compcache swap to increase and never decrease? I've been testing mine and as I cross over into my backing swap (in your case 64megs used or more) I find it harder and harder to force swap usage to increase. Thanks!
[G1 Android Development] innerspace:
PM'd test results overpower, compcache did just what you expected, phone performance lagged going back to home screen, lag increased with test cycles until suddenly things sped up again. would be interesting to see what android was doing at that time, ddms maybe?
[G1 Android Development] h.nocturna:
you're right, I did have it activate on boot... forgot about a2sd.sh... well, anyways, I removed that portion of the script and just have the backing swap activated in userinit.sh

Now it only shows 1 partition under cat /proc/swaps. Other than that, I can't really tell the difference. I'll how fast it is when I wake up in the morning. These things tend to slow to a crawl overnight so far...
[G1 Android Development] huanyu:
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.
[G1 Android Development] Smokuevo:
how do u use ur script heh
[G1 Android Development] overpower:
Compcache backing_swap

As a note, I finally figured out how to enable a compcache managed backing_swap.

It appears there's a bug with the .5.x module where the order of the parameters matter. This is the opposite of all the documentation.

If you want a backing_swap, the backing_swap parameter must be first. Just noticed that memlimit is ignored.

# insmod ramzswap.ko backing_swap=/dev/block/mmcblk0p3 memlimit_kb=8192
# swapon /dev/ramzswap0
# cat /proc/ramzswap
DiskSize:	31250 kB
MemLimit:	14680 kB
NumReads:	1
NumWrites:	0
FailedReads:	0
FailedWrites:	0
InvalidIO:	0
PagesDiscard:	0
ZeroPages:	0
GoodCompress:	0 %
NoCompress:	0 %
PagesStored:	0
PagesUsed:	0
OrigDataSize:	0 kB
ComprDataSize:	0 kB
MemUsedTotal:	0 kB
[b]BDevNumReads:	0
BDevNumWrites:	0[/b]

Without the memlimit_kb parameter, it will default to 15% of ram, which is about 14 megs.

The bolded sections indicates there is a backing device.
[G1 Android Development] ttabbal:
Thanks! I changed my script and it seems to be working now. It's also reporting 100% "GoodCompress" and shows the status for the block device.

Filename Type Size Used Priority
/dev/ramzswap0 partition 32120 5244 -1

DiskSize: 32130 kB
MemLimit: 14680 kB
NumReads: 62
NumWrites: 594
FailedReads: 0
FailedWrites: 0
InvalidIO: 0
PagesDiscard: 0
ZeroPages: 22
GoodCompress: 100 %
NoCompress: 0 %
PagesStored: 412
PagesUsed: 90
OrigDataSize: 1648 kB
ComprDataSize: 347 kB
MemUsedTotal: 360 kB
BDevNumReads: 6
BDevNumWrites: 160

total used free shared buffers
Mem: 97876 96240 1636 0 1068
Swap: 32120 5244 26876
Total: 129996 101484 28512
[G1 Android Development] dixxa:
maybe it's just me but I've the impressions the phone lag even more with that new method.

this 100% compress seems to eat cpu.
[G1 Android Development] osho741:
Can you post your userinit.sh as a txt file for me so I can install it using terminal and try it out?
[G1 Android Development] ttabbal:
I haven't had much trouble with it. Switching between apps is faster than before and I'm using more swap/compcache. I have swappiness set to 30 right now. The only issue I have had is that I think the phone app got swapped and it took a couple seconds to swap back in. Not a big deal most of the time, but when I'm trying to receive a call and waiting for the dialpad to become available, it kinda sucked. It brought up the FC dialog, but I just hit wait and it was responsive after that. No idea what the primary cause is though.

As I understand it, the 100% compress is because it can move uncompressible data like jpegs off to the swap partition. So it's only compressing data that can be compressed well. Right now, my phone is showing ~12MB original data size, ~3MB memory used. It will take more CPU to decompress that, but it shouldn't be too bad. It might be interesting to use a compression algorithm that's faster but only gets 50% compression to see if that helps. I have no idea how feasible that is. I think I'll try lowering the amount of memory it's using. If I'm allocating 24MB and using 3, that's wasteful. :)
[G1 Android Development] ttabbal:
If you're talking to me, I'm using the one posted in the middle of the thread with configuration options you change by creating files with the touch command. No point in re-posting it. I just changed the command that loads the module to use the syntax mentioned a few posts back.
[G1 Android Development] pshadey:
can you please post a copy of your script.not everyone is mentally capable of know where to make the changes...please and thank you
[G1 Android Development] SRT102JZ:
where it has this line in your script, disksize_kb=16000; change it to this: backing_swap=/dev/block/mmcblk0p3 memlimit_kb=8000; and obviously change the numbers to whatever works for you
[G1 Android Development] SRT102JZ:
im not quite sure if i have BOTH linux-swap AND compcache working at the same time.

things i know is that i do have compcache working and i do have the 3rd partition linux-swap partition on my sdcard.

heres a copy of my userinit.sh

is that ALL that is supposed to be in my userinit.sh? or should i have done something from the thread [MOD]Auto Swap Extension here http://xdaforums.com/showthread.php?t=531988 ?

i havent followed anything in that threads instructions and not sure if i need to since i have CM3.9 and my compcache setup like above.

this stuff confuses me :-/
[G1 Android Development] ttabbal:
Here it is. When you run it, it should give you help info to tell you how to set it up. Set it up to use a backing swap and see how it goes for you. This version has some stuff I like in it, so you may need to change it to suit you. None of my changes should cause much trouble.

The main part of this script is not my work, I just modified it a little to suit me.

Note that even though I tell it 8MB, I end up with this:

Looks like it's not taking my parameter. No big deal, just interesting. Could be a bug, either in the script or the compcache module. Not sure. I haven't investigated it much. For checking things out, do a /system/sd/userinit.sh status and it will output some nice data about what it's doing.

cat /proc/ramzswap
DiskSize: 32130 kB
MemLimit: 14680 kB
NumReads: 3422
NumWrites: 11060
FailedReads: 0
FailedWrites: 0
InvalidIO: 0
PagesDiscard: 263
ZeroPages: 258
GoodCompress: 99 %
NoCompress: 0 %
PagesStored: 4866
PagesUsed: 1343
OrigDataSize: 19464 kB
ComprDataSize: 5160 kB
MemUsedTotal: 5372 kB
BDevNumReads: 911
BDevNumWrites: 3036
[G1 Android Development] pshadey:
Thanks for your help but its not much help im using jasherai's script and i dont see that specific line to alter.
[G1 Android Development] huanyu:
sorry. Here is the instruction

1. unzip the cc.zip

2. Change the parameters in the user.conf

apps2sd=0 #this parameter is useless here (this is for a modified a2sd, )

media2sd=1 #moves media to sd if /system/sd/media exists

compcache=1 #enable compcache

cc_disksize=32 #set size to 32MB

cc_memlimit=8 #set size to 8MB

cc_backingswap=/dev/block/mmcblk0p3 # set backing swap to /dev/block/mmcblk0p3

swappiness=30 # set swappiness to 30

linux_swap_partition=/dev/block/mmcblk0p3 # enable linux swap if compcache is not enabled​

3. push user.conf to /system/sd

4. push userinit.sh to /system/sd

5. reboot

Then it should work
[G1 Android Development] Yaboiaj:
Just making sure, but the file in the original post and instructions should still work solid for 3.6.8.1, correct?
[G1 Android Development] TheMan42:
what if we have A2SD enabled by default, will the effect my current settings as the parameter here is set to "0". Got any terminal commands for this as I'm still not entirely savvy with Shell commands.
[G1 Android Development] dixxa:
This is jasherai's modified script with 16 Mo compcache, 20 swapiness, vfs_cache_pressure 10 by defaut and page-cluster to 0
[G1 Android Development] innerspace:
thx dixxa

was just trying to figure this out and then thought to myself..."myself, why not look at that turtorial thread" and here you were.

appreciate the info, new output exists in status.
[G1 Android Development] huanyu:
It won't effect your a2sd... you need a modified version of a2sd to read the user.conf file.
[G1 Android Development] dixxa:
^^ no problem :) it has the backing swap too :)
[G1 Android Development] innerspace:
yeah that was the part I was trying to figure out, where exactly to plug that short declaration amongst all that code ;)
[G1 Android Development] xdaofficeuser111:
I would like to know .... I have one ext3 partition only for running app2sd. Do I need to create another ext partition for running swap partition??? Previously I just use Swapper to run a file swap ....
[G1 Android Development] h.nocturna:
Yes, you need to use the linux-swap partition to use the backing swap, but as overpower indicated, you need to write the command as backing_swap first if you want to use it. It should look like:

ramzswap.ko backing_swap=/dev/block/mmcblk0p3 memlimit=24000;
[G1 Android Development] xdaofficeuser111:
Cool ... Thanks!

One stupid question - how can I create a linux swap partition on my phone/SD card? In Paragon Partition Manager I only find ext2 and ext3 :(
[G1 Android Development] h.nocturna:
If you flash the new cyanogen's recovery image, there's a tutorial to do it from the command line, don't worry, its realllly easy. Just look under the JACHero thread under developers thread and the instructions to partition each partition is there. :D Good luck.
[G1 Android Development] xdaofficeuser111:
Thanks a lot!

I check Paragon again and found that actually I oversaw the "linux swap" option! I think I will go ahead with Paragon because I am afraid that command line partitioning will format my existing partition (which saves LOTS of application data and any restoration is a VERY PAINFUL process T.T .....)
[G1 Android Development] xdaofficeuser111:
I just use Paragon to create a linux swap partition but cannot get it working .... Searching the forum something like "Swapon" is mentioned .... How do I kick my swap working???
[G1 Android Development] xdaofficeuser111:
Um .... finally have some clues. I use "parted" and "print" and check that I have the swap partition available, but in /etc/fstab no mmcblkop3 is there. Only mmcblkop1 and mmcblkop2 ....

What is the line I am supposed to add to make my swap partition active?
[G1 Android Development] ttabbal:
mkswap /dev/block/mmcblk0p3
[G1 Android Development] tman7510:
The free command gives all 000 for swap

I followed the instructions and copied the userinit.sh to /system/sd. chmodded the file to 755 but after checking status I still have all 0 0 0 for swap. So I followed these instructions

mkswap /dev/block/mmcblk0p3

4. Enable the swap partition

swapon /dev/block/mmcblk0p3

5. Change the swappiness. I'm using 20

echo 20 > /proc/sys/vm/swappiness

6. Run 'free' to see that its enabled

and I get non zero results but 0 in the used. So I run sh /system/sd/userinit.sh and I get "Disabling swap /dev/block/mmcblk0p3" and have all zeros in swap again. cat /proc/swaps give me nothing and cat /proc/ramzswap tells me no such file. I'm using jasherai's script and I'm running the latest cyanogen stable build 3.6.8.1. Any ideas on what I am doing wrong
[G1 Android Development] ttabbal:
Ok, so you can use a standard swap partition. What userinit.sh are you running? I need a copy or a link to the one you downloaded. It sounds to me like you aren't loading the compcache module or it's failing for some reason.

It's normal for swaps that have just been added to have zero used. You have to use the computer for a while for it to decide to swap things. Particularly with 20 swappiness.
[G1 Android Development] My_Name_Is_Neo:
Do i need to add

to my userinit.sh or just adding

in the right place will enable it.

If I dont need to run the top 2 command in the script then do i need to run them atleast once or compcache will enable the swap automagically.
[G1 Android Development] h.nocturna:
I think you still need need to mkswap, but don't turn it on or else you'll go back to linux managed swap.
[G1 Android Development] ttabbal:
OK, just try this userinit.sh. Rename to remove .txt before using it. You don't need to replace your existing script, just copy it to /system/sd (rename it if you don't want to replace your existing script, or backup the one you have).

mount -o remount,rw /system
(copy the file you downloaded from this post to /system/sd/userinit.sh You can also use adb push from your computer.)
cd /system/sd
chmod 755 userinit.sh
rm -r userinit.d
./userinit.sh
touch /system/sd/userinit.d/etc/use_compcache
touch /system/sd/userinit.d/etc/use_compcache_backing
./userinit.sh start
./userinit.sh status

Cut and paste any errors. If you have it, you can use adb shell to make it easy to copy and paste. I use ssh, but you have to install that manually as well, so adb is easier.

This is working for me on CM 3.9.1 and I've used it since about CM 3.6.8. The commands above will set up compcache with a backing swap. You will only see one swap partition in /proc/swaps. That's normal.

Note that you only need to do mkswap once unless you change the partitions for some reason. It's like formatting your ext drive. It doesn't need to be done in your scripts or anything like that.
[G1 Android Development] tman7510:
You can find the script I am using on the bottom of pg21. Also I solved my swap problem by reading the script. I needed to create some files to enable swap :)
[G1 Android Development] tman7510:
I solved my problem by reading the script. You can find the script I'm using at the bottom of page 21
[G1 Android Development] My_Name_Is_Neo:
Ok.. i understood you script. rather than creating a conf file which i saw a few pages back you create files with appropriate names to know what to do in the script.

My question is what is the Media symlinking function doing. i know it is moving media to sd & symlinking, but why? To create space for compcache disk image? If i've aready moved my apps & dalvik cache to sd, then why is there a need to move more stuff out?

Oh is it because it needs more space on system partition and not data partition. if thats the case then can we tell the compcache to create its ramdisk in data partition instead.

did i make nay sense :P
[G1 Android Development] overpower:
The medialink function removes the standard /system/media and replaces it with the /system/sd/media. The purpose of that is mod authors may not populate a full ringtone/notification/ui sound directly, and some people prefer to use what they've collected on their ext3 partition.

It's not a space issue but a settings saving issue.

It was included because it was in the first userinit.sh scripts and some people found it useful. Since it was moved to an uncalled function, it doesn't affect anyone who doesn't know about it.
[G1 Android Development] xdaofficeuser111:
using Rom 3.6.8.1 but compcache fails to start

I flash the 3.6.8.1 rom (without any themes) and followed the procedures to enable compcache but failed ....

I try typing the commands in userinit.sh line by one and I got an error after typing swapon - "Cannot stat /dev/ramzswap0" ....

What happen???? Anything I missed???
[G1 Android Development] Denkai:
check and verify that the commands you are calling are pointing to the kernal you are using, not sure if he upgraded kernals before 3.8.1 and after 3.6.7.
[G1 Android Development] wesbalmer:
Just got a replacement G1 after my Touchscreen died on the first one. Never had a problem using compcache before, but now for some reason I cannot get it to work. I'm pretty sure I've done this all right. I was reading through the userinit, and I can't seem to cd or cat the modules that the script calls for. I cann't even pull them, I get the same 'no such file or directory' error. Any ideas?

Running 3.9.2, 1.4 recovery, 1.33.2005 SPL

Correctly partitioned.

I wonder if someone who comes from a previous build has these modules, I started freshly new today, barely got my replacement. And flashed straight to 3.9.2 after rooting
[G1 Android Development] xdaofficeuser111:
Thanks Denkai.

Um .... what is strange is .... I use the Pre-theme with 3.6.8.1 (http://xdaforums.com/showthread.php?t=535472) everything was going fine ....

I don't know why when I just wipe+flash the 3.6.8.1 rom alone things do not work ....

I checked that every module files are there, and I run every commands line by line to debug what line went wrong ....
[G1 Android Development] Binary100100:
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
[G1 Android Development] huanyu:
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.
[G1 Android Development] Binary100100:
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.
[G1 Android Development] uwonsum:
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.

echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

This is my current setting:

#!/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
[G1 Android Development] ttabbal:
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.
[G1 Android Development] uwonsum:
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.