Top interpretation

Armitage

Banned
Feb 23, 2001
8,086
0
0
Here's the output from top on a box with 8GB of ram:

top - 13:32:44 up 3 days, 4:17, 4 users, load average: 1.10, 1.12, 1.09
Tasks: 125 total, 1 running, 124 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.0% us, 3.2% sy, 0.0% ni, 49.8% id, 43.9% wa, 0.0% hi, 0.2% si
Mem: 7979656k total, 7455752k used, 523904k free, 56020k buffers
Swap: 1052216k total, 0k used, 1052216k free, 6065544k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP DATA COMMAND
25747 mysql 16 0 5464m 1.0g 3912 S 12.0 13.5 4:32.87 4.3g 5.3g mysqld
1 root 16 0 724 256 216 S 0.0 0.0 0:08.04 468 224 init
2 root RT 0 0 0 0 S 0.0 0.0 0:00.05 0 0 migration/0

Note the first process - mysqld. It shows 4.3GB of swap, yet the header shows 0k of swap space used - and in fact there is only 1GB of available swap space. And the actual RAM isn't maxed out yet.

So what is my misunderstanding here? What does the SWAP column in the top output really mean??

 

drag

Elite Member
Jul 4, 2002
8,708
0
0
What it probably means is the amount of memory that is being left untouched as cache.

You have memory that is being actively used, and then if it stops being used usually it's still kept track of so that if you need that information again you don't have to re-read it from disk. If the amount of free memory falls below a certain threshhold then eventually it will be removed to make way for more important data.

For example if you open up a text file edit it, then close it.. if the system has plenty of ram aviable it will just keep the file in memory after it is written out to the disk.. just incase you have to open it again. It's also why when you open up something like openoffice, then close it, then open it again it will open much quicker the second time.

Although I am not sure about that. It's just a guess.

One thing I do know however is that the 'load average' doesn't tell you how busy a computer is. What it tells you is on average how many proccesses are waiting in a I/O command. So if you have a machine with very fast I/O it can have a very low load average compared to a much less busy machine with crappier harddrives/memory. It also depends on the type of workload. Some types of proccessing your going to have very high loads, which is ok, and other stuff high loads would mean something bad.

So take any thing you see with a grain of salt, especially when the terms aren't very discriptive. The stats are more of a 'relative' thing. You look at the stats and everything seems ok, and you get used to it. When things start to get goofy you can then look at the stats again and see were something is very different and it can help troubleshooting.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
From looking at the soure to top, it looks as if swapped is just total size minus resident so at the very best it's a guess, but I don't know why there would be such a discrepency off the top of my head.

But I see the same sort of thing on Debian sid 2.6.8-2-sparc64-smp and as you can see, it's not MySQL specific either.