Swap Space For Gb And Ics
#1
Posted 25 August 2012 - 07:05 PM
CF Bench @1.2ghz Stock 232 ICS Webtop with Swap Space @900MB
Antutu @1.2ghz Stock 232 ICS with Swap Space @900MB
CF Bench @1.2ghz Stock 232 ICS with Swap Space @900MB
Webuntu2sd @1.23
#If someone with 1.3ghz OC can try this out and post antutu benchmark image it would be great!
Download link to flashable init.d swap (must have working init.d for this to work). Thanks to twinkyz1979 for this!
Download link for init.d support. Thanks to twinkyz1979 for this!
*Disclaimer - I do not take credit for this procedure since I had to find bits and pieces from other threads.**I did adjust some of the code accordingly for the Bionic though.**Use this at your own risk!**I AM NOT RESPONSIBLE FOR WHAT YOU DO TO YOUR DEVICE!
Swap space is a partition in Linux based OS’ that allows the users physical ram to be freed by moving unused inactive data to a separate partition (swap) that way freeing up physical ram for the OS and active applications.**In this procedure you will learn how to:
A.**Create a swap partition on your external sd card.
B:**Activate that swap partition through your Android OS.
This is for the multi taskers.**I have seen performance increase in GB and tried my hardest to force close apps by running numerous video, audio, web browser, painting apps etc, and GB kept on ticking with no FC or reboot.**I also saw nice jumps in benchmarks (Antutu : 75-100 point, CF Bench: 100-200+).
**I highly recommend using a class 10 external SD card for this to work optimally (will work with other speeds though).**
***This will decrease the life expectancy of your SD card since you will be reading/writing more than usual.
****This has been tested to work on ICS and performance increase have been verified.**On GB it does increase performance and stability on my phone.
*****I have tried this and found being on stock governor is the most stable.**Stock governor highly recommended.**Over clock is OK.
With that being said...let’s begin-
Creating Swap space partition:
1. Back up your external sd card.
2.**Download MiniTool Partition Wizard Home Edition here --->****
3. Remove external sd card from phone and connect to a pc using an adapter or sd card slot.**Do not do it through your phone!
4.**Depending on how you want to do it you can resize existing partition or start from scratch.**I recommend deleting the existing fat32 partition and starting fresh.**
5. Right click your sd card in mini tools and delete existing partition.
6.**Right click again and create a new fat32 primary partition leaving 512BM(recommended, 1.0GB optimal) available or minimum 200mb of unallocated space.
7. Click apply.
8.**Now create a swap partition in your unallocated space by right clicking and choosing primary linux swap (make sure to use all unallocated space).
8.**Click apply.
9.**Return backed up data.
Detecting and Enabling Swap in Android-
Now that we have our partition you will need to use adb or terminal you will need to do this:
1. In adb or terminal execute this:
********A. su
********B. fdisk -l dev/block/mmcblk0
2. You should see your partition labeled Linux swap, write down the number, remember it, take a picture..lol
3.**Now execute this : swapon /dev/block/mmcblkXXX (XXX being your partitions identifiers).
4. Finally execute this:**echo 100 > /proc/sys/vm/swappiness
5. Finished but this will not survive reboot.**Look below for methods that will.
Creating Smanager script (execute code at boot through script, easiest method) -
******Make sure you have tested code before creating init.d or script
1. Using Smanager (Free from play store) create a new file and name it androidswap.sh
2. Edit the file and add this:
#!/system/bin/sh
swapon /dev/block/mmcblkXXX**************** (XXX being your partitions identifiers)
echo 100 > /proc/sys/vm/swappiness
3.**Save the file.**Right click it and choose open as script executable.
4. Click "su" and "boot" and choose save configuration.
5. Finished.**Now everytime android boots it will execute this and swap will be enabled.
Creating init.d script (you must have init.d support to do this)-
******Make sure you have tested code before creating init.d or script
1.**Using rootexplorer go to /system/etc/init.d and create a new file called androidswap
2. Make dir rw by clicking the rw button at the top.
3. Edit the file and input this and save after-
#!/system/bin/sh
swapon -a
echo 100 > /proc/sys/vm/swappiness
4. Go to /system/etc (make rw again by clicking rw) and create new file and call it fstab
5.**Input this into the file and save:
/dev/block/mmcblkXXX swap swap**********(XXX being your partitions identifiers)
6. Now using adb/terminal execute this:
****A. su
****B. chmod 750 /system/etc/init.d/androidswap**
7.**Finished.**This should survive reboot now. (Note: init.d method would not work for me on GB but it might work for you.**If it doesn't try smanager it's much easier.)
I would like to thank Segnale007 for his work which I used as a template, Sogarth who taught me how to create a linux swap space, twinkyz1979 for testing on ICS leak 238, and the whole Droidhive community!
- johnlgalt likes this
#2
Posted 26 August 2012 - 12:29 PM
- ax562 likes this
#3
Posted 31 August 2012 - 12:17 AM
Confirmed working on 6.7.244
#4
Posted 14 September 2012 - 01:27 AM
the potential benefit of swap partition usage is huge, and given that i have a class 10 this is a no brainer...BUT i realized that v6 supercharge script, as part of default kernel tweaks, is setting vm.swapiness to 20. anyone have any experience with v6 and know what the potential for total FUBAR is if i changed that swapi back to 100?
im gonna end up being the test arent i..
#5
Posted 14 September 2012 - 08:04 PM
#6
Posted 15 September 2012 - 08:04 PM
confirmed on 244 as well (haven't saved init.d persist yet though).
the potential benefit of swap partition usage is huge, and given that i have a class 10 this is a no brainer...BUT i realized that v6 supercharge script, as part of default kernel tweaks, is setting vm.swapiness to 20. anyone have any experience with v6 and know what the potential for total FUBAR is if i changed that swapi back to 100?
im gonna end up being the test arent i..
swappiness "0" means least processes put into swap, or none. swappiness of "100" means most aggressive swapp, most processes possible. Since our devices have a low amount of ram and could be used rather quickly, aggressive swap was suggested(100). Sweet spots for our phones might vary depending on usage and roms etc. For my gb 905 based rom while using webuntu, I found 65 is my sweet spot. I tried 100 swappiness on ics 232 and that is what is pictured in thread. If you are feeling more adventerous try these mods (adjust /dev/webtop/mmcblk0p3 accordingly):
#!/system/bin/sh
sysctl -w vm.oom_kill_allocating_task=1
sysctl -w vm.page-cluster=5
#NEW SCRIPT, BLOCKDEV ONLY WORKED AS SCRIPT FOR ME NO MATTER WHAT, MIGHT WORK FOR YOU
blockdev --setra -w 16384 /dev/webtop/mmcblk0p3
#NEW SCRIPT
#!/system/bin/sh
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "1536,2048,4096,8192,16384,24576" > /sys/module/lowmemorykiller/parameters/minfree
fi
if [ -e /proc/sys/vm/dirty_expire_centisecs ]; then
echo "250" > /proc/sys/vm/dirty_expire_centisecs
fi
if [ -e /proc/sys/vm/dirty_ratio ]; then
echo "10" > /proc/sys/vm/dirty_ratio
fi
if [ -e /proc/sys/vm/dirty_background_ratio ]; then
echo "2" > /proc/sys/vm/dirty_background_ratio
fi
- johnlgalt likes this
#7
Posted 20 September 2012 - 03:11 PM
For 64mb of zram you would do "echo 67108864 > /sys/block/zram0/disksize; mkswap /dev/block/zram0; swapon /dev/block/zram0" (you will also need to make sure to adjust /proc/sys/vm/swappiness. 30-45 is a reasonable value in this case.) It will hold a lot more data than 64mb of physical swap space and it will be accessed lot quicker than it would on an sd card. Plus it won't affect the lifespan of any hardware.
- johnlgalt likes this
#8
Posted 20 September 2012 - 07:06 PM
I mean, if you think about it, if you reserve 64 MB of RAM for swap, that's 64 MB that you cannot use at all. If you free up an app out of memory, it has to fit within that 64 MB in order to be swapped, even if it actually holds more than the 64 MB on sdcard. So, you free up 64 MB of RAM but have already used 64 MB to reserve for swap. net result - 0 MB free.
Am I missing something? IS this a part of the RAM block that is not actually used by anything, just kind of sitting there twiddling it's thumb or something? If so, then my analysis is obviously incorrect....
#9
Posted 21 September 2012 - 02:09 AM
#10
Posted 21 September 2012 - 02:52 AM
#11
Posted 23 September 2012 - 02:39 PM
#12
Posted 23 September 2012 - 06:04 PM
The idea is to sacrifice a small portion of ram so that you can cram a bunch of data into that compressed virtual swap which would otherwise be occupying a greater amount of memory on the unconpressed RAM. Imagine a trash can with a small section that crushes a portion of the garbage really tightly together. Even though it's using space of the trash can, the trash can will ultimately hold more garbage than a standard trash can.
However, that also depends upon how much of a compression ration you get in that 64 MB, *PLUS* there is also the fact that you're now using even more CPU cycles to compress and uncompress. Ax's idea is to free as much RAM as possible, and while this is also a good idea, in practice it can get cumbersome when you have a large program loaded into memory that just needs to be there for whatever reason but cannot fit in the compressed swap in RAM....such as a game that you pause.
I dont mean to imply that it's always better than swapping to the sdcard, but i definitely prefer it since the sd card has a limited number of times it can be written to before fails to hold data properly (i know the sdcard will probably outlast the phone for most people but it's just a peace-of-mind thing for me)
Now, *THAT* I can understand. I tend to keep my phones close to 2 years at a time, so I can see how keeping the SDCard free of swap would be beneficial. However, on the flip side, I just bought an ASUS Transformer Prime, and I think, since it has an external microSD port, (plus another SD port in the docking station) that this might be a very viable option for me, to grab a 2 or 4 GB Class 10 card (if any of those are around still) and use it for swap on that machine permanently... I can always swap out cards one it starts exhibiting symptoms of failure...
not sure how 64mb of compressed data > 1.5GB of tuned swap. The purpose of this is for people that are running a lot of processes simultaneously and using up most of the physical resources. If you are using 64mb of memory for anything trying to improve performance and compressing it, you will most likely see no improvement. If anything using up a nice chunk of your fastest memory, slowing down everything since compression will take up cpu, is probably not a good idea.
No, since it is compressed, with a good, fast processor,you can easily see a performance gain. I did much the same thing when running Gentoo on a P4 box with 3 GB of RAM, I created a (uncompressed) RamDrive of ~ 800 MB, symlinked it to /tmp, and let my machine compile large apps at a speed benefit of around 30% increase. being RAM, it is still faster than access to the microSDCard, even a class 10.
#13
Posted 25 September 2012 - 08:09 PM
However, that also depends upon how much of a compression ration you get in that 64 MB, *PLUS* there is also the fact that you're now using even more CPU cycles to compress and uncompress. Ax's idea is to free as much RAM as possible, and while this is also a good idea, in practice it can get cumbersome when you have a large program loaded into memory that just needs to be there for whatever reason but cannot fit in the compressed swap in RAM....such as a game that you pause.
Now, *THAT* I can understand. I tend to keep my phones close to 2 years at a time, so I can see how keeping the SDCard free of swap would be beneficial. However, on the flip side, I just bought an ASUS Transformer Prime, and I think, since it has an external microSD port, (plus another SD port in the docking station) that this might be a very viable option for me, to grab a 2 or 4 GB Class 10 card (if any of those are around still) and use it for swap on that machine permanently... I can always swap out cards one it starts exhibiting symptoms of failure...
No, since it is compressed, with a good, fast processor,you can easily see a performance gain. I did much the same thing when running Gentoo on a P4 box with 3 GB of RAM, I created a (uncompressed) RamDrive of ~ 800 MB, symlinked it to /tmp, and let my machine compile large apps at a speed benefit of around 30% increase. being RAM, it is still faster than access to the microSDCard, even a class 10.
bet we're still talking about 64MEGABYTES here. Compressing 64mb would probably not use much cpu but its still only 64mb. ICS settings uses almost that much ram.the end.
#14
Posted 26 September 2012 - 12:48 AM
#15
Posted 26 September 2012 - 06:20 AM
Sent from my ASUS Transformer Infinity Running Tapatalk.
#16
Posted 18 December 2012 - 07:09 AM
Also tagged with one or more of these keywords: gingerbread, ics, swap space, swap, memmory, performance, webtop
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users