SWAP - enable or not

Are you going to enable SWAP on your Pandora ?

  • Yes - will have swap partition on NAND

    Votes: 0 0.0%
  • Yes - will have swapfiles/partitions everywhere

    Votes: 0 0.0%

  • Total voters
    25

alastor

Still Fresh
Joined
Oct 23, 2010
Messages
42
Age
31
So, the SWAP adds extra amount of very slow memory ( compared to RAM ). It doesn't speed up anything unless the % usage of RAM becomes very high. But does using SWAP make sense at all on Pandora ?


What would you guys advise: enable SWAP or not ? If yes, then where is it better to have the partion ?


Internal NAND is most likely out of question. ( I assume the SWAP, if being used, will kill the NAND in a matter of months. What I find interesting is the fact that the NAND is the closest to CPU, meaning it has highest priority/communication speed, after cache and RAM of course. )


SDHC cards are probably more reliable, but swapping process would wear them quickly enough, wouldn't it ? However there are two slots, so you could have two swapping threads, which would speed up the SWAP and reduce the load on both cards, I assume.


( I remember some guys were using USB flash drives to speed up their Vista laptops. :lol: )
 
Last edited by a moderator:
i say swap isn't needed, the pandora has tons of memory for a handheld, and if you actually need swap you're doing something too heavy and should just drop it (with a few exceptions of course)


the vista thing is called readyboost, windows simply stores the most used files on there instead of with the rest of the swap, which i don't see how it makes any sense at all, unless microsoft just wanted to make people buy more flash drives that is. shouldn't need a swapfile on a modern pc anyway, if you're using more than 2/3GB of ram things need slimming down a bit :D
 
i say swap isn't needed, the pandora has tons of memory for a handheld, and if you actually need swap you're doing something too heavy and should just drop it (with a few exceptions of course)


the vista thing is called readyboost, windows simply stores the most used files on there instead of with the rest of the swap, which i don't see how it makes any sense at all, unless microsoft just wanted to make people buy more flash drives that is. shouldn't need a swapfile on a modern pc anyway, if you're using more than 2/3GB of ram things need slimming down a bit :D
Ok, I just though about how much wear would it put onto NAND/SDHCs. :)
 
I'd say swapping to NAND is a bad idea, given it can't be replaced when broken.


Not having a Pandora I can only speculate, but usually having swap available helps even if you don't technically need it - "the kernel gets an additional tool to use in its arsenal" as this rather excellent article puts it.


In very general terms, the ability to page out rarely used memory areas makes room for better use of free RAM (for stuff that's actually currently in use or as buffer / cache). As long as your system isn't about to go down because of imminent memory starvation, writing to swap will be rare, and reading common - which makes good use of flash memory properties. Setting a low vm.swappiness value should help to make the read/write ratio better.
 
Last edited by a moderator:
Adding more virtual memory will only very rarely improve execution speed. It's more useful for making something actually run that wouldn't have previously.
 
On my Pandora, I've found memory tends to rarely go above 50% usage. It peaks pretty high when running Firefox/Chromium, deadbeef, and a text editor, but even that doesn't run out. Swap isn't very likely to be needed. You can if you want, a nice to have parachute in case you do do something that requires large amounts of memory, but you're likely to only see a few megs of overage: there'll probably be more wear due to saving games and stuff than from swap. The reason to avoid swap is to actively discourage its use, both in users and developers.


On my beagleboard, however, I run an SSH, http, vnc, irc, and occasional minecraft server, as well as being my irc, bittorrent, and IM clients. Especially when I run the minecraft server, it really gets up in memory, so I've taken to floating a few hundred megs of swap space that regularly gets bumped into. These things, however, are mostly not time sensitive: if my http server hicoughs every once in a while, no one notices. If SSH starts lagging a half second, no big deal. If an emulator drops from 60FPS to 40FPS, people notice, and complain.
 
I prefer having swap there, so things don't crash if I open one too many FF tabs. Suggestions seem to be that a swap file will give better wear leveling than a partition, and I use an SD for it rather than nand.
 
I've thought about this. I think it's always wise to have a swap partition handy, even if it's not likely you'll need it. Of course, I need it on my NanoNote, because it's only got 32M, but the Pandora won't need it likely as not - even so, I've still partitioned 1G out of my 8G SDHC card for swap. The other 7G I'll use for software, and when I get my 64G SDXC card I'll use that for /home.
 
Ok, thanks for the help. :)


I hope this will be useful to other people concerning about SWAP.


So, it wouldn't hurt having 512 MB SWAP file or partition on one or both SDHC/SDXC cards. ( I believe both methods are very close in performance. And I was also using 512 MB swap partition on my PS3 linux, which had < 256 MB of DDR3 RAM available. ) From my own experience, compiling on -03 level, with all optimizations turned on and on the highest possible levels will eat the memory instantly. :lol:
 
It would be nice if somehow you could get an option to use swap only when the program starts needing it. That is, a confirmation window coming up where you give permission to use it. So you can prevent something from suddenly crashing but not let things just take the system down. For most people swap usage would be an exceptional event so it wouldn't be too nagging.
 
Last edited by a moderator:
well, you could put swappiness to near 0 (say 10), and maybe I could write a script which makes a popup when swap actually increases. I don't think you'd be able to do a hold on the memory though. Some applications can be time sensitive without meaning to be: firefox goes to load a new page, request some memory, and pauses for 10 seconds while you fumble for the OK button, and suddenly you've lost all connections you had.


Better to just have a pop up saying "Out of memory: extended into swap space. Performance may be hindered. Please close some things soon." or something. 's'my opinion anyway.
 
They shouldn't be THAT time sensitive, given that they're now relying on getting stuff in and out of swap.. hopefully you'll just press the enter key and not have to pull out the stylus.
 
as far as i can remember, i never used swap on any linux system i used since.. probably around 1998 :) and never noticed anything.. is it really that important ??


kisses


Mac
 
as far as i can remember, i never used swap on any linux system i used since.. probably around 1998 :) and never noticed anything.. is it really that important ??
I'm running a machine with 4GB of RAM (archlinux x86_64, xfce, some devel stuff & firefox) of which there is _free_ (not disk cache) some 928M. I have 1GB of swap (from my earlier configuration with 512M of ram, it used to sometimes need it when I got really tab-crazy with firefox). Anyways, the kernel has still decided that 13M of stuff is so rarely used that it is better to be put into swap. Also, (atleast in the past) some machines have been known to run better with some of RAM designated to be swap than with 100% as RAM: http://kerneltrap.org/node/3660 (Pandora note: this wont work well with only 256M of ram)


Totally illogical, but propably related to the way swap has been integrated into the VM design since before 1994 (atleast).


So yeah, my personal experience has been that linux runs well without swap as long as the VM system is not tasked much. In interactive things (with gui & desktop) it is also not a good idea to have huge amounts of swap on a slow device, because then it can cause a hugely long thrashing time instead of relief brought by the OOM killer.


So eg. my recommendation for the pandora swap size (if one wants to setup a swap partition at all) would be from 64M to 512M. I've needed 512M of swap once on the pandora - that was a heavy compiling job, but it made the device UI unusable for hours... Personally on the pandora I have two 256M swap files that I enable only if needed.


TL;DR Wall of text on swap. Not sure if its any good. Read if you really want to :p
 
Last edited by a moderator:
TL;DR Wall of text on swap. Not sure if its any good. Read if you really want to :p
Maybe I missed it, but he never actually said why swap is better than ram. He made a lot of arguments why swap-in-ram is better than swap-on-disk, but I don't think he really need to make those arguments: it's pretty obvious.


Even the commentators can't agree on why swap is necessary. Closest I can find is someone saying there's a feature/flaw of the 2.4 kernel which behaves better with swap for reasons they don't go into, which is fine with me since we're using 2.6.
 
Unfortunately, discussing swap is about as effective as predicting the weather by using a wet finger and looking at the sky.


The good news is: this method is very good at determining if you need an umbrella in the next hour.


I can think of 2 good reasons to have a swap SD card:


Tab addicts, you use allot of memory while browsing.


Use a very low swapiness value (1-9), the kernel will use up all your main memory before going to swap, effectively preventing your pandora to lock up halfway your HTML5 game.


Native compiling (or every long running process that only uses a fistfull of binaries).


Use a very high swapiness value (90-99), the kernel will swap everything that isn't a running process. make/GCC will really appreciate your kindness. Beware, your X session will not like this, please use on tty only.
 
EDIT: Made a pol to see what people think


SWAP is needed everywhere, I think. I had to stick with < 256 MB of RAM for some time, so I know that it is not much memory even for linux with all staff tweaked. Compiling needs good amount of memory. ( It took 4 hours to compile gnash in terminal, i.e Xorg was switched off completely. )
 
@pol


I voted, I am going to dedicate an old 256 or 512 mb SD card to swap. Just to have it in my *bag of SD cards* that doesn't mean I will dedicate SD-Slot2 to swap.


The pandora is meant to run without swap, I'll only use it whilst pretending my pandora is a 1980's unix super computer. (native compiling)
 
as far as i can remember, i never used swap on any linux system i used since.. probably around 1998 :) and never noticed anything.. is it really that important ??


kisses


Mac
On my oldest system (1992) I had only 16MB RAM, so yes, I added swap. Not too much though. When (some years later) Mozilla was open-sourced I added 128MB swap so that i could compile it. Worked fine.


I also used to optimize Linux installations in the mid-90s for a company in a country where resources were limited, they had some i386 boxes with 8MB RAM. That also needed a leeetle bit of swap space (the optimization I did was to set it up so that it didn't need so much.. otherwise X-windows became unusable, with all the swapping).


I also had swap space on my previous 786MB box (I would upgrade, but alas, it was RAMBUS memory). Firefox had to be restarted all the time. The box I'm currently running has 8GB of RAM and it's the first one where I run entirely without swap.


Going back to ARM, my N800 worked fine for a year with just 128MB RAM and no swap, but I eventually added 128MB swap when I started to use MicroB (firefox-based) and not only Opera, the former use more memory.
 
Back
Top