OpenWrt Forum Archive

Topic: Swap not being used?

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'd like to add some swap space to improve performance on NFS transfers on my Wl500gP w/ USB storage (running Kamikaze 7.09).

I installed swap-utils, formatted a 1 GB pen drive to Linux-Swap, plugged it in, and ran "swapon /dev/discs/disc1/part1". The drive does seems to be recognized as swap space:

# free
                    total         used         free       shared      buffers
Mem:        30512        29796          716            0          536
Swap:       990696           0       990620
Total:      1021208        29872       991336

But it seems the swap space isn't being used. The output of "free" shows mostly 0 usage, sometimes it goes up to 76. And that's while I'm writing to my NFS export, and the RAM has all been filled up and rates dropped to about 1MB/sec. (Curiously, RAM stays 99% full even after the transaction has stopped, though I'm not sure that has anything to do with swap).

I've searched the forums, and found 3 people who are describing exactly the same problem: HERE and HERE

Is swap working for anybody? I would appreciate any pointers..

When transferring several large files in one move, I noticed that rates would drop to about 1MB/sec after transferring about 80 MB, but as soon as one file was done and transfer of the next one started, speed went back to 7-10 MB/sec again briefly. But on many occasions, transfers also stalled for about a minute after completing one file.

So... is this the kind of the behavior you would expect on an NFS server with only 32MB of physical RAM at its disposal, or could I be doing better here?

Kamikaze 7.09 is pretty old... .
I'm using trunk with an 2.6.25 kernel on my Asus, and swap seems to be used (currently at 2,9 MB).

(Last edited by KanjiMonster on 7 Jun 2008, 18:15)

KanjiMonster wrote:

Kamikaze 7.09 is pretty old... .
I'm using trunk with an 2.6.25 kernel on my Asus, and swap seems to be used (currently at 2,9 MB).

yes, but the wireless DOESN'T WORK with 2.6 kernels.

loodp wrote:

When transferring several large files in one move, I noticed that rates would drop to about 1MB/sec after transferring about 80 MB, but as soon as one file was done and transfer of the next one started, speed went back to 7-10 MB/sec again briefly. But on many occasions, transfers also stalled for about a minute after completing one file.

So... is this the kind of the behavior you would expect on an NFS server with only 32MB of physical RAM at its disposal, or could I be doing better here?

Yes, this is a general problem of the NFS. Previously I worked in small company which had a NFS server. All the station were without harddisk. We booted from NFS. I saw that the transfers of the large files (as divX movies) from another storage server to this NFS server is 7 MB/s at the beginning (in a 100 Mb network) and begin to decrease to 1 MBs and rested until the completion of the process. All the RAM of my station was used, and the swap also.
The problem is that the linux system doesn't manage the swap partition well. In fact the SWAP purpose is not a RAM replacement. It's a helper. It's very slow to use as a RAM replacement. And when you copy large files (the RAM memory is fulled), the SWAP space  in your case is used. When it's fulled (as in the case of LARGE files) the processor has to do more tasks than ever. The SWAP is used as a buffer space for the incoming (download) ,used for the temporary storage and used for the upcoming (upload) the information from it to the right partition of the external harddisk. It is doing many tasks at once.
And the processor doesn't work well with the SWAP, because the processor works with the RAM, which ram consults the software, which tells that there is a SWAP place as a RAM replacement (when the RAM is fulled with the other softwares ). So there are lots of operations which must be done when SWAP is used.
And SWAP is slow because it's physically on the harddisk, and doesn't communicate directly with the processor.

I tried to simplify my explanation for the sake of simplicity. I hope that I made my point.
I hope that this helps.

If you want more speed, I saw some RAM upgrades for the router. But I wouldn't recommend you.

(Last edited by youth4ever on 10 Jun 2008, 17:51)

youth4ever wrote:

yes, but the wireless DOESN'T WORK with 2.6 kernels.

But that wasn't the question, he asked about swap, not wireless. wink.
Besides, broadcom wireless does not work. One could always replace the minipci card for an e.g. atheros based one (I did).

I would suggest playing with the priority myself, setting it manually rather than the -1 or whatever it goes to by default depending on the times you've run swapon for that reboot, I get better results setting the mmc swap partition I set up on my buffalo to 500 or better. "-p 500"

So you'd need to alter the init.d script with the startup line if you have it set to come up with the fstab uci config entry. I have not messed with it extensively, but as I recall from the manual, it will accept up to a 1000 priority value, giving it the highest priority. As to the validity of what I've observed, only those with further knowledge of what exactly it's doing can comment, for all I know the priority value may ONLY be for swap space, rather than having any impact on when it is called by the kernel as opposed to regular memory. But I'm fairly sure I've noticed it using far more the higher I set it before running down further on physical memory.

(Last edited by yasha on 11 Jun 2008, 15:47)

I tried setting the swap priority higher (swapon [partition] -p [value]), apparently you can use any value from 0 to 32000 something. Didn't change anything though. Swap usage didn't go beyond a couple of bytes. Isn't swap priority only relative? Like, if you've got two swap partitions, to determine which one to use first?

What's curious also is the fact that physical memory is pretty much all used up all the time, no matter what I'm doing currently. That's even when "top" doesn't show any process using more than 1,5% of memory.

I just ran another test with a 200MB file, and I got an average of 999kb/sec writing and 654kb/sec reading. That is just awful.

So.. am I wasting my time here? Is there any way I'll ever get decent NFS or SMB transfer speeds with only 32MB RAM on the router?

I'd have to say, ya, your probably wasting your time if your looking for swap being the solution for this issue. I get more than a few megs of swap used, but it's only AFTER all the memory is used for the most-part that I can tell. The priority only effects multiple swap partitions that are set after reading all the docs I could find. So it has no bearing on when it's actually called.

I'll have to test my throughput later, but my nslu2 seems to do fine with samba. I watch HD shows from it all the time without any issues. I did do the easy 133 to 266 cpu mod a long while back, but everything else is the same as yours.

I can't complain about streaming -- my NFS link is fast enough for that, thank god. But getting the files up there in the first place is a pain in the behind.

System load doesn't seem to be the issue, it hardly gets any higher than 0.4 during the transfer. But when I type "free", tells me physical memory is used up 98% pretty much at all times, whether a transfer is going on at that point or not. So that's why I thought swap should kick in there.

The discussion might have continued from here.