142
submitted 5 months ago* (last edited 5 months ago) by SorteKanin@feddit.dk to c/linux@programming.dev

One big difference that I've noticed between Windows and Linux is that Windows does a much better job ensuring that the system stays responsive even under heavy load.

For instance, I often need to compile Rust code. Anyone who writes Rust knows that the Rust compiler is very good at using all your cores and all the CPU time it can get its hands on (which is good, you want it to compile as fast as possible after all). But that means that for a time while my Rust code is compiling, I will be maxing out all my CPU cores at 100% usage.

When this happens on Windows, I've never really noticed. I can use my web browser or my code editor just fine while the code compiles, so I've never really thought about it.

However, on Linux when all my cores reach 100%, I start to notice it. It seems like every window I have open starts to lag and I get stuttering as the programs struggle to get a little bit of CPU that's left. My web browser starts lagging with whole seconds of no response and my editor behaves the same. Even my KDE Plasma desktop environment starts lagging.

I suppose Windows must be doing something clever to somehow prioritize user-facing GUI applications even in the face of extreme CPU starvation, while Linux doesn't seem to do a similar thing (or doesn't do it as well).

Is this an inherent problem of Linux at the moment or can I do something to improve this? I'm on Kubuntu 24.04 if it matters. Also, I don't believe it is a memory or I/O problem as my memory is sitting at around 60% usage when it happens with 0% swap usage, while my CPU sits at basically 100% on all cores. I've also tried disabling swap and it doesn't seem to make a difference.

EDIT: Tried nice -n +19, still lags my other programs.

EDIT 2: Tried installing the Liquorix kernel, which is supposedly better for this kinda thing. I dunno if it's placebo but stuff feels a bit snappier now? My mouse feels more responsive. Again, dunno if it's placebo. But anyways, I tried compiling again and it still lags my other stuff.

you are viewing a single comment's thread
view the rest of the comments
[-] SorteKanin@feddit.dk 4 points 5 months ago

It sounds like the issue is that the Rust compiler uses 100% of your CPU capacity.

No, I definitely want it to use as many resources it can get. I just want the desktop and the windows I interact with to have priority over the compiler, so that the compiler doesn't steal CPU time from those programs.

[-] JATtho@lemmy.world 1 points 5 months ago

No, I definitely want it to use as many resources it can get.

taskset -c 0 nice -n+5 bash -c 'while :; do :; done' &
taskset -c 0 nice -n+0 bash -c 'while :; do :; done'

Observe the cpu usage of nice +5 job: it's ~1/10 of the nice +0 job. End one of the tasks and the remaining jumps back to 100%.

Nice'ing doesn't limit the max allowed cpu bandwidth of a task; it only matters when there is contention for that bandwidth, like running two tasks on the same CPU thread. To me, this sounds exactly what you want: run at full tilt when there is no contention.

[-] SorteKanin@feddit.dk 2 points 5 months ago

Sure but that's not what the person I replied to suggested.

this post was submitted on 18 Jun 2024
142 points (96.1% liked)

Linux

5380 readers
207 users here now

A community for everything relating to the linux operating system

Also check out !linux_memes@programming.dev

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 1 year ago
MODERATORS