Custom sysctl vm's advice needed

im doing so tweak to my vm settings to adjust system performance to my needs

an i want some thoughts an advice on the ups an downs an possible issues with either of these two lists

an which would better suit my rig thats currently running a 3900x oc’ed to 4.2125ghz with 64gb of ram an twin nvme’s

1st drive - SK Hynix Platinum P41 1 TB (for os,apps)

2nd drive - SK Hynix Gold P31 1 TB (for games , downloads , converts , renders an assorted files)

system tweak 1


sudo sysctl vm.swappiness=133
sudo sysctl vm.dirty_background_ratio=31
sudo sysctl vm.dirty_ratio=75
sudo sysctl vm.vfs_cache_pressure=200
sudo sysctl vm.max_map_count=64000
sudo sysctl vm.watermark_scale_factor=250
sudo sysctl vm.watermark_boost_factor=15000
sudo sysctl vm.zone_reclaim_mode=4
sudo sysctl vm.extfrag_threshold=250
sudo sysctl vm.dirty_expire_centisecs=15000
sudo sysctl vm.dirty_writeback_centisecs=60000
sudo sysctl vm.min_free_kbytes=105000

system tweak 2


sudo sysctl vm.swappiness=155
sudo sysctl vm.dirty_background_ratio=25
sudo sysctl vm.dirty_ratio=75
sudo sysctl vm.vfs_cache_pressure=150
sudo sysctl vm.max_map_count=64000
sudo sysctl vm.watermark_scale_factor=250
sudo sysctl vm.watermark_boost_factor=15000
sudo sysctl vm.zone_reclaim_mode=2
sudo sysctl vm.extfrag_threshold=250
sudo sysctl vm.dirty_expire_centisecs=60000
sudo sysctl vm.dirty_writeback_centisecs=15000
sudo sysctl vm.min_free_kbytes=105000


which might produce the most efficient memory caching an least lag for anything
an how do i correctly make which ever version i go with persist after re-boot

as iv tried before by adjusting the 10-pop-default-settings.conf file but the lines

vm.extfrag_threshold=250
vm.dirty_expire_centisecs=60000
vm.dirty_writeback_centisecs=15000
vm.min_free_kbytes=105000

never actually stick an i have to do them by sudo command after boot

I hope you are using spinning disks instead of flash memory for swap. Sure, it will be 100+ times slower, but it won’t wear out your flash write cycle.

dirtytime_expire_seconds is also an option.

Have a look at this: Documentation for /proc/sys/vm/ — The Linux Kernel documentation

I woupd put these changes into

/etc/sysctl.conf

You might also want to look into the io schedular for storage devices, lots of tunable settings.

https://www.kernel.org/doc/html/latest/block/bfq-iosched.html

1 Like

which is a better config with these timing

vm.dirty_expire_centisecs=60000 vm.dirty_writeback_centisecs=1500

or

vm.dirty_expire_centisecs=1500 vm.dirty_writeback_centisecs=60000

or

vm.dirty_expire_centisecs=1500 vm.dirty_writeback_centisecs=1500

is it better to have matching expire & writebacks or longer expire an shorter writebacks or longer writebacks an shorter expires

whats the ups an downs to any of the configs

iv got a custon zram module of 48gb on one rig with a 3900x,64gb of 3200mhz ram an twin SK Hynix Platinum P41 1 TB ssd’s an

on another rig a custon zram module of 24gb 3900x,32gb of 3200mhz ram an twin SK Hynix Gold P31 1 TB ssd’s

which for both are the best for my uses but id like some advice on tweaking the sysctl.vm settings to get the best responce

my sysctl.vm settings are

sudo sysctl vm.swappiness=133

sudo sysctl vm.page-cluster=1

sudo sysctl vm.dirty_background_ratio=31

sudo sysctl vm.dirty_ratio=75

sudo sysctl vm.vfs_cache_pressure=200

sudo sysctl vm.max_map_count=64000

sudo sysctl vm.watermark_scale_factor=250

sudo sysctl vm.watermark_boost_factor=15000

sudo sysctl vm.zone_reclaim_mode=4

sudo sysctl vm.extfrag_threshold=250

sudo sysctl vm.dirty_expire_centisecs=1500

sudo sysctl vm.dirty_writeback_centisecs=60000

sudo sysctl vm.min_free_kbytes=125000

I don’t like the idea of write caching, may as well save to disk as soon as possible instead of waiting. You are telling Linux that data that is waitong in mempry to be written which is held for 150 seconds to be eligible to be written. This is CENTiseconds, as in 100 percent makes 1 second, not 1000ths, as milliseconds.

But then you also have set to only wake up the writeback every 600 minutes, which is every 10 hours. This means data will still wait almost a minute before it is saved. Again, this is all in CENTiseconds, 100th of 1 second, not milli 1000ths of a second.

I think this is reasonable as you don’t want constant data writes on an ssd, so I would try leave it at 1500 and 6000. This would result in 15 seconds for data being eligible for write back. and 1 minute for actual writeback. This way you don’t lose much data during power loss.

thanks i goofed up that times measuremet 15sec to 1min is what i was going for