memory:tune_virtual_memory
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
memory:tune_virtual_memory [2017/04/04 15:05] – peter | memory:tune_virtual_memory [2019/11/30 14:14] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Memory - Tune virtual memory ====== | ||
- | |||
- | Tune the virtual memory subsystem under Linux for better performance. | ||
- | |||
- | <WRAP warning> | ||
- | **WARNING: | ||
- | </ | ||
- | |||
- | ===== / | ||
- | |||
- | The files in the **/ | ||
- | |||
- | <code bash> | ||
- | ls -al / | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | < | ||
- | total 0 | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 block_dump | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 dirty_background_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 dirty_expire_centisecs | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 dirty_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 dirty_writeback_centisecs | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 drop_caches | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 flush_mmap_pages | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 hugetlb_shm_group | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 laptop_mode | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 legacy_va_layout | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 lowmem_reserve_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 max_map_count | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 max_writeback_pages | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 min_free_kbytes | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 min_slab_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 min_unmapped_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 mmap_min_addr | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 nr_hugepages | ||
- | -r--r--r-- 1 root root 0 Oct 16 04:21 nr_pdflush_threads | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 overcommit_memory | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 overcommit_ratio | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 pagecache | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 page-cluster | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 panic_on_oom | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 percpu_pagelist_fraction | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 swappiness | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 swap_token_timeout | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 vfs_cache_pressure | ||
- | -rw-r--r-- 1 root root 0 Oct 16 04:21 zone_reclaim_mode | ||
- | </ | ||
- | |||
- | |||
- | ===== pdflush ===== | ||
- | |||
- | Type the following command to see current wake up time of pdflush: | ||
- | |||
- | <code bash> | ||
- | sysctl vm.dirty_background_ratio | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | < | ||
- | sysctl vm.dirty_background_ratio = 10 | ||
- | </ | ||
- | |||
- | **vm.dirty_background_ratio** contains 10, which is a percentage of total system memory, the number of pages at which the pdflush background writeback daemon will start writing out dirty data. However, for fast RAID based disk system this may cause large flushes of dirty memory pages. | ||
- | |||
- | <code bash> | ||
- | sysctl -w vm.dirty_background_ratio=20 | ||
- | </ | ||
- | |||
- | |||
- | ===== swappiness ===== | ||
- | |||
- | Type the following command to see current default value: | ||
- | |||
- | <code bash> | ||
- | sysctl vm.swappiness | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | < | ||
- | vm.swappiness = 60 | ||
- | </ | ||
- | |||
- | The value 60 defines how aggressively memory pages are swapped to disk. If you do not want swapping, than lower this value. | ||
- | |||
- | <code bash> | ||
- | # sysctl -w vm.swappiness=100 | ||
- | </ | ||
- | |||
- | |||
- | ===== dirty_ratio ===== | ||
- | |||
- | Type the following command: | ||
- | |||
- | <code bash> | ||
- | sysctl vm.dirty_ratio | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | < | ||
- | vm.dirty_ratio = 40 | ||
- | </ | ||
- | |||
- | The value 40 is a percentage of total system memory, the number of pages at which a process which is generating disk writes will itself start writing out dirty data. This is nothing but the ratio at which dirty pages created by application disk writes will be flushed out to disk. A value of 40 mean that data will be written into system memory until the file system cache has a size of 40% of the server’s RAM. So if you have 12GB ram, data will be written into system memory until the file system cache has a size of 4.8G. You change the dirty ratio as follows: | ||
- | |||
- | <code bash> | ||
- | sysctl -w vm.dirty_ratio=25 | ||
- | </ | ||
- | |||
- | |||
- | ===== Making Changes To VM Permanently ===== | ||
- | |||
- | You need to add the settings to **/ | ||
- | |||
- | |||
- | ===== References ===== | ||
- | |||
- | * The /proc filesystem | ||
- | * man page sysctl | ||
- | |||
- | |||
memory/tune_virtual_memory.1491318338.txt.gz · Last modified: 2020/07/15 09:30 (external edit)