Browse Source

Removes vm.swappiness and vfs_cache_pressure

They were both set at 1 in the same commit without justification
and both can be bad things to set that low.  This commit will
just let the kernel defaults come through.

Details on how bad it is set to these to 1 courtesy of Jay Vosburgh.

vfs_cache_pressure
Setting vfs_cache_pressure to 1 for all cases is likely to cause
excessive memory usage in the dentry and inode caches for most
workloads. For most uses, the default value of 100 is reasonable.

The vfs_cache_pressure value specifies the percentage of objects
in each of the "dentry" and "inode_entry" slab caches used by
filesystems that will be viewed as "freeable" by the slab shrinking
logic. Some other variables also adjust the actual number of objects
that the kernel will try to free, but for the freeable quantity,
a vfs_cache_pressure of 100 will attempt to free 100 times as many
objects in a cache as a setting of 1. Similarly, a vfs_cache_pressure
of 200 will attempt to free twice as many as a setting of 100.

This only comes into play when the kernel has entered reclaim,
i.e., it is trying to free cached objects in order to make space to
satisfy an allocation that would otherwise fail (or an allocation
has already failed or watermarks have been reached and this is
occurring asynchronously). By setting vfs_cache_pressure to 1,
the kernel will disproportionately reclaim pages from the page
cache instead of from the dentry/inode caches, and those will
grow with almost no bound (if vfs_cache_pressure is 0, they will
literally grow without bound until memory is exhausted).

If the system as a whole has a low cache hit ratio on the objects
in the dentry and inode caches, they will simply consume memory
that is kept idle, and force out page cache pages (file data,
block data and anonymous pages). Eventually, the system will resort
to swapping of pages and if all else fails to killing processes to
free memory. With very low vfs_cache_pressure values, it is more
likely that processes will be killed to free memory before
dentry / inode cache objects are released.

We have had several customers alleviate problems be setting
thus value back to the defaults - or having to make them
higher to clean things up after being at 1 for so long.

vm.swappiness
Setting this to 1 will heavily favor (ratio 1:199) releasing file
backed pages over writing anonymous pages to swap ("swapping" a
file backed page just frees the page, as it can be re-read from
its backing file). So, this would, e.g., favor keeping almost all
process anonymous pages (stack, heap, etc), even for idle processes,
in memory over keeping file backed pages in the page cache.

Change-Id: I94186f3e16f61223e362d3db0ddce799ae6120cb
Closes-Bug: 1770171
Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
changes/82/570582/3
Bryan Quigley 1 year ago
parent
commit
3527bf4ae1
1 changed files with 1 additions and 2 deletions
  1. 1
    2
      config.yaml

+ 1
- 2
config.yaml View File

@@ -232,8 +232,7 @@ options:
232 232
   sysctl:
233 233
     type: string
234 234
     default: '{ kernel.pid_max : 2097152, vm.max_map_count : 524288,
235
-                kernel.threads-max: 2097152, vm.vfs_cache_pressure: 1,
236
-                vm.swappiness: 1 }'
235
+                kernel.threads-max: 2097152 }'
237 236
     description: |
238 237
       YAML-formatted associative array of sysctl key/value pairs to be set
239 238
       persistently. By default we set pid_max, max_map_count and

Loading…
Cancel
Save