Skip to main content

Growing and Shrinking RAM in the Nswap Cache

joel

Growing and Shrinking RAM in the Nswap Cache

Joel Tolliver and Tia Newhall

NSWAP is the process of swapping pages of a process to the RAM of other computers in a cluster of computers that are connected through a network, instead of swapping the pages to disk. On each computer in the cluster, a portion of its RAM is designated for Nswap and this network RAM is called the Nswap cache.

By swapping pages to local and network RAM, Nswap is much faster than swapping pages to disk. This summer we worked on making Nswap even more efficient by identifying when there is more idle RAM in order to grow the Nswap cache. Also, when a machine in the system is using lots of its own RAM, we want to shrink the Nswap cache on that machine in order to give the machine back some of its RAM (this is done to decrease the amount of swapping to disk).

Growing the Nswap cache consists of finding idle RAM on a machine and adding these pages to the Nswap cache. Last summer was devoted to trying to figure out when memory on a machine is actually idle. If the list of free pages (freelist) is large, then it is easy to tell there is idle RAM, but sometimes, such as when there is idle RAM in the file cache, it is harder to tell. We only take pages from the freelist to grow the Nswap cache.

Shrinking the Nswap cache is a lot easier to predict on the other hand. When the RAM on a machine is approaching being completely used, we should shrink the Nswap cache to send pages back to the freelist for use as RAM. Even if the pages in the Nswap cache are being used, they will be transferred to another machine's Nswap cache on the network. This process is done so swapping to disk (which is SLOW) can be avoided.