System information
180 System Analysis and Tuning Guide
Finally, the workload itself should be examined and tuned as well. If an application is
allowed to run more processes or threads, effectiveness of VM caches can be reduced,
if each process is operating in its own area of the file system. Memory overheads are
also increased. If applications allocate their own buffers or caches, larger caches will
mean that less memory is available for VM caches. However, more processes and
threads can mean more opportunity to overlap and pipeline I/O, and may take better
advantage of multiple cores. Experimentation will be required for the best results.
15.1 Memory Usage
Memory allocations in general can be characterized as “pinned” (also known as “unre-
claimable”), “reclaimable” or “swappable”.
15.1.1 Anonymous Memory
Anonymous memory tends to be program heap and stack memory (for example,
>malloc()). It is reclaimable, except in special cases such as mlock or if there is
no available swap space. Anonymous memory must be written to swap before it can
be reclaimed. Swap I/O (both swapping in and swapping out pages) tends to be less
efficient than pagecache I/O, due to allocation and access patterns.
15.1.2 Pagecache
A cache of file data. When a file is read from disk or network, the contents are stored
in pagecache. No disk or network access is required, if the contents are up-to-date in
pagecache. tmpfs and shared memory segments count toward pagecache.
When a file is written to, the new data is stored in pagecache before being written
back to a disk or the network (making it a write-back cache). When a page has new
data not written back yet, it is called “dirty”. Pages not classified as dirty are “clean”.
Clean pagecache pages can be reclaimed if there is a memory shortage by simply
freeing them. Dirty pages must first be made clean before being reclaimed.
15.1.3 Buffercache
This is a type of pagecache for block devices (for example, /dev/sda). A file system
typically uses the buffercache when accessing its on-disk “meta-data” structures such