samrocketman / blog

A personal technical blog. Full featured complete with automated peer review.
http://sam.gleske.net/blog/
Other
5 stars 0 forks source link

Linux performance and swap tips #86

Open samrocketman opened 2 months ago

samrocketman commented 2 months ago

Summary

top

top -H

shortcuts zxc and then press 1 to see CPU core usage. Use < and > to navigate sorting fields.

iotop-c

iotop-c -oPa

shortcuts a (to toggle aggregate or real time stats) and p (to toggle break down by parent process or by pthreads).

ps

View process threads for thread count and more info about the threads. UID 1000

ps -T -u 1000

Disable journald logging

Edit /etc/systemd/journald.conf with

[Journal]
Storage=none
ForwardToSyslog=no

and restart

systemctl restart systemd-journald

Enable swap space and increase swappiness

50% of RAM is conservative but if you want to enable hibernation on laptops you need at least 100% of RAM available as swap.

# allocate disk
dd if=/dev/zero of=/swapfile bs=1G count=16

# prepare swap
chmod 600 /swapfile
mkswap /swapfile

# persist enabling swap on reboot
echo '/swapfile none swap sw 0 0' >> /etc/fstab

# enable swap without needing to reboot
swapon /swapfile

Change swappiness so that Linux kernel has more memory management options. For SSDs, maximum swappiness is okay because of their random access. SSD lifespan is good enough to not worry about it.

# Check swappiness is not already configured
grep vm.swappiness /usr/lib/tuned/*/tuned.conf /etc/sysctl.conf

# read current swappiness (returned 60 which is kernel default)
cat /proc/sys/vm/swappiness

# set swappiness persistent on reboot
echo 'vm.swappiness=100' >> /etc/sysctl.conf

# set swappiness in the current runtime so reboot is not needed
sysctl -w vm.swappiness=100

# verify current swappiness (returned 100)
cat /proc/sys/vm/swappiness

Background reading material

and man pages

man 8 systemd-journald.service
man 5 journald.conf