In my last post i showed most of the tweaks i do to my system, here are some more tweaks along with tips for a responsive desktop. Lets start with some kernel parameters

mkdir /etc/sysctl.d/
vim /etc/sysctl.d/50-tweaks.conf

in that file place the following

vm.swappiness = 5
vm.vfs_cache_pressure = 50

vm.dirty_background_ratio = 25
vm.dirty_background_bytes = 0
vm.dirty_ratio = 75
vm.dirty_bytes = 0
vm.dirty_expire_centisecs = 6000
vm.dirty_writeback_centisecs = 2000

These tweaks are designed to improve overall desktop responsiveness, and are not tweaks you would apply to a server or performance critical workstation. Lets detail these settings

  • vm.swapiness = 1 This parameter controls how aggressively the system will use the system swap (partition or file)
  • vm.vfs_cache_pressure = 50 Increasing this increases the rate at which VFS caches are reclaimed
  • vm.dirty_background_ratio = 25 The percentage of system memory the system will use to store dirty pages, or memory pages that need to be written to disk
  • vm.dirty_background_bytes = 0 This is another way to specify the dirty_background, but in bytes rather than percentage. Setting this to 0 lets us use the ratio parameter instead. We could disable the ratio by setting it to 0 and using the bytes instead.
  • vm.dirty_ratio = 75 The absolute maximum system memory that can be used before flushing to disk
  • vm.dirty_bytes = 0 Specify in bytes rather than a percentage
  • vm.dirty_expire_centisecs = 6000 Maximum amount of time something can exist in cache before being written to disk. If you have a laptop with dedicated power and an SSD setting this value is higher is safe. However on a desktop system with no backup power this can lead to data loss. I’ve set this to 60 seconds +vm.dirty_writeback_centisecs = 2000 How often the flush processes wake up to check if data needs to be written to disk

Feel free to tweak these parameters to your liking, these are just the parameters i use. These are settings i have taken from various sources and seem to work for me.

Powertop

Powertop is a utility made by Intel to help tweak your system to reduce power consumption and increase battery life. It shows a lot of detailed stats and helps you tweak your system to remove wasteful resources. While this can be quite complicated Powertop can be fairly automated using the auto tune parameter

powertop --auto-tune

However these values are unlikely to change, so we can have powertop output these tweaks and load them into our rc.local.

powertop --html=power.html
awk -F '</?td ?>' '/tune/ { print $4 }' power.html > tweaks
sudo su -c 'cat tweaks >> /etc/rc.local'

Our tweaked parameters should now load every boot without having to run powertop. Void Linux makes this very easy, as other systems requires us to create various udev rules.

Module tweaks

Another way we can save power is by tweaking some kernel module parameters - specifically the audio and WiFi modules. If you opted to not build kernel modules into the kernel this is fairly easy.

vim /etc/modprobe.d/powersave.conf

add the following to this file

options iwlwifi power_save=1 d0i3_disable=0 uapsd_disable=0
options iwldvm force_cam=0
options snd_hda_intel power_save=1

This will allow intel WiFi to power save along with the intel hda audio. The WiFi tweaks are experimental and might cause issues. I have not noticed any negative effects on my system, but you might need to disable these.

If like me you built your modules into the kernel you have to change your boot options. If you still use grub then add these to your GRUB_CMDLINE_LINUX_DEFAULT options.

vim /etc/default/grub
GRUB_CMD_LINE_LINUX_DEFAULT="...iwlwifi.power_save=1 iwlwifi.di03_disable=0 iwlwifi.uapsd_disab;e=0 iwldvm.force_cam=0 snd_hda_intel.power_save=1"

If you boot using EFI stub, then these need to be added to your in kernel boot option.

make nconfig

Processor type and features —> built-in kernel command line

root=/dev/mmcblk0p3 rootfstype=f2fs iwlwifi.power_save=1 iwlwifi.di03_disable=0 iwlwifi.uapsd_disab;e=0 iwldvm.force_cam=0 snd_hda_intel.power_save=1 quiet

then make and install like we did before

make
cp -v arch/x86/boot/bzImage /boot/vmlinuz-linux-4.13.9
cp -v arch/x86/boot/bzImage /boot/efi/EFI/Linux/BOOTX64.efi

Replace Linux/BOOTX64.efi with your chosen path

Reboot for these to take effect.