dirty page related kernel parameters
Related Parameters
$ sysctl -a | grep dirty
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 10
vm.dirty_bytes = 0
vm.dirty_ratio = 20
vm.dirty_writeback_centisecs = 500
vm.dirty_expire_centisecs = 3000
vm.dirtytime_expire_seconds = 43200
Parameter Analysis
(1) vm.dirty_background_ratio
The percentage of memory that can be filled with dirty data. This dirty data will be written to disk later, and background processes like pdflush/flush/kdmflush will clear the dirty data. For example, if I have 32G of memory, then 3.2G (10% ratio) of dirty data can stay in memory, and if it exceeds 3.2G, background processes will clean it up.
(2) vm.dirty_ratio
The absolute maximum amount of system memory that can be filled with dirty data. When the system reaches this point, all dirty data must be committed to disk, and all new I/O blocks will be blocked until the dirty data is written to the disk. This is often the cause of long I/O stalls, but it is also a protective mechanism to ensure there is not an excess of dirty data in memory.
(3) vm.dirty_background_bytes and vm.dirty_bytes
Another way to specify these parameters. If the xxx_bytes version is set, then the xxx_ratio version will be 0, and vice versa.
(4) vm.dirty_expire_centisecs
Specifies the lifespan of dirty data. Here its value is 30 seconds. When pdflush/flush/kdmflush runs, they check if any data has exceeded this time limit, and if so, they asynchronously write it to the disk. After all, data staying in memory for too long also poses a risk of loss.
(5) vm.dirty_writeback_centisecs
Specifies how often pdflush/flush/kdmflush processes wake up to check if there is cache that needs to be cleaned.
You can check how much dirty data is in memory with the following command:
cat /proc/vmstat | egrep "dirty|writeback"
Reference
https://www.yugabyte.com/blog/linux-performance-tuning-memory-disk-io/
https://www.thomas-krenn.com/en/wiki/Linux_Page_Cache_Basics
https://www.baeldung.com/linux/file-system-caching