To swap or not?

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Link.

Kind of interesting. I personally haven't seen any systems with less than 16GB of ram configured without the typical 1.5x memory sized swap, not in a server role anyhow. I personally like the idea of useless stuff being paged out to make room for the stuff I'm using.

On OpenBSD, I don't have much of a problem with swap though. Mozilla, thunderbird, lincity/dopewars, gaim, etc. are all usable immediately without issues. With Mozilla in the mix you'd think I'd be filling up my memory. :p

Anyone seeing a big problem with latency from swap issues?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Well if you don't use an app for a really long time, it can have a big slowdown when you come back to it -- especially if you were doing something earlier that used a lot of memory. But as mentioned in that thread:

1. Swap lets you move unused memory out to disk so you have more ram for fast disk buffers -- I know that filesystem buffering is very often handy for me. You know - when you run some kung-fu one-liner in a shell which takes a while as it goes through a bunch of files, but then is much faster the second, third, etc times?
2. No matter how much ram you buy, you always still have that/those hard drive(s) sitting there, and you can always add some swap for basically free.
3. With swap, you won't all of a sudden have apps randomly crashing when you run out of memory. Instead, you'll generally notice a big slowdown as you start swapping heavily. By the time things start getting killed off, you're probably already well aware of the situation, and you can normally fix it before that happens.

Eh, six of one, half dozen of the other. I don't ever really do anything that sucks up a TON of memory (lots of compiling, but that's not too extreme, and cpu is more of an issue for me there), so my 512 ram + 1G swap serves me quite well.

(edit: woah, I'm using almost 400MB of my memory - without kde or gnome! whoda thunk :p)
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Well if you don't use an app for a really long time, it can have a big slowdown when you come back to it -- especially if you were doing something earlier that used a lot of memory.


Of course (I know you think swap is a good thing, bingbong), but if you use something that uses up a lot of RAM and you try to open up a program you haven't used for a long time it's going to take a long time even if you don't have swap. The thing gets pushed out of RAM either way.

Which I think is a point that most of the "swap sucks" people overlooked.

I mean if you have a server and you open up mozilla and then closed it, how long do you want that stupid thing to be in RAM before it gets removed?

6 hours? 8 hours? 24 hours? 2 weeks? 3 years? Never?

And people want random application to remain in memory for 24 hours since they used that?

I'd rather have a service/script take 10 seconds instead of 30 seconds to complete. Especially if it's a CGI script or whatever and your server performs it a average of 30 times a minute.

Actually the whole "no swap" thing arguement is kinda dissapointing. It's like a Windows-ism were people think they do some fundamental setting change that MS doesn't do and get big performance increases.

Jeez, your Linux users, your suppose to know better then that!

Saying "get rid of swap" as a cure all instead of bothering to do any real research and understand the complexitity of the issue is silly.

What you want to do is understand the fundamental issues your dealing with. Then you'd realise what you realy want is NOT to get rid of swap, but have a different memory management sceme for Desktops vs Workstations vs Servers.

Like the pre-emptive kernel for responsiveness and cpu priority, but for memory managment priorities instead.

Then have a few stupid little sliders you stick in a system configuration tool (that go and change settings in the related files in the /sys directory) to give the "tweakers" and complainers something to play around with while the developers can get on without being attacked for thinking swap is a good idea.

BTW remember the /proc/sys/vm/swappiness file?

Anyone seeing a big problem with latency from swap issues?

The only issues I have is that when I sit down in front of my computer after not using it it takes a few seconds for the desktop to become responsive.

But normally it takes just as long for my monitor to switch on and warm up to the point it's at it's normal brightness. It's a trivial delay.

My memory info, which shows why you don't NEED any swap, but I still want it.

top - 08:15:23 up 11:38, 7 users, load average: 2.04, 0.84, 0.35
Tasks: 74 total, 2 running, 71 sleeping, 0 stopped, 1 zombie
Cpu(s): 96.0% us, 4.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 903792k total, 899392k used, 4400k free, 68236k buffers
Swap: 1052248k total, 0k used, 1052248k free, 248444k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
9750 drag 25 0 209m 80m 85m R 84.8 9.2 0:43.15 ut2004-bin
9642 drag 15 0 139m 46m 88m S 0.0 5.2 0:02.65 soffice.bin
7377 root 5 -10 173m 38m 150m S 0.0 4.4 1:19.64 XFree86
9713 drag 15 0 196m 37m 23m S 0.0 4.3 0:00.48 xine
6910 drag 15 0 95548 33m 31m S 0.0 3.8 0:44.13 firefox-bin
9681 drag 16 0 56096 19m 28m S 0.0 2.3 0:01.71 evolution
7487 drag 16 0 32380 15m 18m S 0.0 1.7 0:01.22 nautilus
9747 drag 15 0 58492 14m 38m S 0.3 1.7 0:00.54 chromium
7485 drag 16 0 22060 14m 16m S 0.0 1.6 0:01.98 gnome-panel
7389 drag 16 0 17336 9712 14m S 0.0 1.1 0:00.32 gnome-session
7498 drag 16 0 16876 9608 15m S 0.0 1.1 0:01.27 wnck-applet
7516 drag 16 0 16380 8664 14m S 0.0 1.0 0:00.25 clock-applet
9685 drag 16 0 24124 8432 18m S 0.0 0.9 0:00.17 evolution-alarm
7460 drag 16 0 17544 8340 15m S 0.0 0.9 0:00.30 gnome-settings-
9683 drag 16 0 29028 6688 23m S 0.0 0.7 0:00.18 evolution-womba
7451 drag 16 0 7004 5728 2968 S 0.0 0.6 0:00.88 gconfd-2
7483 drag 16 0 7856 5144 5588 S 0.0 0.6 0:00.84 openbox
9670 drag 16 0 10876 4444 10m S 0.0 0.5 0:00.03 getstyle-gnome

That's Firefox + OO.rg + UT2004 + Xine playing Matrix with Ac3 passthru + Full gnome 2.6 with nautilus with openbox + evolution + chromium + whatever other crap I have open.

Before I just had mozilla open from yesterday and it was running all night, 11 hours uptime (messing around with hardware stuff before that) and it was riding right at 90000k from normal desktop usage before I even openned up all these apps.

It kept almost everything in memory since yesterday, that is.

Xine started right up, that was the last App I used before I left. Evolution I had closed since yesterday that openned up quickly, no noticable delay vs closing it and openning it up again. It took like 4 seconds to open up vs 1.5 seconds when I close it and open it right away. Oo_Org I had openned up for a second a couple hours before I left the computer in order to copy something to a text file (normal unix-style copy paste stuck spaces before each line). It started up quickly (well fast for Oo_Org)

The only thing that took a long time to open was UT2004, but I didn't play it, but it uses a butt-load by just sitting there. It'll use 500megs during normal play.

I am sure that if I played a serious session of Ut2004 it would of pushed about 15-40megs into the harddrive swap.

No issues here. ;)

Linux version 2.6.5

Remember, that unused memory is wasted memory. You want it filled up. ;)

The higher the ratio percentage used over percentage free is a easy way to measure the intellegence of the memory managment.

My ratio is 204 to 1. Good stuff. :D
 

Haden

Senior member
Nov 21, 2001
578
0
0
I don't think it's big issue, with reasonable RAM amount one can turn it's swap off. I'm running with swap off for some time now - no problems,
not that I had any problems with it.
total used free shared buffers cached
Mem: 1557184 1535716 21468 0 20876 1218220
-/+ buffers/cache: 296620 1260564
Swap: 0 0 0

Up for about 12 hours,
it's obvious to me that I will not hit memory limit under normal circumstances, and there is no point to play swap game - I've already got 1.2GB cache, ~100MB which probably
could be freed by swapping some unused apps won't give me any edge, but could cause delay.

OTOH, I would never run server in such configuration.
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
sunner@litovel:~$ uptime
17:24:19 up 64 days, 23:15, 6 users, load average: 0.13, 0.17, 0.07

sunner@litovel:~$ free -m
total used free shared buffers cached
Mem: 1002 992 10 0 160 348
-/+ buffers/cache: 483 519
Swap: 2047 9 2038

Mem: 1026800k total, 1016628k used, 10172k free, 164476k buffers
Swap: 2097136k total, 10096k used, 2087040k free, 357352k cached

I canlive with that :)