Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yonderbread/d9006a65a680031aafcfd8c27fa13078 to your computer and use it in GitHub Desktop.
Save yonderbread/d9006a65a680031aafcfd8c27fa13078 to your computer and use it in GitHub Desktop.
Set of optimizations, I use on my Artix Setup

Everything here is written according to runit in mind, please modify it according to your init(openrc/s6).

Index

1. Selecting the correct init

To select the correct init you should have the knowledge of different init's but if you don't, it might be a problem. But to get you a starting point here are some arrangements that I made.

Speed of Booting

s6-rc >> openrc ≊ runit

Simplicity Of

Usage

runit ≥ openrc > s6-rc

Code

runit > openrc ≊ s6-rc

Ram Usage

runit = openrc >> s6-rc
Note: Runit busybox is the more efficient than standard one.

Features

s6-rc ≥ openrc >> runit

To summarize, every init has its own features and is designed for specific use cases, so you can choose one according to your preference. I am a simple man that's why I selected runit.

2. Silent GRUB

To hide all the grub output which is displayed during boot.
Copy these parameters to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

loglevel=0 console=tty2 udev.log_level=0 vt.global_cursor_default==0

But still, there are some messages that can be hidden like "Welcome to GRUB!" which can be removed by this. Also, you can hide booting messages by going to

sudo nano /boot/grub/grub.cfg

And here you can remove all the echo messages. This provides a clean-looking boot, which I prefer.

3. Turn off Mitigations

You can turn off CPU mitigations for the highest performance, but least security. If you run a lot of unknown code, then you should skip this. To learn how this affects your pc, go here. To know what kind of vulnerability might arise, you can go here
To enable this, add this to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

mitigations=off

4. Disable Watchdog

Watchdog is used to monitor if a system is running. It is supposed to automatically reboot hanged systems due to unrecoverable software errors. Personal computer users don’t need a watchdog, as they can reset the system manually. You can learn more about this from here
To enable this, add this to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

nowatchdog

5. Kernel Parameters

These are some kernel parameters that boost my computer, most of them optimizations are from Clear Linux. These basically disables some checks on boot time, making it faster.

intel_idle.max_cstate=1 cryptomgr.notests initcall_debug intel_iommu=igfx_off no_timer_check noreplace-smp page_alloc.shuffle=1 rcupdate.rcu_expedited=1 tsc=reliable

This is what my GRUB looks like after adding the parameters

#
# Configuration file for GRUB.
#
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=0 console=tty2 udev.log_level=0 vt.global_cursor_default=0 mitigations=off nowatchdog msr.allow_writes=on pcie_aspm=force module.sig_unenforce intel_idle.max_cstate=1 cryptomgr.notests initcall_debug intel_iommu=igfx_off no_timer_check noreplace-smp page_alloc.shuffle=1 rcupdate.rcu_expedited=1 tsc=reliable resume=UUID=b6063c20-d091-4334-8726-55e0ee6b0aed"
GRUB_DISABLE_OS_PROBER=true
GRUB_DISABLE_RECOVERY=true
GRUB_DISABLE_SUBMENU=true

6. Remove Artix logo during boot

After hiding the grub, you would notice that the Artix logo is still being displayed. If you want to remove it you can do this.

sudo rm /etc/issue

7. Custom Kernel

There are many custom kernels(cacule, zen, tkg, hardened, liquorix, xanmod) in the AUR you have to choose according to your requirements.

sudo pacman -S linux-tkg-bmq-generic_v3 linux-tkg-bmq-generic_v3-headers bbswitch-dkms #bbswitch-dkms for optimus-manager

This might not work since I get this from Chaotic Aur
I have played around with a lot of custom kernels, probably all the ones listed here are the ones that I have messed with. But linux-tkg-bmq-generic_v3 fit my requirements best. You probably also have to mess with a few kernels before choosing one.

8. Xorg Config(iGPU)

While using your pc you might find screen tears or graphical bugs, to fix them you need to create a config file

sudo nano /usr/share/X11/xorg.conf.d/20-intel.conf

Place this inside it

Section "Module"
    Load "dri3"
EndSection

Section "Device"
        Identifier      "Intel Graphics"
        Driver          "Intel"
        Option          "AccelMethod"           "sna"
        Option          "TearFree"              "True"
        Option          "Tiling"                "True"
        Option          "SwapbuffersWait"       "True"
        Option          "DRI"                   "3"
EndSection

Note: Please crosscheck this before you use it because this may not be correct for you & might make your Xorg crash.
Note: If your Xorg crashed try commenting some lines under Option & that might fix your issue but if it doesn't just remove the file.

9. Intel Graphic Parameters

These are specific parameters that I use on my setup to boost my intel graphic card, these were picked from the arch wiki according to my hardware specs. You need to go through the wiki to check if the same or other parameters apply to you.

sudo nano /etc/modprobe.d/i915.conf

Place this inside it

options i915 enable_guc=2 enable_dc=4 enable_hangcheck=0 error_capture=0 enable_dp_mst=0 fastboot=1 #parameters may differ

You need to reconfigure your kernel according to these changes.

sudo mkinitcpio -p linux-tkg-bmq-generic_v3

Change the linux-xxx according to the kernel you are using. Note: Please be sure of what you do because this is risky & might give you a complete OS crash.

10. NVIDIA

Way to install NVIDIA Drivers

sudo pacman -S nvidia

Note: This varies according to your kernel since you might require the dkms version.
There is also a nvidia version with some optimizations for performance you can install it instead of nvidia to get some extra fps on games.

yay -S nvidia-dkms-performance

11. Universe Repo

Universe repo from Artix, contains some services which might be useful to you, for example - optimus-manager-runit.
Add this to your pacman.conf

[universe]
Server = https://universe.artixlinux.org/$arch

12. Optimus Manager (Multiple GPUs)

If you have multiple GPU's, then turning both on at all times is unnecessary & just might consume more power or cause your system to heat up. So, Optimus Manager turns your secondary GPU off when not you are not using it, depending on the mechanism(bbswitch, acpi_call...) you choose.

sudo pacman -S optimus-manager-runit bbswitch

You may choose something else if bbswitch doesn't work for you
Then configure the optimus-manager config

sudo nano /etc/optimus-manager/optimus-manager.conf

Then paste this inside your file

[optimus]
switching=bbswitch
pci_power_control=no
pci_remove=no
pci_reset=no

On next boot, check if it's off

cat /proc/acpi/bbswitch #Should output OFF

Note: If bbswitch reports ON then something might be breaking it like powertop. So you might have to fix it or use something else as a replacement.
Note: bbswitch breaks on tkg kernels, so you have to switch to bbswitch-dkms

13. Backlight

The brightness value does not get saved when the system reboots, to fix that you have to install brightness-runit & enable it.

PSD is a service that symlinks & syncs browser profile directories to RAM, thus reducing HDD/SSD calls & speeding up browsers.
You can get it from here. This helps Firefox, Librewolf & Chromium reduce ram usage.

git clone https://github.com/madand/runit-services
cd runit-services
sudo mv psd /etc/runit/sv
sudo ln -sfv /etc/runit/sv/psd /run/runit/service
sudo sv start psd

Note: rsync should also be enabled.

15. Colord

Colord is a system service that makes it easy to manage, install & generate color profiles to accurately color manage input & output devices. You can install it with colord-runit & enable it.

16. EarlyOOM (OOM-killer)

EarlyOOM checks the amount of available memory & swap periodically & kills memory according to the set pre-configured value. You can install it with earlyoom-runit.
To set values, do this

sudo nano /etc/default/earlyoom

Set the EARLYOOM_ARGS to this value

EARLYOOM_ARGS=" -m 96,92 -s 99,99 -r 5 -n --avoid '(^|/)(runit|Xorg|sshd)$'" #change the runit according to your init

You can also experiment with this, I have set this according to my personal preference.

Thermald is a Linux daemon used to prevent the overheating of platforms. This daemon monitors temperature & applies compensation using available cooling methods. You can install it with thermald-runit & enable it.

Ananicy is a simple daemon written in Bash to manage processes' I/O & CPU priorities, with a crowdsourced rule set for popular applications. Fixing bugs for apps & thus reducing chances of crash or lags. You can install it with ananicy-runit & enable it.

Preload is an ‘Adaptive read-ahead Damon’ which effectively what it does speeds up application load time by monitoring the software that is loaded & used day-to-day, the software used most often, & cache them in memory.
Currently, while writing this there didn't exist a preload-runit service so the best way to use it is to get it from the AUR then

sudo nano /etc/rc.local

Put "preload" inside it.

20. Powersaving

1. TLP

TLP is a feature-rich command line utility for Linux, saving laptop battery power without the need to delve deeper into technical details. You can install it with tlp-runit & enable it.
You can configure this with tlp-ui or just with the terminal by

sudo nano /etc/tlp.conf

You can get my tlp.conf here.

PowerTOP is a software utility designed to measure, explain & minimize a computer's electrical power consumption. You can also use powertop instead of TLP or with it, which won't have much significant impact if you use powertop with it.
You can install powertop then enable it with

powertop --auto-tune

inside /etc/rc.local
Currently, I am not using this since it breaks bbswitch for me, so I use some scripts

echo auto > /sys/bus/pci/devices/0000:00:17.0/ata1/power/control
echo auto > /sys/bus/pci/devices/0000:00:17.0/ata2/power/control
echo auto > /sys/bus/pci/devices/0000:00:17.0/ata3/power/control
echo auto > /sys/bus/pci/devices/0000:00:1c.4/power/control
echo disabled > /sys/bus/usb/devices/1-1/power/wakeup
echo auto > /sys/block/sda/device/power/control
echo auto > /sys/bus/usb/devices/1-1/power/control

Which I got from powertop only by playing around with it.
Note: If you use powertop or scripts, you also have to use

echo 60000 > /sys/bus/usb/devices/1-1/power/autosuspend_delay_ms 

The auto suspend timer needs to higher or your external mouse/keyboard may go to sleep again & again which is very annoying adding this line increases the auto suspend counter.

Intel-Undervolt is a tool for undervolting & throttling limits alteration for Intel CPUs. So, we reduce some of the power that is going to our cpu/gpu/cpu-cache.... which results in less battery consumption & less heating, but you have to be sure that it's not too less because otherwise, your system will crash since it's not getting enough power to work. This is not bad for hardware, but you should be sure about what you are doing. You can install it with intel-undervolt-runit & enable it.
You can configure it by

sudo nano /etc/intel-undervolt.conf
sudo intel-undervolt apply

Note: This is very dangerous and might cause system crash. If it is unbootable at some point you can go to a live system and remove execute permission from intel-undervolt/run file. My current under volt config is here.

22. Fstab Modification

Disable File System Check(FSCK)

In Linux, when a file system is mounted for certain times, or its last fsck was more than certain days ago, the system will perform fsck on it when the server reboots. The fsck process can take a few minutes to hours to finish, depending on the file system size. This is more useful on a server machine than a personal computer.
To remove the checks

sudo nano /etc/fstab 

Example:

UUID=f634ad84-2283-4c62-b1ab-d57718e64cbb swap swap sw 0 0
UUID=5c24bcde-e284-457d-b1e1-5845e0e77fb8 / xfs defaults 0 0
UUID=C61D-2685 /boot vfat umask=0077 0 0
tmpfs /tmp tmpfs defaults,nosuid 0 0

The 2 at the end of the first line and 1 at the end of the last line will disable checks for my /boot and my / partition.

Use Noatime instead of Defaults

Turning off atime is a small but effective way to improve system performance. One tweak is atime, which is one of the three timestamps on every file on Linux (more on that later). Since atime is updated every time the file is accessed, my understanding was that it had a significant impact on system performance.
So, get rid of defaults for noatime

sudo nano /etc/fstab 

Example:

UUID=f634ad84-2283-4c62-b1ab-d57718e64cbb swap swap sw 0 0
UUID=5c24bcde-e284-457d-b1e1-5845e0e77fb8 / xfs noatime 0 0
UUID=C61D-2685 /boot vfat umask=0077 0 0
tmpfs /tmp tmpfs noatime,nosuid 0 0

23. Using rEFInd

You can refind instead of grub. Refind has some features that my entice you like its is simpler to use, its more adaptive, its a eye candy, it supports Bios mode, and its faster.

sudo pacman -S refind
sudo refind-install --usedefault /dev/sda

You can go here to know how to configure it and add pacman hooks to modify things according to it. My refind.conf lies here.

24. Removing unnecessary services

The services you don't use can be unlinked/stopped/uninstalled according to your choices, but be careful in removing anything because it may break your system.

sudo pacman -Rscn memtest86+ amd-ucode

Note: I don't have an AMD pc nor do I need to test my memory since I already have that functionality on my hp diagnostics.

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