yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] dm-digital:
For me swap makes a huge difference on my G1/Dream. I use my phone for work and run at least 6 widgets related to the things I need everyday. I've played with many different ROMs and each one needs to be tweaked a little different when it comes to SWAP to optimize performance.

When I don't run SWAP the phone is painfully slow. If I run a single app and return to home screen I wait as the launcher reload. I want to access dialer, I press it and wait. Go into contacts, I wait. Just about everything has to be reloaded when I need to access it. Running music while I doing a little browsing or even check email, forget about it.

Once I have swap properly set up it's like a completely different phone. Going back to my home screen is as fast as hitting the home button. I want to access the dialer and it's up the instant I press the icon. Hopping from app to app is almost instant.

Now maybe if I wasn't running all those widgets, etc. it might not be a big deal, but I need my phone to do a lot and without SWAP it just can't. Well at least in a way that doesn't require you to take a coffee break between tasks.

I could see running a MT3G/Magic it wouldn't be a big deal and I doubt I would need to run SWAP, but with the limited RAM on the G1/Dream SWAP can make a night and day difference. It may still depend how the phone is used but in my case I see the night and day difference.

Currently under CM5.0.7-DS-test1 I run a 64MB SWAP partition with swappiness of 30 on a class 4 card. This combination makes my phone run extremely well. I'm sure a class 6 SD would improve things but but the configuration I have runs beautifully! Sure the SD is slow compared to RAM but if you have to constantly be reloading apps the slow SD still ends up being faster.

With all the testing I've done I have found that with my requirements and configuration a swappiness of 20-30 works best. If I go over 30, performance starts to degrade due to having so much swapping to the SD. If I go below 20, then not enough is being swapped and apps start to reload. It's all about having the perfect balance for your requirements. I'm sure if I changed to a class 6 SD and used my phone in a different way (ie. less widgets) then I would have to change my SWAP settings to optimize the phone performance.

I agree that on some phones SWAP just isn't necessary. But, due to the lack of RAM on a G1/Dream, it is. If you don't run any widgets and have very little on your home screens then you might be able to get away with it. But, if you use your phone beyond that the resources just aren't there.

With a fast SD card and properly set up SWAP, your G1/Dream could perform almost as well as a phone with more RAM. That is the point of SWAP and if you're lacking in the RAM department, it WILL make a difference.
[G1 Android Development] zimphishmonger:
Very nice, this is what I was looking for. Thanks!
[G1 Android Development] philosophics:
i could be in a different situation then the rest of you but I run an 8gb class 6 and just can't afford to be replacing it all the time. That's what swap will do.

Sdcards weren't made to have all that constant writing going on and eventually, mostly sooner then later, the card will fail where the swap partition is and become corrupt.

Unless you're always on top of your backups, that wouldn't be a problem. But if you're like me and don't do backups for no other reason than just being lazy, that would pose to be a potential problem if in which the card fails.

Take it or leave it. Everyone maintains their own mods to their system.

I dont think the device needs swap or ...compcache which I haven't tried yet since the update, when you have the over clocked kernel and even just the ....test1 of CM5.

...test. ha! that's funny. I can see why though. Some wrinkles but still nice enough to wear...

Sent from my HTC Dream using the XDA mobile application powered by Tapatalk
[G1 Android Development] zimphishmonger:
The trick is to buy two of them, as they have lifetime warranties usually and just rotate them out. They are only like $15
[G1 Android Development] dm-digital:
I think it's funny how many people get concerned with wearing out their SD cards. I have been using swap on SD cards for a long time whether it be my phone or EeePC 701 with swap mounted on SD. I have yet to wear out a card and I don't know anyone else who has worn out a card either. Wear leveling balances out the write cycles across the whole card. Sure it does shorten the life of the SD but the SD will more than likely out live the device it's being used in. If wear on those cards were a concern then SSD's wouldn't exist.
[G1 Android Development] ttabbal:
People make a big stink about this, but in reality it's not a big issue. Same with SSD drives for computers. Swap is fine for them. With modern flash memory, you will probably stop using it because it's too slow/small before you kill sectors due to overwrites. If you buy cheap crap SD cards, yes, they fail sooner. But that has little to do with swap. I've had cheap SDs fail on me with damn near read-only use. I also have an SD (better brand) in my G1 that's been there for over a year with swap enabled with no signs of issues. "Replacing it all the time" is a myth, or people are buying the cheapest crap SD card they can find on EBay. Spend $5 more, and you won't have that problem.
[G1 Android Development] happyface_0:
Well said! Sdcards have wear levelling, it's not like it keeps reading/writing to the same area over and over.
[G1 Android Development] philosophics:
like i said, it's all y'alls choice. I have my opinions and you have yours. I will stick with mine and you guys can do with swap what you want to be done with it...

Sent from my HTC Dream using the XDA mobile application powered by Tapatalk
[G1 Android Development] Ajax1885:
Don't post here much, but swap was one of the solutions I turned to in order to improve an issue I was immediately met with on CM 5.0.7.

Whenever I had an app such as, oh I don't know, let's take the browser for example, open and I would hit the home button? It would sit there for a minute, give me a "wtf? Fine..." kind of response before finally wiping out the process and doing it's best to re-assemble the homescreen so I could continue using the phone.

Now this is on a CM set-up that using the following widgets: Power Widget, Set CPU, Advanced Task Manager's widget, Curvefish's 2G/3G on-off widget, the analog clock widget from the HTC Hero (just the big night clock), eight shortcuts, and the search bar.

Far less process intensive than what I'm sure many others run on the screen.

Naturally, with this, came the Launcher lag and general skittishness.

I installed Swapper from the market and set the swappiness to 10, and the swap to 24mb and turned on it's ability to use the swap partition created long ago for running Hero ROMs that hasn't been used in God knows how long.

My problems are gone. CM 5.0.7 is as fast as lightning and I'm noticing no degradation in performance, battery life, or anything else as near as I can tell.

Then again, I have a class 6, so yeah. :P

Worst case scenario? Throw yourself into recovery and reflash your ROM, keeping it that way until you've got the chance to a store to grab another card for a small sum of cash equal to a Big Mac at McDonald's.
[G1 Android Development] senab:
Not exactly, ANY type of widget uses memory (and a fair bit of it). Shortcuts don't which is why I always use shortcuts instead. I'd say you'd be looking at saving 15-20mb of RAM just buy getting rid of them widgets. The screen size of the widgets doesn't really make a difference, the main thing is that fact that each widget needs it's process to run in, all adding a massive overhead no whatever what widget you use.
[G1 Android Development] senab:
Thanks for this, I'll give this a try later. Never liked CC with Backing Swap but have always preferred CC over swap. This might be the perfect combination of the two.
[G1 Android Development] connoisseur:
Thanks for your thread... I was having difficulty trying to set up swap as well as my other unserinit settings...

I'm using your swap settings as well as process kill settings and this thing is flying. Swap allows for that extra memory when its needed while the process kill gets stuff out of the way fast.

I'm attaching my userinit script in case anyone wants it.;)

Also enabled Media 2 SD in this script. Just push your ringtones to /sd-ext/media/audio/ringtones and use this script. If you don't need it just delete those lines.
[G1 Android Development] zimphishmonger:
No problem, I wanted to start a discussion and get others feedback. :D Your memory tweaks in the userinit.sh are very handy, however I prefer to keep it customizable through the use of an app like AutoKiller or Auto Memory Manager.

I have a ton of apps (about 180), however I use AutoKiller on aggressive and autostarts to disable a lot of apps starting at boot-up\hogging ram in the background. I find that swap helps a TON at the beginning, but after several hours (6+) it gets SUPER laggy, and sluggish.

I also noticed that despite having a 96mb swap partition available, it rarely uses above 24MB. I originally was using 60 swappiness, but on some of the above recommendations, I lowered it to 30. Still having issues after a long period of use w/o a reboot, or formatting the swap partition (or reinitializing it)
[G1 Android Development] deimdos:
I'm having problems to set this up... Let's see, I copied userinit.sh to /sd-ext and then I gave it permissions, reboot and not working (checked in terminal with "free" command). I've tried all userinit.sh you guys have posted :(

PD: /sd-ext folder is supposed to be empty after reboot?
[G1 Android Development] vincom2:
It's supposed to contain your userinit.sh at least.
[G1 Android Development] lbcoder:
That is the stupidest thing I've ever heard.

You want to increase the available memory so that you can kill programs to free up memory and therefore NOT USE IT? What's the point?
[G1 Android Development] lbcoder:
Disagreeing does not make you right. This is a matter of FACT.
[G1 Android Development] lbcoder:
You should really think longer about how android manages memory before making any stupid statements. You clearly have NO CLUE.

ANY modern OS? No. Android's memory management scheme is totally different than any other OS. SWAP IS BAD FOR ANDROID.
[G1 Android Development] n171n:
Hi

Thanks for all who have posted information in this thread. It certainly is enlightening. I am using a G1 with cm5.07t1. As I'm a bit of a n00b with these things, I'm using swapper from the market. I have a 96Mb swap partition which is what I am setting the swap file to be on in the advanced settings. I set swap size to 64Mb and Swappiness to 20.

When I set the swap on, and then check in 'Get information', it gives me this:

Memory: 97764 KB

Used: 96068

free: 1696

Swap: 118344 (<-wtf? how did it get to this?!)

Used: 21176

free 97168

Changing the size to 32Mb then gives this:

Swap: 24432 (<-wtf? how did it get to this?!)

Used: 21408

free 3024

I can't seem to make sense of this....

using the terminal 'free' command reflects these figures too...
[G1 Android Development] h.nocturna:
Could you post the busybox that you used to accomplish this? The current one that comes with Cyan5.0.7t2 doesn't have the -p on swapon. Thanks
[G1 Android Development] vincom2:
Look, we might not know all the details, but not everyone here is completely clueless about how android memory management works.

Frankly, I think most of us don't give a damn WHAT'S GOOD FOR ANDROID. What matters to us is WHAT'S GOOD FOR US, THE USERS. It's all very good to cover your ears and say "LA LA android will kill unneeded processes to free up memory so I can open more processes so it should never be swapping things out", but see how long you can say that when you're trying to browse the web and listen to music at the same time and the damn music player will insist on dying every time your browser loads an especially large image.

If we cared about what was BEST FOR THE OS on any other platform, we'd be doing things like setting swappiness to 100 even on the desktop. But we don't, because we don't want to leave the computer alone for 5 mins and come back and wait another 5 mins for it to fault everything back in.

Similarly, we run with swap because, while it's all good to say that android memory management's designed to work a certain way, it's not quite so good when pages reload every time I switch browser tabs.

Sometimes real life > pure theorycraft.
[G1 Android Development] farmatito:
Here is it.
[G1 Android Development] deimdos:
I agree with both things you said, specially with the 2nd one, and the fact is that I've tried with and without swap (I'm not sure if you did) and clearly runs better with it ;-) (at least for me in my phone)

PS: still trying to enable swap in CM5 :-(
[G1 Android Development] quierotacobell:
Where you stuck on?
[G1 Android Development] sd2649:
just download swapper.... it is working great for me on CM5. I have a swap partition, so I just went into settings and selected the "use swap partition" box, set swappiness to 60 and clicked enable swappiness or whatever. working great for me!
[G1 Android Development] PSP_Hacker:
You can also create the user.conf from an app in the market, search for "userinit" or "user.conf" in the market. That's what I do :D

Swapper works well. I've had it since the first days of root (JesusFreke's ROMs), but it won't autorun on boot, so I just use user.conf.
[G1 Android Development] deimdos:
when I reboot after copying userinit.sh (and give it permissions) swap it's not enabled. But something strange is happening, I'm not able to copy files (like ringtones) to the system folders... maybe it's because ES File Explorer doesn't work with CM5 yet (can anybody confirm that?) but I feel it's kinda (****ing) related.

sd264, I'm trying to avoid swapper because I don't want to be starting it everytime I reboot.

PSP_Hacker, when I have a moment I'll take a look at that (I'm supposed to be working right now xD)
[G1 Android Development] titsmaster:
If you have real issues with swap, there is an even easier way to do it. It's really efficient if you don't have an ext partition.

Create a text file (formatted UNIX) with only

swapon /dev/block/mmcblk0p[B][COLOR="Red"]2[/COLOR][/B];
sysctl -w vm.swappiness=[B][COLOR="Red"]40[/COLOR][/B];

As usual, where 2 is the linux-swap partition number (here is FAT-SWAP so 2, FAT-EXT-SWAP is 3, and so on),

and set swappiness whatever you like.

Then, save it and rename it 25swap

Push it to /etc/init.d/

set permissions to rwxr-x---

Reboot, enjoy your swap.
[G1 Android Development] :
I had one die on me. It was only a class 2, though. :P

I agree, though. My new one is Class 6 and it's never had a problem.
[G1 Android Development] n171n:
Swapper help

I revisited swapper and had another play. It seems that it is doing this:

When I first start it, with its setting set to 'swap off' and click get information:

Swappiness: 60

Memory: 97764 KB

Used: 96068

free: 1696

Swap: 24432

Used: 21408

free 3024

Does this mean that there are some default swap set in CMs ROM?

Then, if I set swap on, with the following settings:

Swap partition size: 96Mb

Set to use swap partition (/dev/block/mmcblk03)

Set swap place to /dev/block/mmcblk03/swapfile.swp (I'm not sure if this needs to be set if using partition?)

Swap size: 32Mb

Swappiness: 20

Then I get:

Swappiness: 20

Memory: 97764 KB

Used: 85148

free: 12616

Swap: 118344

Used: 27280

free 91064

I'm not sure how it arrived at the swap value??

Also, with swap on, the phone flies for a while, just as described by others, then totally grinds to a halt and then acore FCs - at this point I turn swap off..

Any ideas on why swapper is reporting what it is?
[G1 Android Development] Pfeffernuss:
This worked beautifully! Have set swappiness to 20, don't know why, I found the swapfile otherwise to fill up rather quickly. Will experiment a bit with the settings.

Thanks for the tip, was getting tired of enabling Swapper after each reboot ;)
[G1 Android Development] tissimo:
I had swap on with my 128mb partition with swappiness set to 10, and seemed to lag after a while (day or two running it). Its probably my slow SD card though. But I ended up just removing the userinit.sh file and running with no swap. Not nearly as bad of a slow down after a day, CM5 doesn't seem to need swap to run well for my use.
[G1 Android Development] ttabbal:
There isn't, not by default. But if you turn CompCache on in Spare Parts, you will have 24MB of swap show up in "free" and friends. Running Compcache AND swap might be a problem, I would pick one, or perhaps CC+Backing swap. There was a report above saying running CC with swap at a lower priority worked well for them, that might be an idea to try if you like. It's far more complex to set up than the Swapper app will do though. You will need an init script to do it properly. userinit.sh, or something in /system/etc/init.d.
[G1 Android Development] ttabbal:
That doesn't surprise me with a class 2 SD. Get a faster card and try again if you want to see how it is, but if it works well for you without swap.... No point in fixing something that isn't broken. :D

Like I've been saying, everyone's work load is different. What works for one might not be ideal for someone else. If you like to experiment, try a few things and see what works for you, then leave it that way. :cool:
[G1 Android Development] n171n:
Thank you very much for this, with compcache off the swap reported values return to 0 when swap is off. I like the idea of using swapper to test things before I commit to them. I am not totally confident with 'pushing' things into places onto disk as I'm not really a Unix person. I downloaded user.conf creator, but saw that someone had commented that if doesn't work on CM 5.07 due to a2sd method.

I will keep playing with the methods posted here and report back.

Thank you for your help.
[G1 Android Development] ttabbal:
Glad to help. I don't see why the user.conf app would have a problem with the apps2sd method, unless it was attempting to do a2sd the old way in the script it generates. There's nothing wrong with using the swapper app to test things out. When you find settings you like, put them in an init script so you don't have to remember to load swapper every time you boot up. If you need help with that, post the settings you want and I or someone else will help you with the scripting.
[G1 Android Development] Pfeffernuss:
Ofcourse I would also like to run without swap. But apps get thrown out of memory with this Rom (on my phone that is). When I use something like eBuddy in the background and go browsing some big sites or even play around on the Market a bit eBuddy closes. Will see if using swap takes care of this "problem". If not I'll be the first to disable it again, as it ofcourse will not make the phone any faster :rolleyes:
[G1 Android Development] ehb224:
ES working fine for me on CM5 test1 and test2. However I did find I need to go into it's settings "root options" and uncheck and then recheck "mount file system" to give me root file RW access every time I needed to modify or cut and paste to a root folder or to my EXT partition (/sd-ext), where my userinit.sh lives.

FWIW, I have a 96MB swap with swappiness set to 10 on my MYTOUCH 3G with 180 apps installed (to both SD and system memory since i ran out of internal memory!) and it FLIES! I am using a class 4 SD card at the moment. I a also running LWP (thanks to firerat's tweak to get it working properly) My userinit.sh is basically the one off of the Cyanogenmod wiki.

Gave up on both Swapper and Droidswap because they don't survive the reboot and, by using ES file manager I can play with my settings by editing the userinit shell script very easily.
[G1 Android Development] deimdos:
FML! that finally worked :D, thanks dude

I had tried everything (wiping, reinstalling etc) without result, everytime I rebooted userinit.sh just disapeared. Swapper worked but I dislike it
[G1 Android Development] Evervoid:
I have a class 6 8gb card. Any tips on how I should set up my partitions?
[G1 Android Development] sd2649:
When SD cards go bump in the night

what exactly happened when it died???

were you able to save your backups(nandroid folder on the fat32 partition and whatnot)? Or did the whole card go kaput?

anyone else know for sure? were their signs of the coming peril?
[G1 Android Development] cal3thousand:
Do this:

512Mb Ext3 - This is plenty... maybe even overkill

96Mb Swap

Rest FAT32

BTW To add to to the swap conversation, I have been running a 96Mb swap on 5.0.7-Test2 for a full day now and it has only improved my phone's performance for how I use it.

/2cents
[G1 Android Development] Evervoid:
Thank you, what swappiness do you use? Also, I'm using the app swapper -- is there any downside to using the program over pushing a file manually?
[G1 Android Development] n171n:
Thanks for the Swapper help!

Just to report back on my first usage of swap and swapper. Thanks to everyone who helped from this thread.

I am using a G1 with cm5.07-t1. I think I have the board with slightly less RAM - I understand that there are 2 variants. With swapper using my 96Mb swap partition I see this in the information it provides:

Swappiness: 10

Memory: 97764 KB

Used: 85148

free: 12616

Swap: 93912 (<- I assume this is set to this due to the size of my partition, and any changes that I make to the 'swap file size' setting in swapper will only come into effect if I don't use a swap partition?)

Used: 27280

free 91064

With this config, and compcache off, my phone has massively changed. It is MUCH more responsive and I don't have to restart it a couple of times a day. To be honest, I'm not sure what I ever did without swap, this has totally changed my whole experience of my G1 :).

Over the last couple of days playing with swapper values, I've found that for my setup; 15 or so widgets and heavy-ish usage, swappiness of 10 works well. There have been a couple of occasions when home seems to REALLY become sluggish, I think that this is because home must've been swapped onto SD and not RAM. If this doesn't sort itself out, I turn swapper off, and then back on and I'm back in business. For running more heavy apps like Copilot, I have switched to swappiness of 20, that way, I can switch out to make a call or check a message, and it remains in memory.

I am using a Class 4 8Gb memory card, but will buy another Class 6 just incase this one goes bang. The experience I get with my phone far outweighs the cost of a replacement card.

I have a couple of questions though:

- farmatito mentions a command called rzstats, now in my limited knowledge of linux, I had a poke around in shell and tried to get the readout in his message, but it seems that I am missing the rzstats command - is this possible?

- If I wanted to setup a script to use a mix of compcache and swap, how would be the best way to do this, and could anybody be kind enough to send me their script and tell me where I need to put it

- Lastly, if I setup my swap in a script user.init or otherwise, then will swapper override this?

Thanks again to everyone in this thread for their help and especially to ttabbal for clarifying the readout from swapper - it was driving me crazy.

Happy swapping!