Reply
Thread Tools
Posts: 66 | Thanked: 17 times | Joined on Dec 2007
#1
I scoured ITT and the net via Google and couldn't find much info on this subject. So I'm going to start a new thread. Since I'm relatively new here I don't know if this is the best area for the thread, but I don't know where else to put it since it applies to N800/810 and OS2007/2008.

Please note:
This thread is not about the standard Nokia FAT swapfile.

This thread is also not for newbies or normal users and is intended for Linux administrators and power users ONLY. What is being discussed in this thread involves major changes to critical parts of the tablet OS which could cause memory corruption, data loss and failure of your SD card. The procedures listed in this thread are not recommended by me, Nokia or most likely anybody else
OK, now that the disclaimers are out of the way, here is the question:

I just now set up a swap partition to replace the Nokia FAT swapfile. I have a 2GB internal SD card which was partitioned into two primary partitions. The second partition is formatted as ext2 for a dual-boot setup. The first partition was set up as fat32, but since I have no use or desire for dos partitions I decided to resize it and convert it to a swap partition which wouldn't be dismounted (causing insufficient memory problems) when the tablet is connected via USB. Since I didn't feel like resizing the partition right away, I decided it would be easier just to make the whole 1GB as swap and see if that worked.

So after creating the partition, running mkswap and then swapon I looked to see if it works. Here is the output of free:

[root@N800 /root]# free
total used free shared buffers
Mem: 127244 84984 42260 0 4
Swap: 998376 0 998376
Total: 1125620 84984 1040636
So, at least according to free, the tablet now has 1GB additional RAM available for programs!

So here is the question for discussion:

What is the optimal size for swap on the N800/810 and what is the max?

Normally the recommended size for swap (for any OS) is
[ 1.5-2 * ( total installed memory ) ]
That has always been the standard. In this instance that would be about 256MB. However, in the case of the N8xx the installed memory is very low and the swap device is uber fast. So how does that affect performance. Will there be thrashing problems which will slow things down? Another question for users of big (somewhat expensive and with lots of data) flash cards is about flash reliability. I could care less about that since my card was $10 and the data is just a backup of my rootfs.
 

The Following User Says Thank You to gnexus For This Useful Post:
Posts: 66 | Thanked: 17 times | Joined on Dec 2007
#2
Just one little observation:

Holy @#%$^ it's a lot faster faster

Update:
The speed increase seems to be more related to the swap type rather than size. In its present configuration the tablet seems more contrained by processor speed than memory. I opened up every app on the tablet at once to test swap usage. Even with 20-30 apps and videos and quake running in the background, and 10 mozilla windows open, the swap usage was only 50% of installed memory. Good news was that there was no thrashing and no crashes - except for Quiver trying to find nonexistent pictures

Last edited by gnexus; 2007-12-29 at 21:57.
 
skeezer65134's Avatar
Posts: 20 | Thanked: 4 times | Joined on Dec 2007
#3
I actually did the same thing, but with about 128MB of SWAP. I don't really use the rest of the 512 card though, so I could theoretically bump it out. I noticed immediately that things ran way faster than with the swap file on a FAT32 filesystem. I thought the 128MB limit would still apply though, good to know it doesn't

EDIT: I don't know if this has changed, but the tablet doesn't load swap partitions on reboot. There's a nice workaround here. I fixed the script and here it is:

Code:
#!/bin/sh
# workaround an issue with mounting swap partition at startup

SWAPX='/dev/mmcblk0p2'

case "$1" in
 start)
   swapon $SWAPX
 ;;
 stop)
   swapoff $SWAPX
 ;;
 restart)
   swapoff $SWAPX
   swapon $SWAPX
 ;;
 reload|force-reload)
   echo "$0: not implemented"
 ;;
 *)
 ;;
esac
Put that in /etc/init.d/swappart.sh and make it executable (chmod 755 /etc/init.d/swappart.sh). You'll have to change the SWAPX location to match your own setup; the one in my example is for the second partion on the internal card. You'll also need make the file execute on boot by linking it in the startup scripts (ln -s /etc/init.d/swappart.sh /etc/rc2.s/S19swappart). Of course, you'll need to be root for all this to work too

Last edited by skeezer65134; 2007-12-30 at 02:19.
 

The Following User Says Thank You to skeezer65134 For This Useful Post:
Posts: 66 | Thanked: 17 times | Joined on Dec 2007
#4
EDIT: I don't know if this has changed, but the tablet doesn't load swap partitions on reboot.
No, it sure doesn't. . .

I already had a script, however, after scouring the net for a while to find something decent and then making my own ( swap wouldn't do much good otherwise, would it?). I still greatly appreciate your nicer looking one, though. I'll likely take yours, add it to mine and revise it a bit. It would be good if we all got on the same page with the scripts so it could be standardized, posted somewhere to help others, and maybe build a deb. The ideal situation would be to scan for existing swap partitions and mount them automagically. Then you could also have a script for users to create a new one on tablets that haven't implemented it.

A couple of pointers:

1) Linux initscripts don't need or use .sh extensions.
2) 'swapon -a' mounts any swap partitions defined in fstab

But first we need to know what the optimal size is, and that's what this thread is for!

Come on people, what's the optimal size for the swap partition when running OpenOffice, KDE and Mplayer all at the same time.
 

The Following User Says Thank You to gnexus For This Useful Post:
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#5
Note that the old "swap size should be at least 2xRAM size" advice only applies to those Unix systems where RAM is mapped to swap, that is, if you have X size RAM you _must_ also have X size swap, and then your virtual memory (VM) is still just X. Only when you add even more swap will your VM get extended.

There are only a few such systems left out there (AIX 4.x was one I think). Linux is not one of them. For Linux, the rule is: "The more RAM you have the less swap you'll need". As 128MB RAM isn't that much it's helpful with some amount of swap. But if you add too much (say, 4-5-6 times RAM size) you may experience that things actually slow down after a while, because lots of application data/code may have been pushed out to swap over the weeks (if you leave applications up and running). I haven't experimented on my N800 yet, but to start with I think I would limit myself to 512MB swap, and probably begin with just 128MB or 256MB.
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
Posts: 66 | Thanked: 17 times | Joined on Dec 2007
#6
Thanks for the post. You are quite correct.

I just used the old rule since it was easy to post. I used 1GB as a starter because I'm lazy and the partition was already there. I've since reduced it down since it had no benefit and I needed the extra space.

But if you add too much (say, 4-5-6 times RAM size) you may experience that things actually slow down after a while, because lots of application data/code may have been pushed out to swap over the weeks (if you leave applications up and running).
That doesn't seem to happen with the N800 for some reason. It's actually quite difficult to get it to use the swap. Maybe thats a kernel config issue. I haven't had it up with swap for weeks yet, however. . .
 
JeffElkins's Avatar
Posts: 273 | Thanked: 15 times | Joined on Oct 2007
#7
I have an internal 8Gb card formatted as ext3. I created a 128Mb swapfile and activate it from /etc/init.d/rcS by adding the command: swapon -a /swapfile. I don't know of any advantages for a separate swap partition for the N800. Am I mistaken?
__________________
My Mac Mini runs Kubuntu
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#8
A swap partition should in principle be faster than a swap file, because with a swap partition the kernel memory management system writes directly to the partition while with a swap file it'll have to go through the filesystem driver and then to the partition the file resides on (longer code and data paths)
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
Posts: 2,152 | Thanked: 1,490 times | Joined on Jan 2006 @ Czech Republic
#9
Originally Posted by TA-t3 View Post
A swap partition should in principle be faster than a swap file, because with a swap partition the kernel memory management system writes directly to the partition while with a swap file it'll have to go through the filesystem driver and then to the partition the file resides on (longer code and data paths)
AFAIK for linux (2.6 at least, maybe 2.4 too) there is no difference. Even with swap file direct device access is used. When swap to file is enabled the file is scanned and logical to physical mapping is done. Apart from speed this solves also deadlocks when filesystem (with swap file) needs to allocate memory.

If file is fragmented there may be some (insignificant?) overhead though. See dmesg log about number of extents when swapon is run.
__________________
Newbies click here before posting. Thanks.

If you really need to PM me with troubleshooting question please consider posting it to the forum instead. It is OK to PM me a link to such post then. Thank you.
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#10
Ah, thanks for the updated info. When swap-to-file was introduced it was an issue (and at least through the 2.2 series, not sure about 2.4 because I didn't use swap-to-file there).

Do you know if this is still true with a FAT32 file system? In principle it should, because an application like the LILO loader does the same kind of mapping you describe. But in an earlier post skeezer reported that there was a noticable difference ("way faster").
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:01.