Skip to content

Instantly share code, notes, and snippets.

@AysadKozanoglu
Forked from marianposaceanu/linux_performance.md
Created September 25, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AysadKozanoglu/e43ad6ce4f42c4d27a64ccb28041b215 to your computer and use it in GitHub Desktop.
Save AysadKozanoglu/e43ad6ce4f42c4d27a64ccb28041b215 to your computer and use it in GitHub Desktop.
Linux simple performance tweaks

Linux simple performance tweaks

Change the I/O Scheduler

Open $ vim /etc/default/grub then add elevator=noop next to GRUB_CMDLINE_LINUX_DEFAULT. Run $ update-grub and $ cat /sys/block/sda/queue/scheduler to be sure that noop is being used:

$ vim /etc/default/grub
$ update-grub
$ cat /sys/block/sda/queue/scheduler
[noop] deadline cfq

noop : a trivial scheduler that just passes down the I/O that comes to it. Useful for checking whether complex I/O scheduling decisions of other schedulers are not causing I/O performance regressions.

In some cases it can be helpful for devices that do I/O scheduling themselves, as intelligent storage, or devices that do not depend on mechanical movement, like SSDs. Usually, the DEADLINE I/O scheduler is a better choice for these devices, but due to less overhead NOOP may produce better performance on certain workloads.

Enable KSM

Open $ vim /sys/kernel/mm/ksm/run and change 0 to 1

Kernel Samepage Merging (KSM) is a feature of the Linux kernel introduced in the 2.6.32 kernel. KSM allows for an application to register with the kernel to have its pages merged with other processes that also register to have their pages merged. For KVM, the KSM mechanism allows for guest virtual machines to share pages with each other. In an environment where many of the guest operating systems are similar, this can result in significant memory savings.

note : this might be useful when running multiple VMs on the same machine

Swappiness and cache pressure

Edit /etc/sysctl.conf and change the values for swappiness and vfs_cache_pressure.

vm.swappiness=10
vm.vfs_cache_pressure=50

You can check current values with:

sudo cat /proc/sys/vm/swappiness
sudo cat /proc/sys/vm/vfs_cache_pressure

swappiness this control is used to define how aggressively the kernel swaps out anonymous memory relative to pagecache and other caches. Increasing the value increases the amount of swapping. The default value is 60.

vfs_cache_pressure this variable controls the tendency of the kernel to reclaim the memory which is used for caching of VFS caches, versus pagecache and swap. Increasing this value increases the rate at which VFS caches are reclaimed.

Mentions

  • disable pagefile not recommanded : swapoff -a

credits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment