• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Virtual Memory

OK, so for those that don't know Virtual Memory/Swap is like adding in more RAM for the processor to use. You can get away with running larger programs or work with bigger files typically for a slight performance hit.

What I've done so far is got swap support in the kernel and added a setting in koumamod.apk to adjust the "Swappiness" setting, which is a number from 0 to 100 representing how often the system will move things in and out of the swap ram.
Linux defaults to 60 for this, Android defaults to 0 (because there isn't any swap by default and Android likes to kill processes that aren't active if memory gets low)

I've been using a partition on my sdcard for swap so far. It caused my phone to be a hair slower at times, but barely noticeable. However, I was able to open a flash game on facebook in Dolphin HD and it didn't lock my phone up like usual :D

I'll give the storage that is usually /data a try and see how it does. The nice thing about the swap system is you can use a bunch of swap partitions/files at once and assign them each a priority.

It seems like there is a lot of interest in this, so I'll roll out KoumaKernel 2.5 tomorrow, and work on adding more features to the koumamod menu.

BTW, the koumamod menu is not CTMod exclusive, only the version that hides it's icon from the app drawer is. :D I think I put a version for all other mods that use KoumaKernel in the KoumaKernel thread
are you still using the class 2 card cause i remember reading where you said you were a "cheap bastard" lol...a class 10 should not lag at all
 
Kouma u stay in rubidoux? Dude I just moved out here! Is there anything good to do? It seems mad desolate.. maybe we can both go cherry picking or somethin lmao. Nah but that swap sounds good I think the unused internal would make a good function considering that its just there

You been to In n Out or Farmer Boy's yet? Good cheeseburgers man
also: 23rd Annual Stater Bros. Route 66 Rendezvous
and there is a Six Flags north of you, Knotts in Buena Park, there's also an awesome pirate based dinner show there too.

there is good surfing to the west, wine country toward the north, Skiiing and snowboarding to the northeast, Baja style offroading to the southeast, and Tijuana with all it's Donkey Shows to the south :)
 
You been to In n Out or Farmer Boy's yet? Good cheeseburgers man
also: 23rd Annual Stater Bros. Route 66 Rendezvous
and there is a Six Flags north of you, Knotts in Buena Park, there's also an awesome pirate based dinner show there too.

there is good surfing to the west, wine country toward the north, Skiiing and snowboarding to the northeast, Baja style offroading to the southeast, and Tijuana with all it's Donkey Shows to the south :)

lol theres alot to do here in california. im going to tijuana this sat :p i wonder if i can get my phone to work overthere........
 
lol, reinstalling apps shouldn't be a problem, all you have to do is restore sd-ext after you upgrade to 3.5, I'm quite sure there should be a way to incorporate the tweak files in the flashable zip too, need to find out from someone if they can and if the script needs to be modified to put those tweaks in the right locations...

EDIT: What tweaks are you using in build.prop and what tweak scripts are you using??

im using a crapload of scripts. i need to remove some of them because they are causing lag. jus need to find out which ones. im running on the init folder i have dns.conf, 01edt_tweaks, 02Logger, 03optiflags, 04journalism, 06loopy_smoothness_tweak, 08darky_zipalign, 09setrenice, 10lwp, 11CFSK, 12cleaner, 14enable_touchscreen_1, 15cleanup_init_ram, 16sqlite_optimize, 17speedy_modified, 18complete, 45smurfed, 66citbun, 98kickasskernel, s10sysctl, s02calibration, rtsp. :eek:lol

for the buildprop i just have the camera tweaks and stuff. i found a script that you run in script manager and it adds tweaks and init scripts. its supposeably a collection. but it had some duplicates and i thing thats what made it slower. i used to get 45 seconds start up time and now i get 2 minutes. maybe some of you know which scripts are useless.:confused:
 
and Tijuana with all it's Donkey Shows to the south :)

:ahhhhh: was the smiley you was looking for, not happy face

Anyways, would using the swap as ram have any effect if you used the default swap partition sizes in CWM? (i'm assuming yes since i think thats what CM7 uses swap for). I'm still completely garbage at anything command-line and can't make ADB work. And you can load flash games, but are we talking Pong, or could this thing run something big like Bloons TD 5?
 
:ahhhhh: was the smiley you was looking for, not happy face

Anyways, would using the swap as ram have any effect if you used the default swap partition sizes in CWM? (i'm assuming yes since i think thats what CM7 uses swap for). I'm still completely garbage at anything command-line and can't make ADB work. And you can load flash games, but are we talking Pong, or could this thing run something big like Bloons TD 5?

I got Monster World to load, but it only ran for a couple seconds before flash threw an error, but at least it tried to run. Before, Dolphin would force close with no message, or my phone would lock up. This for certain gains a great deal of stability for the system

Edit: i just went to armor games and tried to play infectionator 2
it was slow and stuttery, and obviously not touch interface optimized, but it ran :D
 
I was reading about this a few weeks back. Some say Android system doesnt benefit from swap do to how it manages memmory bla bla bla. Others say it wears out SD card faster even with wear leveling on the card bla bla bla. I WOULD LOVE TO SEE FOR MYSELF! To much apposing opinion. Good stuff, lets test and see!
 
Virtual memory will be neat; however, I am concerned that if it is on the SD card it may lag. I had KK to mount the whole /data folder on the sd and my phone was super laggy at times (I have a class 10 card) and I ended up on doing the SSM option and I rarely get lags now.
 
This looks like an awesome addition. Just got my 16gb class 10 set up with ssm... no lag, loving it! I can't wait to try this addition!:D
 
hey kouma, I'm currently re-flashing my phone. gimme about 45 minutes after this post so i have time to finish, then release 3.5 so I have to start all over again :)

In any circumstance, whatever you do with the SD-swap, make it adjustable so idiots like me can set something up without having to ADB into it. pretty please...
 
hey kouma, I'm currently re-flashing my phone. gimme about 45 minutes after this post so i have time to finish, then release 2.5 so I have to start all over again :)

Bwahahaahaaa... Story of my life... As soon as phone is perfect, all hell breaks loose, and some new amazing mod/ROM drops and it's back to the drawing board... Lmao
 
ok, so using /dev/stl13 as swap seems to be a bad idea. Each time I've done it, within an hour or so, the phone just shuts itself off
I'm going to try making it an ext filesystem again and placing a swapfile on it, I'll see if that does any different
 
I applied CTMod 3.5 from my 3.2 version this morning. Created a new partition on my 32 gb SD (before backing it up unfortunately and wiped it lol). Made the 4 gb new partition rebooted, then went back in and told it to mount ext SD. Then booted the phone into CTMod Settings selected SSM and rebooted again just to be sure. I'm not sure it is actually using it or if the phone is just super fast because of a new rom and nothing else on it except google voice, facebook, Evernote, and Skype with the base install but it is just great now.

I'm not seeing any extra RAM shows 130mb used and 97mb free. So I guess I missed a step.
 
KoumaKernel2.5_Upgrade_CWM.zip
here's the new KoumaKernel with the swap support in a package that doesn't overwrite your existing koumamod file.

this way the ADB users can get to experimenting.

Here are some tips.

swapon = app for activating a swapfile / partition. the syntax includes a -p option for setting the swap priority (higher priority means that swap memory gets used first. Only needed if you decide to use multiple swaps)
example: swapon -p 10 /dev/block/mmcblk0p3

swapoff = app to stop using a particular swap
example: swapoff /dev/block/mmcblk0p3

mkswap = formatting utility to make a file or device swap memory
example: mkswap /sdcard/swapfile

dd = tool for copying raw data from one location to another. useful for creating empty files to turn into swapfiles. Be careful with this, it's super powerful. It has a lot of options, do some google research if you want to fine tune your usage.
example: dd if=/dev/zero of=/sdcard/swapfile bs=1024 count=1000 (this example makes a file named swapfile in /sdcard that contains 1000 blocks, each block is 1024 bytes)

/proc/sys/vm/swappiness = 'file' that contains a number from 0 to 100 representing how much the system swaps unused data out of physical ram. write to it using echo.
example: echo 60 > /proc/sys/vm/swappiness

/proc/swaps = 'file' that contains a list of active swaps and their usage. read it using cat
example: cat /proc/swaps

free = app for displaying system memory usage. this gives visibility below that of android meaning that any gui tool you try will not be as accurate or as verbose.

happy hunting team :)
 
Wouldnt all of that constant swapping/writing back and forth on the sdcard pretty much kill the life of the sdcard quick? (im only using a sandisk 16GB class 4)
 
Wouldnt all of that constant swapping/writing back and forth on the sdcard pretty much kill the life of the sdcard quick? (im only using a sandisk 16GB class 4)

You are not limited to the sdcard
also, if you're that concerned, you can set the swappiness low, even to 0, at that level, it only swaps pages if you run out of memory.

even at the highest swappiness, if you start burning out memory locations on your sdcard, it will just make you have less swap. It doesn't go "Click" your whole SDcard is now dead. you loose an address, or a block. The card just moves on to the next block and marks that one bad. all the other stuff on your sdcard will be just fine.

or, just not use the swap at all, I don't effing care. It's not like anyone's holding you down and forcing you to
 
I think he explained that above, but it's way over my head. I think I'll stay where I'm at for now. I'm just starting to get over the )))shakes((( from the switch over from CTMod2.5/KK1.2, to CTMod3.5, just finnaly learned adb, and if I start trying to learn something new without knowing the past first, I'm just gonna get lost anyway and make things harder than they actually are. not sure why I shared that with you. nevermind.
 
I think he explained that above, but it's way over my head. I think I'll stay where I'm at for now. I'm just starting to get over the )))shakes((( from the switch over from CTMod2.5/KK1.2, to CTMod3.5, just finnaly learned adb, and if I start trying to learn something new without knowing the past first, I'm just gonna get lost anyway and make things harder than they actually are. not sure why I shared that with you. nevermind.

Don't sweat it dude, it's not that hard. Just don't try to go faster than you are comfortable
 
So Kouma how do we exactly set the swap to enable this function??

I already flashed your KK 2.5... :D

OK, so what do you want to do?

The kernel just opens the door, the world is out there for you to interpret.
I guess the first question would be, do you want to use a file or a partition?

2nd question would be where do you want to put said file/partition?

3rd would be, do you want it to automagically be added when you boot?
 
OK, so I put /dev/stl13 back to ext4.
I then added a directory /system/swap
I then mounted /dev/stl13 as /system/swap
then I ran "dd if=/dev/zero of=/system/swap/swapfile" which just makes the file bigger and bigger till it runs out of space :)
then I did mkswap /system/swap/swapfile
then I attached it as swap by "swapon -p 100 /system/swap/swapfile"
my phone hasn't shut down on me yet, so I might go ahead and add
Code:
mount /dev/stl13 /system/swap
swapon -p 100 /system/swap/swapfile
to one of my init.d script files so it will activate it on boot


My current situation in case anyone was curious:
Code:
# cat /proc/swaps
cat /proc/swaps
Filename                                Type            Size    Used    Priority
/system/swap/swapfile                   file            158516  19608   100
/dev/block/mmcblk0p3                    partition       1940624 0       -1
# free
free
              total         used         free       shared      buffers
  Mem:       290264       280596         9668            0        20376
 Swap:      2099140        19608      2079532
Total:      2389404       300204      2089200
#
 
Which would be better for your first 2 questions, and yes I'd want it to be added at boot...

Better? I dunno, but from my previous post, you can see I'm doing both :)

I have the internal space set at a higher priority than the sdcard partition (which is set to -1 because I added it without a -p option)
I did that because the internal space is a bit quicker than my class 2 card and I have a lot of space set aside on my sdcard. If I run out of ram on the internal, the overflow will go to the sdcard, effectively giving me 10x the stock ram :)
 
Back
Top Bottom