I have come up with some tricks to deliver the maximum performance from Arch Linux and most other distribution.
1. Choose your File System Wisely
Using XFS file system for HDD. F2FS for SSD. For thumb drive installation, F2FS with trim disabled.2. Use This Well-Tested Kernel Parameter (Also, Read the Warnings)
The info can be found here: kernel-parameters/etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=skip quiet loglevel=0 rd.systemd.show_status=false nowatchdog mitigations=off libahci.ignore_sss=1"
3. Use ZRAM Instead of Disk-Swap
ZRAM is a compressed section in the RAM itself. You can utilize 6 - 7 GB memory (RAM) if your system has 4 GB.4. Use a Custom Kernel
Use Xanmod kernels or liquorix kernel or zen kernel instead of the stock kernel./etc/makepkg.conf
and in the CFLAGS add -march=native -mtune=native -O3 -fno-plt -pipe
for best performance (-pipe only improves compile time, doesn't affect the quality of the output binary).
Compile with the option:
env _microarchitecture=42 use_numa=n use_tracers=n use_pds=n use_ns=y use_cachy=y makepkg -si
5. Disable Watchdog
Add nowatchdog to your kernel parameter.Run
wdctl
command as root, and check the module for watchdog, blacklist it.
6. Sort Services by Loading Time & Mask Unneeded Services
To sort services by loading time, run the commandsystemd-analyze blame
Now comes the part of masking. If you don't use lvm2-monitor, mask it. On the other hand, systemd-random-seed isn't that necessary for most systems.
For example:
You can also disable systemd-resolved if you have NetworkManager installed, make sure to add this tosystemctl mask lvm2-monitor # if you don't need lvm2-monitor systemctl mask systemd-random-seed # in most desktop systems, it's not needed
/etc/NetworkManager/NetworkManager.conf [main] dns=none systemd-resolved=false
7. Blacklist Unneeded Modules
Modules can hog memory and may slow down your system. You can list all the modules currently required by your system by issuinglsmod
command as regular or root user. Blacklist modules that you don't need.
For me, the
On my system, blacklisting:etc/modprobe.d/blacklists.conf blacklist iTCO_wdt blacklist pcspkr blacklist joydev blacklist mousedev blacklist mac_hid blacklist uvcvideo
- iTCO_wdt: disables watchdog.
- pcspkr disables mobo speaker sounds.
- joydev: disables joystick, that I don't use.
- mousedev: disables PS2 mouse support that my PC and laptop doesn't have a slot for.
- mac_hid: I don't love apple products, and don't need one, so blacklisting this doesn't hurt.
- uvcvideo: To disable the webcam.
You can enable them with the command 'modprobe' when needed. For example,
modprobe joydev
in runtime and then plug a joystick to detect it.
find /lib/modules/`uname -r`/ -type f -name '*ko'
) but they are not really loaded unless you have a device for that. Although they do consume storage, can be avoided during kernel compilation.
8. Access the Internet Faster
When you type a link to your browser's URL bar, you use a server called Domain Name Server (DNS) to resolve it into an IP address.man 5 resolv.conf/etc/resolv.conf options timeout:1 options single-request nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 1.1.1.1
Note that if you use the above, your system won't receive a ping from other computers on the same network (like
ping archlinux
from another system on same network).
Oh, and to prevent NetworkManager from overwriting it:
There's a better way as well! resolv file can be overwritten by many app, just make it immutable!/etc/NetworkManager/NetworkManager.conf [main] dns=none systemd-resolved=false
# chattr +i /etc/resolv.conf
9. Use GCC, Clang or Suitable Compiler for your Application
You see, there exists a Linux distribution called clear Linux. It's compiled with the intel compiler, as a result it's very fast.To make your apps run even faster, use this flags (also discussed above in "Use a Custom Kernel" section!):
-mtune=native -march=native -O3 -pipe
-
mtune=native and-march=native makes the package for your system. For most cases, we compile apps for ourselves, this will make them run significantly faster. -
-O3 optimizes the binary. There are levels beyond O3, like Ofast, but O3 is the max which won't break your apps and packages. -
-pipe doesn't actually affect the quality of the binary, but it makes compile faster a bit, noticeable on low memory systems. To use these flags with makepkg, edit/etc/makepkg.conf
, and add this to the CFLAGS and CXXFLAGS.
Linux is faster than Windows - Is it the compiler?
Slower compiler can denote that it's slow to compile (like Clang compiles faster than GCC), but the binary produced by them is kind of identical. But it's not the case in Microsoft Compiler, it's not optimized and it produces bad binary.
10. Noatime When Mounting Partitions
Appending or prepending noatime to fstab or passing as option during mount/remount will disable writing access time to it. This reduces write on the media, and improves the performance by a tiny tiny bit. This is also suggested for flash drive / SSD users.11. Disable Journaling
While this is not suggested by professionals, but as a day to day user disabling journal helps a lot!Journal logs help you debug your system. But for most of the time journaling may write a lot to your storage, and overtime the logs becomes huge. It's then truncated, but if that's not what you want, you can disable it by editing /etc/systemd/journald.conf, and set:
This doesn't disable the journal daemon, which is a terrible idea, but this disables logging overall. This will reduce disk write and make system more responsive. journal-flush service will also have less overhead and will not cause any additional delay during boot./etc/systemd/journald.conf Storage=none
If you run
journalctl -xe
, you will see no new entries. If you see old entries, delete the directories from /var/log/journal/
.
This is a necessity if you want to increase the lifespan of your SSD or thumb drive or any other flash storage. For HDD, this will speed up the system by a little bit.
12. Use Preload (For HDD Users)
As mentioned it's not for SSD users. If you installed Arch on an HDD or a thumb drive, this could be helpful.If you have memory to cache your apps, you can use preload:
Archwiki - Preload
This uses Markov chain (by default located in
/var/lib/preload/preload.state
) to improve your app launch time by caching them.
13. Fast Video Playback (Only for Intel Users)
You might face slow loading 4K videos on VLC even on a high end desktop let alone laptops, which can't even load HD.To overcome this issue (for intel), you need:
A) intel-media-driver
B) intel-media-sdk
Install them with:
# pacman -S intel-media-driver intel-media-sdkDon't ever forget these packages if you need to watch videos on intel processor!
14. IO Scheduler
Schedulers can help to reduce your systems latency, but they will require a little more processing power.If you are an HDD user, use BFQ IO scheduler.
Phoronix - Linux 5.0 HDD I/O Scheduler Benchmarks - BFQ Takes The Cake
If you are an SSD user, use
mq-deadline
IO scheduler.
If you use NVME SSD, use
none
IO scheduler.
To let your system select the scheduler automatically for you, use a udev rule for that!
1. For SSDs
2. For NVME SSDs/etc/udev/rules.d/60-ssd.rules ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"
3. For HDDs/etc/udev/rules.d/60-nvme.rules ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
The following will set the IO scheduler for all the non-rotational block devices starting from sda to sdzzz or the maximum devices supported by your system./etc/udev/rules.d/60-hdd.rules ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
If you use all of the storage devices or multiple type of storage devices, you can combine all of the rules into the single file:
But I will suggest not using things that you don't use./etc/udev/rules.d/60-ioschedulers.rules # SSDs ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline" # NVME ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none" # HDD ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
To confirm, check:
Here sda (/dev/sda) is the device.cat /sys/block/sda/queue/scheduler [mq-deadline] none
These tips should increase performance significantly. It's not hard to see 25 - 50% boost in your boot time to system performance. Some will reduce the security to give you the best performance, those points are also mentioned above. Read the post carefully before using them if you have a production server. For regular desktop user, this is not a big deal.
Comments