Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux performance and swap tips #86

Open
samrocketman opened this issue Jul 10, 2024 · 0 comments
Open

Linux performance and swap tips #86

samrocketman opened this issue Jul 10, 2024 · 0 comments

Comments

@samrocketman
Copy link
Owner

samrocketman commented Jul 10, 2024

Summary

  • Memory via free -m
  • CPU via top
  • Disk IO via iotop-c
  • Disable journald logging to syslog and disable all persistent storage so that it logs in-memory.
  • Enable swap space and change Linux kernel parameter vm.swappiness to 100 (default 60 by the kernel)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant