System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Confuse page in/out, swap in/out

 
nano_sec
Occasional Contributor

Confuse page in/out, swap in/out

Anyone can kindly help to clarify these term.
What does it mean page in/out, swap in/out?
How dees it different page in/out, swap in/out?
Do these values impact system performance?
3 REPLIES
Suraj K Sankari
Honored Contributor

Re: Confuse page in/out, swap in/out

Hi,
See the below links for your questions.

http://en.wikipedia.org/wiki/Paging
http://en.wikipedia.org/wiki/Page_cache

>>Do these values impact system performance?
Yes, Server performance will slow if your page in/out is slow...

Suraj
Matti_Kurkela
Honored Contributor

Re: Confuse page in/out, swap in/out

Swapping in/out: moving entire processes between system RAM and disk to allow running more programs than you have physical RAM.

Swapping is not used in modern operating systems: paging, a more refined version of the same basic idea, is used instead.

Paging in/out: moving fixed-size memory pages between system RAM and disk. It allows the system to present a "virtual memory" that is significantly larger than actual physical system RAM.

Most programs have some parts of program code that is used relatively rarely: e.g. start-up code that is executed once when a program is starting up and then never again. When a system that uses paging has no free memory left, it finds a Least Recently Used memory page and either just frees it (if it contains program code that can be reloaded from the original program file as necessary) or "pages it out" to a paging area on disk(if it contains application data).

The Memory Management Unit of the processor will detect if any process tries to access a memory that is currently "paged out" to disk. In that case, it will interrupt the memory access, trigger a kernel routine to "page in" the necessary memory page back to RAM, and then resume the memory access.

If a system has "memory pressure", it means the system must often move pages back & forth between the disk and RAM. When this gets bad enough, the system will spend most of its time moving memory pages around and not doing much useful work at all. At this point, it is said that the system is "thrashing."

In HP-UX, the paging area is called "swap" for historical reasons: in ancient HP-UX versions (before HP-UX 5.0, I think), it was actually used for swapping. The same is probably true for most modern OSs.

In non-ancient HP-UX versions, the swap statistics (in "sar -w" for example) will always be zeroes, because the statistics are not appropriate for paging. The swap statistics are maintained in "sar -w" output format for backwards compatibility and Unix standards compliance.

You should look at "vmstat" output instead. The most critical is the number of page-outs: a small amount of page-outs occasionally is OK, but huge spikes or constant page-out activity generally indicates your system needs more RAM.

Page-ins are not so critical, because page-ins will often happen for other reasons too. (One very common reason for page-ins is application code using the mmap(2) system call to memory-map a file for easy access.)

MK
MK
Bill Hassell
Honored Contributor

Re: Confuse page in/out, swap in/out

>> Page-ins are not so critical

Actually, page-in is what the kernel does for every program start as well as returning pages from swap space. SInce every program that runs will be paged in, you can have hundreds of page-ins on a busy system that starts short-lived programs. There is no simple way to separate program starts from returning pages from swap space. So page-outs really measure how fast new processes are starting.

Page-out is the measurement to use. As Matti said, there may be applications using memory mapped files and these can generate a small amount of page-outs. With constant 2-digit page-outs (10-99), the system is low on memory. 3 digits means that your system is starved for memory and performance will be awful. The only two fixes are:

1. Reduce the number of users and applications

2. Add a lot more RAM (double or triple)


Bill Hassell, sysadmin