Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running on 4G RAM with an extra 6G swap partition, SSD is a pretty decent SAMSUNG MZMPA128HMFU model. System responds very well to workloads when things stay in RAM, but as soon as things reach the swap partition in any meaningful quantity (let say 1GB+ swap used), responsiveness goes completely down the drain during swapping episodes. SSD light stays on for several seconds while apparently loads of stuffs get paged in or out, during this all other IO is blocked. I've seen system load jump from 0.8 to 10 in a few seconds, then drop back down as IO gets going again. When swap is in active use (I keep a bunch of big apps open) these gagging swap episodes happen more and more often as uptime increases (at 26 days now).

I am looking at latencytop, but it isn't telling me much I could go on.

There seems to be no other solution at this point than stop enough apps to be able to do swapoff -a and just stop using swap. Not sure how this affects my usage patterns, I'm almost certain it's going to be enough for the set of apps I regularly run.

Turning vm.swappiness down to 1 doesn't help things. At least not by itself.

Is this some well known thing? What are my options to have decent desktop responsiveness while using virtual memory?

share|improve this question
7  
Using swap unnecessarily is very very silly. If you constantly need to use swap for very active material, you need more RAM. An SSD is orders of magnitude slower than real memory, even though it is noticeably faster than a spinning platter. –  goldilocks Dec 22 '12 at 15:25
2  
Not sure where this "unnecessarily" came from. I run my apps to do real work. Are you saying using swap on Linux is supposed to lock up the system like this by kernel or scheduler design? –  lkraav Dec 22 '12 at 15:37

2 Answers 2

up vote 5 down vote accepted

I'd strongly suggest getting more memory installed so that you are not swapping. Any swapping just KILLS the performance of a Linux or UNIX(tm) system. So install enough memory to stop the swap!

share|improve this answer
1  
Right, but this doesn't explain the technical background of the issue. For example, having used OS X up to Snow Leopard for several years, I did not experience this sort of behavior under similar usage patterns and conditions. How is Linux weaker here? –  lkraav Dec 22 '12 at 20:44
    
@lkraav the technical background is prety much the data transfer speed: RAM is of the order GB/s, SSD is at least one order below that (plus you need to both write and read it). Hence once you hit swap and the system just tries to move the needed pages into RAM as quickly as possible don't be surprised it's not responding as quickly as swapping. And if you jump from one application into another, it will just make things worse. –  peterph Dec 22 '12 at 21:32
    
I understand the premise of device speed differences regarding this issue. But I've been in this business for a longish while and this behavior does not feel "right" at all compared to years of experience with OS X or even Windows, under similar workloads, even during times of slooooooow rotational media. I think this question is morphing into how is Linux swapping algorithms possibly weaker than that of competing OS's or maybe this is some other kernel or userspace configuration problem. I'd really like to find out more about this on kernel level. –  lkraav Dec 23 '12 at 10:25
1  
Similar hardware with similar workload will give you similar performance degration on any platform (Windows, OSX, Linux, Unix, ...). Either you are comparing two different situations or your hardware is malfunctioning. –  jippie Dec 23 '12 at 11:27
2  
I have a feeling that with memory being quite cheap these days there is not the motivation among the kernel developers to improve swapping behavior. It is just not a high priority to them. –  mdpc Apr 18 '13 at 21:10

If your workload really needs more than 6GB of active RAM, then you're not really going to be able to tune anything to make it run faster while swapping.

Some light swap usage isn't necessarily a problem - my 3GB laptop has been running for about 30 days and is using 600MB of swap (on a spinning hard disk, not an SSD), but it's running fine - since only inactive pages have been swapped out so pages rarely (if ever) need to be swapped back in.

If you can't add more RAM to your system, then the next best thing is to look to see which processes are using so much RAM and see if you can eliminate them or do something to reduce their RAM usage. The "top" command is useful for this, just use the "M" command to sort by memory usage.

share|improve this answer
1  
You are confusing paging with swapping. Paging is quite normal (i.e. taking out memory pages that are inactive or not being used into swap space) whereas swapping involves moving an entire process out of memory onto the swap disk. Swapping is only done if the paging process does not provide the required amount of memory needed. –  mdpc Apr 19 '13 at 20:29
    
Modern VM based operating systems don't do what was historically called "swapping" -- swapping entire process address spaces in/out to secondary storage. They all do paging to what is still called a swap file. Thus, many people use the terms interchangeably. The more correct term would probably be "page swapping" (as opposed to just "paging", which could be confused with MMU page mapping). –  Johnny Apr 19 '13 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.