vmstat – what it is and how to use?

Paging on 386 - address translation (polish texts)
Image via Wikipedia

vmstat provides a summary of various functions within the system, including system wide free memory, paging counters, summarized disk activity, system calls and cpu utilization.

The output of vmstat and description of what each field means:

The first line of output from vmstat shows a summary since boot,
followed by the output over the last 3 seconds for each additional line.

The vmstat command reports the amount of swap space that is free (not reserved or allocated). This is the most useful measure.
Swap space is reserved first, then may be allocated. When a process requests memory via malloc() for example, the address space is created, but real pages are not allocated to it. At this point, swap space is reserved, but not allocated. The first time each page is accessed, a real page of memory is allocated to it and swap space is also allocated.

The vmstat paging counters provide us with some insight as to how busy VM system is, and if there are any memory resource issues.
The first thing to look for in the paging counters is the scan rate. The scan rate is the number of pages per second that the pageout scanner is scanning. If the scan rate is consistently zero, then the pageout scanner is not running, and there must be greater than lotsfree free memory. If the scan rate is zero, then there is no memory shortage. A non-zero scan rate does not always mean there is cause for concern. Remember that as reads and writes occur, pages are taken from the free list and eventually the amount of free memory will fall below lotsfree. In this case, the pageout scanner will be invoked to free up memory, hence a non-zero scan rate.

 

 

Enhanced by Zemanta

Are you swapped? Increase the performance of Linux machine.

With the ever increasing cost of the Hardware, the amount of physical RAM available on the system is increasing day by day. For example, couple of years back, I had a system which was very high end Desktop with 256MB RAM and today I have a 2GB RAM Desktop. So, whats the point.

The Linux systems (right word should be kernel) are desiged to use both RAM and swap partition. Swap partition is a partition on Hard disk and is used mostly like RAM. Problem is that HDD access is always slower than RAM access and hence inherently, the system will work little slower even if you have enough RAM not to use swap. The term \”swappiness\” is used to determine how the kernel should try to seam-balance between the use of RAM and swap. By default, most of the distro\’s have a swappiness of 60. A higher value of swappiness means that the RAM will be swapped out faster.

There are two ways to look at the swappiness:

1) If the user has a higher swappiness then the used memory will be swapped faster to the swap and thus free\’ing the RAM for other useful purposes.

2) A lower value of swappiness would mean that bloaty applications will not be swapped and thus when the user returns to the application, the application would load faster or rather look faster as there will be no swapping from the swap to the RAM.

I personally keep the swappiness to a value of 100 in the Desktop. But then, anyway I kill firefox as soon as I am done and restart when required.

If you see that the RAM is underutilized or feel that the system performance is not that good then you can tickle with this setting and set it to 10-15. How to do it :

Login as roo (\”su -\”)

echo 15 > /proc/sys/vm/swappiness

This will take effect immediately, but if you want to change this value permanently then you can do this(again as root):

echo \”sys.vm.swappiness = 10\” > /etc/sysctl.conf

So play with your swappiness 🙂

\"Enhanced
Enhanced by Zemanta