1 linux kernel

1.1 vm

1.1.1 vfs_cache_pressure

简单说,就是控制page cache的回收,是优先回收data block还是meta block(page cache 包括这两部分),一般情况下建议还是保留meta block缓存。1

kernel设置该值为100,也就是优先回收meta block,会导致文件浏览类的工具速度变慢, 比如find,nautil2



This percentage value controls the tendency of the kernel to reclaim
the memory which is used for caching of directory and inode objects.

At the default value of vfs_cache_pressure=100 the kernel will attempt to
reclaim dentries and inodes at a "fair" rate with respect to pagecache and
swapcache reclaim.  Decreasing vfs_cache_pressure causes the kernel to prefer
to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will
never reclaim dentries and inodes due to memory pressure and this can easily
lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100
causes the kernel to prefer to reclaim dentries and inodes.

Increasing vfs_cache_pressure significantly beyond 100 may have negative
performance impact. Reclaim code needs to take various locks to find freeable
directory and inode objects. With vfs_cache_pressure=1000, it will look for
ten times more freeable objects than there are.

1.1.2 swappiness

简单说,就是先回收page cache还是先swapping anonymous page(也即是应用栈,例如 java heap),缺省设置60,也就是先swapping,这样回导致应用变得很慢。



This control is used to define how aggressive the kernel will swap
memory pages.  Higher values will increase agressiveness, lower values
decrease the amount of swap.  A value of 0 instructs the kernel not to
initiate swap until the amount of free and file-backed pages is less
than the high water mark in a zone.

The default value is 60.

blog comments powered by Disqus