Is there a reason to use custom kernels like Linux zen in 2023?
I recently started learning and reading articles about it and I can't find a modern articles. Many of those I've seen was like from 2009 or close. How can I understand that I need an optimized kernel like Linux zen, xanmod, Linux PF? Isn't Linux 6.4.12 that came through thousand of iterations of optimizations enough?
Most of the articles say that it depends on my use case, but non of them provide definitive examples of use cases and when all those cool and difficult-to-understand stuff like CPU schedulers are needed.
I'm a fullstack web developer who uses vs code, terminal, docker, node.js, and chrome 90% of the time. Do I need custom kernel? I would like to make docker containers builds faster. And my 16 GB of RAM are often 90% full. Do I need custom kernel? Will it benefit me?
Edited 31 Aug 2023. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 69 · 90% up
- Kind
- Text
- ID
- 166e96b
57 comments
Zen kernel has LESS throughput than normal (meaning it's worse for development). The advantage is that it also has less latency, which makes it preferable for low-latency (not "realtime"!) desktops and gaming.
This is true, but even for latency, the effect depends on the system, and most users will not benefit from it.
Unless the system is getting 100% CPU utilization, the latency effect will not be there. For games, in the absence of such bottleneck, the latency impact will be like 0.1ms and not noticeable unless the player has superhuman senses. :)
The default
linuxkernel on Arch is already pretty well-optimized.Also, using alternative kernels may unnecessarily complicate the system, requiring the setup of dkms and perhaps other configuration.
This is especially interesting in light of:
most software can't effectively utilize the many cores that are likely available on today's 4c + systems, IIRC. Zen wouldn't be effective then?
Plus, my observation on my old "Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz" T480 CPU, is most of the time, cores run < 5%. Zen wouldn't be effective then?
Your comments appreciated as I try to understand this thread.
This is very speculative. Historically, people like Con Kolivas have proven that different deadlines, schedulers, whatnot can benefit desktop interactivity in general, not just under full load.
How does it perform against newer alternatives like Xanmod and CachyOS kernel in gaming?
I'm curious, what kind of "throughout" you mean?
Debatable, depending on your workflow. If you have a resource intensive, long build process, and you prefer to keep working while it builds in the background, a more responsive system may be advantageous even if the build is slightly slower
OP mentioned:
For that, Zen is objectively worse.
I usually build containers from scratch when deploying them for testing. And usually I don't do anything in parallel, just chill or use chrome for something. I didn't notice any major inconveniences while building containers. It's just slow. Especially when I'm happen to build them for arm architectures. I did many optimizations in docker files, and docker itself to make it faster, but there is still way to go.
I use the Zen kernel because my priority is responsiveness of keyboard and mouse in the UI. Especially and specifically the mouse lagging when under high loads, specifically during gaming. In my particular use case I have a Windows VM running which I interact with either by sharing the mouse through a KVM and running on a separate monitor, or using looking-glass. I also use the software KVM to share my mouse and keyboard from my install to a Windows laptop that I run for my work. These are all split into separate 1920x1080 inputs on a large 4K monitor. If my system is compiling software and the mouse starts to lag while I'm interacting with one of these other devices, that seriously hinders my usability. There are also times when someone in my house may be gaming on the Windows VM through Sunshine/Moonlight and I want my linux system and work laptop to remain as responsive as possible even during heavy workloads on the VM. The only time I have slowdowns right now is if I am running a high thoroughput load on the VM, and try to compile something on my linux system at the same time, and this is specifically because I have used CPU pinning to give all but two of my cores to the VM.
This is an impressive setup you have there!
But, I don't see where you compared performance between the Arch kernel and Zen.
Thank you!
You've got a good point, I've got no formal benchmarks! And personally, I don't have the time, energy, or will power to get them. It's just a subjective stance that I feel like my mouse (and KVM) doesn't freeze any more. Meaning I can use my work laptop without interruption while my main system is bogged down heavily.
But you're right, it's totally a subjective anecdote, so I understand that no one else may want to use zen based on this.
You can find the reasons why you may want to use the Zen kernel here:
https://github.com/zen-kernel/zen-kernel/wiki/Detailed-Feature-List
I've never run it personally, I stick to linux or linux-lts. I'm sure for some niche use-cases, the performance tweaks applied will be valuable, but for your Average Joe or Jane home user, you're not going to notice it.
Personally, with the default linux-lts kernel, I'd get audio drops when CPU load was high with pipewire. That's pretty much the only problem I had that got solved by moving to linux-zen.
Phoronix posted an article earlier this year comparing the different kernels against each other for different use cases and it showed that the standard kernel is the best. There are claims that if you doing lower latency stuff on your pc (like gaming) you will benefit from it but personally I think it's quite hard to benchmark latency and there aren't any as far as I am aware of. Be happy to be proven wrong tho!
Phoronix is notoriously bad for this type of benchmarks, they don't get that throughput isn't the same as interactivity and they constantly test throughput only. Interactivity testing needs specialized benchmarking tools, such as contest/interbench.
Phoronix is notoriously bad
FTFY
There are ways to measure total latency of a system, so you could take the delta if the only variable was kernel choice.
Usually a fast camera (modern smartphones can do 500+fps), a device that acts as an HID mouse (a normal mouse can work as long as the click is consistent enough), and a software that changes what's on the screen when you click. Then you can measure "click to photon" latency.
There's a need if you have a need.
Put less obnoxiously, your average user doesn't need to worry about it. There are absolutely some performance options you can change by customizing your own kernel, but it's one of those situations where you first identify a problem and then determine if a custom kernel is a potential solution. I wouldn't go seeking out reasons for a custom kernel unless you already have a problem you're trying to solve. Or unless you're just curious.
this.
why wasted time on premature optimization.
Short answer - no. In my view of course :)
I do think its good practice to have a second kernel installed purely as a hedge against a kernel not booting for some reason. It's rare but nice to have the comfort of an alternative kernel to boot. Its a lot nicer to recover from a booted system than from recovery.
I use sd-boot - so to add a second kernel to the boot menu is as simple as copy the entry to new name - and change the name, initrd and kernel.
Older tools like grub likely are straightforward as well, but I haven't used grub for over a decade.
regards,
gene
For me it's because of Waydroid "support": https://wiki.archlinux.org/title/Waydroid#Using_Linux-Zen
Yes more performance and way better io or whatever. Example: ryujinx with rdr on a 5900x stock kernel did 47fps 8k and with cachyos kernel i got 66fps same cpu.
for some reason, only linux-zen recognises my touchpad... ive been using lts and regular kernels for ages, and so been using a mouse. i have no idea how zen fixes it for me, but that's why i chose it
I needed the ACS patches for IOMMU groups. The zen kernel in Arch has that. So that's what I use.
I use a nonstandard kernel for development on my PC. In most cases the standard Linux kernel will suffice. The major difference between it and most other kernels that advertise better performance is the cpu Scheduler. The default Linux kernel uses CFS (completely fair scheduler) which doesn’t provide performance benefits for tasks that prefer lower latency. It is meant for servers where uptime and fairness is a priority so tasks scheduled will eventually be completed even with high IOPS. It is not made for end users who want the smoothest experience possible. If you are running kernel on a server I don’t recommend using a non standard Linux kernel unless you have done research and/or testing yourself to ensure it provides benefits while remaining fair enough to complete all tasks during high IOPS. But if you are using it on your developer PC and what you are developing is made to run on servers and not your developer PC then you may consider a different kernel.
I use linux-cachyos-lto for my personal computer that I compile my own code on. It has a BORE scheduler and an EEVDF scheduler. The BORE scheduler ensures tasks that take very little time to complete are scheduled before other tasks (default I believe to be 4ms of cputime or less. I could be wrong as I’ve never completely read the documentation. I just know it seems to work well for my PC). The EEVDF scheduler does heuristic analysis of task to prioritize tasks that are expected to have the “Earliest Eligible Virtual Deadline First” before other tasks can run. The biggest difference I’ve seen using this kernel is that my mouse movement is almost always smooth on my desktop (KDE) even when doing extremely cpu intensive tasks like compiling, moving multiple large files, or compressing files to a tarball or zip/7z file. And other instructions like interacting with app guis with tasks running in the background seems to be processed quicker by the cpu.
If using less ram is a priority I suggest doubling your ram to 32gb instead or using apps that have less footprint on ram. Using a custom kernel won’t save you ram unless you compiled it yourself. And even then it won’t save you much ram unless you use flags to prevent compiling unnecessary code like in Gentoo or use -Os optimizations on your entire Linux installation (which will likely make your computer slower). For developers the extra ram is great to allow caching of compiled code. You may be using your swap as cache which is actually a performance loss so you should check if this happens and take steps to prevent it. Use terminal programs like btop or htop to check how much swapspace you might be using. And if you have no swap and are using 90% of your ram you definitely need more ram.
If getting more ram isn’t an option you can also consider using Gentoo as it greatly reduces memory footprint if set up properly. Then again Gentoo isn’t really an option for most people who just want an OS that works with little downtime.
If you want to add extra interactivity, enable/disable specific features you can even compile the kernel yourself.
That won't impact interactivity much. Interactivity comes down to various schedulers, polling intervals and deadlines.
That's what I've said, you change the kernel config and the kernel itself to get/remove stuff.
I get roughly 400 point higher scores using Zen vs the Regular Linux kernel. My FPS in games also seems to be higher on Zen, comparable to my framerates I could get on Windows 11.
Where do you test scores?
I used Geekbench
Is the RAM actually allocated to programs, or is is just cache? You want the system to use as much RAM as possible to hold things in memory instead of having to wait for storage, even SSD. It will free up RAM used for cache when a program actually needs it.
https://www.linuxatemyram.com/
No, its not cache, its actual programs taking it. few gb chrome, few gb vs code, few gb jetbrains datagrip, few gb just for f***ing hot reload and development server, few gb for other local project's containers like kafka, elastic, logstash, kibana, postgres, redis etc with mock data. Also Apache Superset is eating a lot of ram, and I need to deploy it locally sometimes. Sometimes I need to deploy apache Airflow locally. It's really eaten by programs. Also I have swap partion on nvme disk about 24 gb and usually swap utilized for 20-60%.
You can laugh, but even as simple program as Telegram takes 1.2GB just because I have 4k screen it it stores all big image assets in ram without optimizations. (i've got this explanation from developers themselves in one github issue)
You don't need it, until you do.
Zen is nice to keep the system responsive under heavy load. I also have an lts kernel installed if my system somehow bug down.
I think you can try zram compressed with lz4.
Yes, maybe i will try. But how does it match with my existing swap? I've heard that it creates a virtual device with compression in ram, and assigns swap into it. But I already have 24 gb swap on nvme, that's usually 20-60% full. Should I remove it? Or is there a way to set priority for swaps?
I would suggest deleting the existing swap partition and using zram of the same size as the entire memory. If you don't want to delete the original swap partition, make sure to add the priority in /etc/fstab.
UUID=device_UUID none swap defaults,pri=xxx 0 0I don't recommend using zram alongside a traditional disk swap partition because even if you set swap partition priorities, it only prioritizes filling the higher-priority swap first, and memory-intensive processes may still end up on the regular disk swap.
Please note that some Linux distributions may have zswap enabled by default, which can cause errors in zramctl output.
cat /sys/module/zswap/parameters/enabledEnsure to disable zswap in /etc/default/grub.
GRUB_CMDLINE_LINUX_DEFAULT="zswap.enabled=0"orGRUB_CMDLINE_LINUX="zswap.enabled=0"remember to update grub configgrub-mkconfig -o /boot/grub/grub.cfgBy the way its really cool idea to use compressed device in ram. When I upgrade my notebook to 32 gb ram I'll try to mount /var/lib/docker to such device to eliminate disk io
You can place it in tmpfs or zram.
No.
The differences are marginal at best, and there's little to no real advantage to be gained by using something other than the stock kernel as far as gaming is concerned.
For your use, no. The normal kernel is fine.
As many others said, I don't think you need a custom kernel, as you're quite an average user. But if you're curious, I advice you to try a custom kernel on a virtual machine, you'll learn some things without breaking your workstation.
I use the TKG kernel because it makes super easy to specify the precise latency level you want. Also it optimizes the kernel for your specific GPU.
I use linux-tkg. I use BORE scheduler with it. I feel games like DOOM Eternal running smoother, I've done also benchmarks in games that show leas stuttering.
It can be hard to say, but try the standard kernel and the custom kernel and benchmark the workloads you care about. Get plenty of data points.
You can install a second kernel and choose between then in GRUB. :)
Heck, if you have the space on
/boot, you could install as many kernels as you want!Been using the vanilla kernel for years. Now I'm on linux-zen, as it is the default in Garuda Linux. I don't notice any difference, whether good or bad.