6 ms·
The Linux Scheduler: A Decade of Wasted Cores (2016) [pdf]
- westurner 3y ago> Abstract: As a central part of resource management, the OS thread scheduler must maintain the following, simple, invariant: make sure that ready threads are scheduled on available cores. As simple as it may seem, we found that this invari- ant is often broken in Linux. Cores may stay idle for sec- onds while ready threads are waiting in runqueues. In our experiments, these performance bugs caused many-fold per- formance degradation for synchronization-heavy scientific applications, 13% higher latency for kernel make, and a 14- 23% decrease in TPC-H throughput for a widely used com- mercial database. The main contribution of this work is the discovery and analysis of these bugs and providing the fixes. Conventional testing techniques and debugging tools are in- effective at confirming or understanding this kind of bugs, because their symptoms are often evasive. To drive our in- vestigation, we built new tools that check for violation of the invariant online and visualize scheduling activity. They are simple, easily portable across kernel versions, and run with a negligible overhead. We believe that making these tools part of the kernel developers’ tool belt can help keep this type of bug at bay.
- deleted 3y ago[deleted]
- megaloblasto 3y agoThis paper is from 2016. Anyone know the status of this now?
- pokler 3y agoThe Linux kernel received a new scheduler not too long ago (https://lwn.net/Articles/925371/ https://lwn.net/Articles/925371/), so I'm not sure how relevant the critiques about CFS are.
- whoisthemachine 3y agoLooks great! According to one article, those changes just hit shore last month in kernel 6.6, so it's likely not in most os distributions yet. https://tuxcare.com/blog/linux-kernel-6-6-is-here-find-out-whats-new/#:~:text=Processor%20Updates,efficiency%2C%20especially%20for%20AMD%20processors https://tuxcare.com/blog/linux-kernel-6-6-is-here-find-out-w....
- mixmastamyk 3y agoIn fedora 38 and 39, just update.
- mmwelt 3y agoFWIW, Pop OS just updated to the 6.6 kernel.
- fmajid 3y agoAs did Alpine in 3.19
- whoisthemachine 3y agoInteresting! I've used Linux Mint for the last 5+ years (and am using the Xanmod kernel, which is on 6.6), but have always been Pop OS curious. This increases my curiosity, I may have to give it a go on my laptop. https://xanmod.org/ https://xanmod.org/
- nickelpro 3y agoIt was discussed at the time, and the consensus was the patches were unusuable, the testing methodology dubious, and the machine configuration rare. https://lkml.org/lkml/2016/4/23/135 https://lkml.org/lkml/2016/4/23/135
- Agingcoder 3y agoThis paper caused me to start doubting the Linux scheduler on medium sized boxes ( 36 physical cores in 2016 ) and helped me find an annoying bug in the rhel 7 kernel which prevented some processes from being scheduled at all in some cases( it was an issue with Numa load balancing if I remember well). Note my bug was most likely unrelated to the paper, but it marked in my mind a specific class of bugs as possible. So it helped me at least :-)
- Aerbil313 3y agoDidn’t read the paper, but Linux kernel and userspace gotten a lot of tech debt while it became the most common OS. I’d love to see something new built with modern practices and ideas come and dethrone it. Maybe Theseus OS (not affiliated).
- entropicdrifter 3y agoI've been keeping an eye on Redox for several years now, as well. It'll be interesting to see what floats and what sinks in the decades to come.
- pmarreck 3y agoThanks for reminding me to bookmark that project! I'd forgotten about it.
- adql 3y agoI hesitate to call "the shit that keeps stuff older than a year working on that kernel" a tech debt. It's necessity in any general use OS. The stuff that can be changed without breaking compatibility is, well, it was the developer's best idea at the time and some of them turned out to be good, some turned out to be bad. Going "but on paper that idea would be better, let's make OS around it" rarely ends up being plain better. It's not one dimensional. For example if your CPU scheduler makes all jobs run faster (less cache thrashing while keeping CPUs busy etc.) but is unfair, that might be great for people running batch jobs, but shit for desktop users. Scheduler wasting cycles but making sure interactive tasks get the right level of priority might be improvement for desktop users but not for server use etc. Or you figure out that the reason something was "unnecessarily complex", was actual necessary complexity that wasn't obvious at first. Also Linux isn't exactly stranger to taking the whole bunch of code and replacing it with something better, I think we're at 3th firewall stack now (ipchains -> iptables -> nftables)
- gerdesj 3y agoThere was another one before ipchains - ipfw.
- dang 3y agoRelated. Others? The Linux scheduler: A decade of wasted cores (2016) - https://news.ycombinator.com/item?id=33462345 https://news.ycombinator.com/item?id=33462345 - Nov 2022 (26 comments) The Linux Scheduler: A Decade of Wasted Cores (2016) - https://news.ycombinator.com/item?id=15531332 https://news.ycombinator.com/item?id=15531332 - Oct 2017 (35 comments) The Linux Scheduler: A Decade of Wasted Cores - https://news.ycombinator.com/item?id=11570606 https://news.ycombinator.com/item?id=11570606 - April 2016 (38 comments) The Linux Scheduler: A Decade of Wasted Cores [pdf] - https://news.ycombinator.com/item?id=11501493 https://news.ycombinator.com/item?id=11501493 - April 2016 (142 comments)
- mpixel 3y agoUltimately -- the thing is, if anyone is both capable and willing, they can, and sometimes do, fix it. Granted, this combination is rather rare. Most people aren't capable. Of those who are, they have better things to do and they probably have very well paying jobs they could be focusing on instead. With that being said, Linux is _still_ more efficient than Windows. I don't want to say Linux is free, in practice it's not, those who are running the big powerful machines are using RHEL and paying hefty licenses. Which are still better than any other alternative.
- saagarjha 3y agoThere are well-paying jobs that allow smart people to focus on exactly this.
- adql 3y ago> I don't want to say Linux is free, in practice it's not, those who are running the big powerful machines are using RHEL and paying hefty licenses. Google/Amazon/MS isn't paying RHEL licenses. Reason for using RHEL is basically "we don't want to hire experts", which makes a lot of sense in small/midsized company but in big one it's probably mostly the ability to blame someone else if something is fucked up, and the fact some of the software basically says "run it on this distro or it is unsupported".
- deafpolygon 3y agoThat's basically it. As a sysadmin, I supported over hundreds of Linux servers (mostly virtual) pretty much by myself. We paid the license so that if the shit hit the fan (and we really had no way of fixing it) we can call on Red Hat. At least, I could be able to tell my bosses that things were being handled. This never happened, of course. But it's CYA.
- ElijahLynn 3y agoI've used RHEL support too, believe it or not, while working as a DevOps engineer at Red Hat on www.redhat.com. And the support specialist assigned to my issue was very sharp and solved the issue quickly. Easy in hindsight but I was stuck so I reached out, and I was glad I did. It involved a segfault and grabbing a core dump and analyzing it. ++Red Hat Support
- AaronFriel 3y agoThe Linux 6.6 kernel ships with a new default scheduler[1]. Is the testing methodology in this paper relevant and used to assess the current (EEVDF) scheduler, or is it irrelevant? [1] - https://lwn.net/Articles/925371/ https://lwn.net/Articles/925371/
- hinkley 3y agoThere’s nothing in that article that talks about how work stealing is managed, so there’s no knowing if this scheduler fixes the problem or makes it worse.
- redeeman 3y agoand something reasonably like it existed for... more than a decade, but mingo was not a fan, threw a hissyfit and originated CFS, and well, torvalds didnt care too much, so deferred to mingo
- mochomocha 3y agoHaving experimented with a lot of CFS knobs, my high-level conclusion is that every single non-default behavior is broken to various degrees, and default behavior isn't immune to pathological edge cases either.
- mochomocha 3y agoI'd like to wager that EEVDF has been tested less methodologically than how this paper investigates CFS. The primary author of EEVDF and maintainer of the subsystem has been dismissing alternative approaches and plethora of robustly tested patches from Google and Facebook over the years, with mostly replies boiling down to "meh I don't like it". I'd take a patch of CFS and its millions of broken knobs from Google over newly released EEVDF any day, because I trust scheduler AB testing by Google over millions of machines and every single scheduling pattern under the sun way more than whatever synthetic micro-benchmark a single kernel dev (as competent as they might be) ran. If you're interested in quantitative analysis of schedulers & tooling around it, these 2 projects are very interesting: https://github.com/google/schedviz https://github.com/google/schedviz https://fuchsia.dev/fuchsia-src/concepts/kernel/fair_scheduler#detailed_scheduler_tracing https://fuchsia.dev/fuchsia-src/concepts/kernel/fair_schedul...
- tremon 3y agoSame goes for I/O scheduling. The virtual memory subsystem seems to only have two modes: buffering and write-out. The system will buffer writes until some threshold is reached, then it switches to write-out mode and flushes all dirty pages regardless of their age. The problem is that new pages are locked during write-out, so pending writes will stall, regardless of the memory pressure on the rest of the system. A better design would be to only lock a subset of dirty pages and let new writes to virtual memory continue while the write-out is happening, but it doesn't seem like the system can accomodate that. A simple test to see this in action is to use netcat to transfer a large file across the network, and monitor the device activity with sar or atop (or just check the disk/network activity lights). What you'll see is that while the disk is writing, network activity drops to zero, and when network activity resumes, the disk remains idle again for seconds. It doesn't matter how much smaller you make vm.dirty_background_{bytes,ratio} with respect to vm.dirty_{bytes,ratio}, the network traffic will block as soon as the "background" disk write starts. The only effect a low value for vm.dirty_background_{bytes,ratio} has is to increase the frequency at which the network and disk activity will alternate.
- freedomben 3y agoWhy do you think it's still this way? Why hasn't somebody implemented something better? Is it too core that we can't afford any instability? Edit: apparently it has been done, but only very recently and hasn't had a major distro ship it yet
- ahartmetz 3y agoOh? That sounds important and interesting. Do you have a URL or commit hash with more information?
- freedomben 3y agoI'm very confused now so I have no idea what to think. I need to take some time to read through everything, but in the mean time here are some relevant links I've seen: https://lwn.net/Articles/925371/ https://lwn.net/Articles/925371/ https://lkml.org/lkml/2016/4/23/135 https://lkml.org/lkml/2016/4/23/135
- bee_rider 3y agoIs their LU benchmark just LU factorize and possibly solve? That seems like an odd candidate for this kind of problem, because of course anybody running that kind of problem that cares about performance just doesn’t over-subscribe their system… the scheduler has a much easier job when there’s one big chunky thread per core. I mean, I get that they are testing a general fix for the sort of problems that, like, non-scientific-computing users get. So it isn’t to say the work is useless. It just seems like a funny example. I think coming up with benchmarks for schedulers must actually be very difficult, because you have figure out exactly how silly of a thing you want the imagined user to do.
- semi-extrinsic 3y agoFurther to this, if you are running a program where compute is mainly a sparse linear solve, you are memory bandwidth limited and on modern systems like AMD Epyc you will very very likely see improved performance if you undersubscribe cores by 2x - e.g. using max 64 threads per 128 cores.
- swatson741 3y agoAnd yet Linux has consistently out preformed macOS in terms of throughput.
- jerf 3y agoYes. It turns out one thing being bad does not make a completely different thing good. (You'd think this was obvious, but I've been on the Internet a while and it sure isn't.)
- haberman 3y ago> As a central part of resource management, the OS thread scheduler must maintain the following, simple, invariant: make sure that ready threads are scheduled on available cores. As simple as it may seem, we found that this invariant is often broken in Linux. Cores may stay idle for seconds while ready threads are waiting in runqueues. This oddly lines up with an observation I've made about traffic lights. It is very surprising how often you'll be stopped at an intersection where everybody is waiting and nobody is allowed to go, sometimes for what feels like 10-30 seconds. It seems like the lowest-hanging fruit for improving traffic is to aim never to have degenerate intersections. If someone is waiting and nobody is going, the light should change quickly.
- zukzuk 3y agoIsn’t that usually to give pedestrians a head start on crossing?
- wmf 3y agoThat sounds like a protected left turn but no one is turning so it looks stalled.
- nextaccountic 3y agoIn some places the lights work like this, but you need to install relatively expensive sensors The sensors help gather high quality data for traffic models though. That should help traffic engineers to do their job
- guhcampos 3y agoI tried to read the article, but eventually gave up. There’s just too much bad science in it. By too much I mean: 1. A clickbait title 2. A conclusion that phrases “scheduling was thought to be a solved problem”
- dekhn 3y agoWhen we replaced a venerable Tru64 cluster with Linux about 15 years ago, the head of the department (who was skeptical of linux) came to me with a problem: he had scheduled 9 "use 100% of a core" processes on an 8 core machine and expected each process to get 8/9ths of a core on the machine, with each process proceeding at the same rate. (If I got that math wrong, basically I mean that all processes should receive the same amount of CPU time over an interval, with the expectation that the CPUs will be at 100%). Instead, he found that one of the 9 processes always went slower than all the others. Tru64 did what he expected. I believe at this point, we were running a kernel before the completely fair scheduler, but I've always wondered if there was a right answer here- I don't think UNIX or Linux truly 'guarantee' fully predictable and evenly divded CPU performance when you have n+1 (or n+whatever) processes running on n cores. (also, he used "yes > /dev/null" as the CPU-generating task and I had to spend a lot of time explaining to him that wasn't really 100% cpu)
- ralfd 3y ago> that wasn't really 100% cpu Can you explain?
- wtallis 3y agoThat's probably referring to the fact that running 'yes' is going to spend virtually all of its time on syscall and context switch overhead, and minimal real work or IO. So conclusions from such a test may not generalize to any kind of realistic workload.
- dekhn 3y agothe yes command, writing to /dev/null, is making IO calls, which interfere with predictable scheduling. If you look at the source code for yes, https://github.com/coreutils/coreutils/blob/master/src/yes.c https://github.com/coreutils/coreutils/blob/master/src/yes.c it builds a buffer of output and then writes that in a for loop while (full_write (STDOUT_FILENO, buf, bufused) == bufused) continue; Inside the kernel, /dev/null is handled by doing nothing. So basically when this runs, the majority of the CPU time it consumes is just context switches from process to kernel and back. It consumes 100% of a core on an idle machine, but what you really want for your basic scheduling test is to have a pure CPU hog with no kernel transitions (I've seen variations- increment a register, do some light flops that don't hit memory, or even just a nop loop (which is basically "increment register, branch if less than"). If you get the expected performance on the cpu hog, then you can proceed to the yes hog.
- stevefan1999 3y agoI'm surprised that nobody talked about the problems of scheduling problem, being NP-Complete, is all about finding heuristics to workaround this ultimate algorithmic hard truth. And for multicore scheduling, job shop scheduling [1], it is the even harder version of NP-Hard (no pun intended). This is literally taught in senior year uni CS class, that there is no perfect solution to the scheduling problem, unless Cook-Levin Theorem or anyone of those NP-Complete problems are solved [2]. [1]: https://optimization.cbe.cornell.edu/index.php?title=Job_shop_scheduling https://optimization.cbe.cornell.edu/index.php?title=Job_sho... [2]: https://www.cse.cuhk.edu.hk/~siuon/csci3130-f19/slides/lec22.pdf https://www.cse.cuhk.edu.hk/~siuon/csci3130-f19/slides/lec22...
- mochomocha 3y agoThis is technically true but practically irrelevant. Case in point, I deployed at Netflix a real-time combinatorial solver specifically for CPU scheduling [1]. Most real-world combinatorial problems can be solved relatively well. This is why Gurobi is in business, Alpha Go exists, or why Amazon and United Airlines still manage to practically solve their resource allocation problems. [1]: https://netflixtechblog.com/predictive-cpu-isolation-of-containers-at-netflix-91f014d856c7 https://netflixtechblog.com/predictive-cpu-isolation-of-cont...
- skyde 3y agofirst time earing about Gurobi, is it some kind of SMT solver? I tried looking at their website but could only find high level marketing description.