Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Programming Linux

Rust-Written Linux Scheduler Continues Showing Promising Results For Gaming (phoronix.com) 40

"A Canonical engineer has been experimenting with implementing a Linux scheduler within the Rust programming language..." Phoronix reported Monday, "that works via sched_ext for implementing a scheduler using eBPF that can be loaded during run-time."

The project was started "just for fun" over Christmas, according to a post on X by Canonical-based Linux kernel engineer Andrea Righi, adding "I'm pretty shocked to see that it doesn't just work, but it can even outperform the default Linux scheduler (EEVDF) with certain workloads (i.e., gaming)." Phoronix notes the a YouTube video accompanying the tweet shows "a game with the scx_rustland scheduler outperforming the default Linux kernel scheduler while running a parallel kernel build in the background."

"For sure the build takes longer," Righi acknowledged in a later post. "This scheduler doesn't magically makes everything run faster, it simply prioritizes more the interactive workloads vs CPU-intensive background jobs." Righi followed up by adding "And the whole point of this demo was to prove that, despite the overhead of running a scheduler in user-space, we can still achieve interesting performance, while having the advantages of being in user-space (ease of experimentation/testing, reboot-less updates, etc.)"

Wednesday Righi added some improvements, posting that "Only 19 lines of code (comments included) for ~2x performance improvement on SMT isn't bad... and I spent my lunch break playing Counter Strike 2 to test this patch..."

And work seems to be continuing, judging by a fresh post from Righi on Thursday. "I fixed virtme-ng to run inside Docker and used it to create a github CI workflow for sched-ext that clones the latest kernel, builds it and runs multiple VMs to test all the scx schedulers. And it does that in only ~20min. I'm pretty happy about virtme-ng now."
This discussion has been archived. No new comments can be posted.

Rust-Written Linux Scheduler Continues Showing Promising Results For Gaming

Comments Filter:
  • by ffkom ( 3519199 ) on Saturday January 20, 2024 @04:47PM (#64175499)
    "Gaming" not being the default task of most Linux computers, the default kernel scheduler is not optimized for that use case. There is a variety to choose from, though, and there are schedulers like PDS that are more suitable for gaming: https://wiki.archlinux.org/tit... [archlinux.org]

    So, how does that special-interest user-space scheduler compare to a scheduler actually optimized for the same use case?
    • by Anonymous Coward

      I wonder what SteamOS uses? It's a Linux distribution where the primary task is gaming. Maybe SteamOS could benefit from a scheduler that is built with gaming in mind.

  • Is there something inherent to Rust here, as opposed to other languages, that makes this scheduler possible? If not, then it isn't really a Rust story. The dev just happened to use Rust instead of C or C++.

    • I see it a a "Rust within linux kernel" story. As you point out, it does not seem there is anything particular about the Rust implementation; but there also does not seem to be anything special about this scheduling algorithm. The most notable point is that the Rust integration designed by the linux kernel team and provided by the compiler chain is now good enough to make this hybrid combination work and perform well. It's evidence that Rust is now usable beyond a hello world keyboard driver.

      • It's not even that, really.
        It uses sched_ext (I have several sched_ext projects ongoing for different network processing tasks).
        The in-kernel portion is BPF (written in C via bpfc, or direct BPF assembler).
        Presumably this has the BPF component receiving instructions form a user-space component written in Rust.
    • It just happens to be Rust. This is your first step down the forbidden path, a lifestyle you may well regret lies before you. People will mock and tease you and may threaten your life. Turn away from those with hidden agendas and use a gaming-specific scheduler written in a nice, normal language.
    • by Anonymous Coward

      Yes, there is nothing special by using Rust here.

      In fact I wonder how much faster and more efficient it would run if it were written in C or C++. They (Rust developers) probably don't want to know the answer to that because they would have to admit something they don't want to.

      • It likely wouldn't make a difference what language you used. It's the scheduler; it's picking which process to run next. Probably O(n).

The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny ..." -- Isaac Asimov

Working...