no swap makes system slower - why?

Joris Dobbelsteen Joris at
Tue Nov 6 09:54:58 UTC 2007

>-----Original Message-----
>From: ubuntu-users-bounces at 
>[mailto:ubuntu-users-bounces at] On Behalf Of 
>Derek Broughton
>Sent: maandag 5 november 2007 21:56
>To: ubuntu-users at
>Subject: Re: no swap makes system slower - why?
>Felipe Figueiredo wrote:
>> Questions:
>> 1- Since swap access is slow (disk) compared to real RAM, I would 
>> expect that a swapless setup to be faster.
>Only if you're not actually _using_ that memory.  Swap 
>provides "virtual"
>memory.  If you have programs running that require 2GB of 
>memory, and you only have 1G of ram, things will slow down a LOT.

This an incorrect explaination for why system performance degrades
without swap. Indeed, the swap does allow application that use more RAM
than is physically available to run, but this is not (directly) related
to the observed performance difference.

The reason for this is closely related to why your processors have a
cache. Its very simple: data in fast memory is only useful if its used!
Given that software developers have (had) the luxery of ever increasing
CPU performance and memory sizes, on a generic PC you care only very
little whether the memory you allocate is actually use. There are also
other factors, such as how you use your application/computer. The result
is that parts of the memory are never (or very sporadically) used.
These sporadically used memory segments are good candicated for swap.
Hence, with no swap the system can NOT evict data and it has to remain
in memory. This memory cannot be used for a more useful purpose (mostly
file cache and perhaps application data).
Any modern operating system, Linux, *BSD, Windows have quite good
heuristics to determinate what data to put in swap. None are optimal and
no generic algorithm can ever become that, but still they are very good.

- Joris Dobbelsteen

More information about the ubuntu-users mailing list