Git Product home page Git Product logo

Comments (9)

VorpalBlade avatar VorpalBlade commented on September 4, 2024 2

I would for my day job (where we use real time Linux patches) have a use case for having priority inheritance even on Linux. That would allow using third party crates on some projects. Currently it is a massive pain to use PI since virtually nothing third party (or std) uses it (I think I have seen two crates for PI on Linux on crates.io). You basically have to roll your own everything for synchronisation.

Furthermore I expect that on some targets that are more focused on real-time (QNX for example) not having PI would annoy users. (Of course that is a tire 3 target, and I don't know if it has PI currently.)

Pethaps there could be a way to enable PI globally, like the global allocator attribute? Since Rust doesn't use pthreads mutices any more it is unfortunately not as easy as enabling the flag but would require larger implementation changes in std.

from rust.

the8472 avatar the8472 commented on September 4, 2024 2

std does not have an API for setting the thread priority

yet. rust-lang/libs-team#195

from rust.

joboet avatar joboet commented on September 4, 2024 1

I would for my day job (where we use real time Linux patches) have a use case for having priority inheritance even on Linux. That would allow using third party crates on some projects. Currently it is a massive pain to use PI since virtually nothing third party (or std) uses it (I think I have seen two crates for PI on Linux on crates.io). You basically have to roll your own everything for synchronisation.

Furthermore I expect that on some targets that are more focused on real-time (QNX for example) not having PI would annoy users. (Of course that is a tire 3 target, and I don't know if it has PI currently.)

Pethaps there could be a way to enable PI globally, like the global allocator attribute? Since Rust doesn't use pthreads mutices any more it is unfortunately not as easy as enabling the flag but would require larger implementation changes in std.

That sounds like a good candidate a build-std option. It would definitely increase the maintenance burden, though, but that needn't be a blocker. The question then still remains whether the default should be platform-dependent.

from rust.

the8472 avatar the8472 commented on September 4, 2024 1

Isn't it generally better to have the wake queues in the kernel even when no PI is involved? E.g. on a RWLock a single FUTEX_WAKE can wake up all the waiters.

from rust.

Amanieu avatar Amanieu commented on September 4, 2024 1

The conclusion of the libs meeting was that In general we don't make any guarantees about thread priority since this is very OS-specific and not supported on all targets. However we should make a best effort to support PI where possible as long as this doesn't impact performance, but this is purely QoI and not an API guarantee.

from rust.

joboet avatar joboet commented on September 4, 2024

Definitely! I just wondered whether we really have to bother on the platforms were PI is difficult to maintain.

from rust.

joshtriplett avatar joshtriplett commented on September 4, 2024

We definitely want to keep using futexes on Linux, and in general we probably don't want to switch to a userspace queue on any target that has a more efficient OS mechanism. I don't think we need to guarantee PI, but we should attempt to give the kernel enough information to handle priority on targets that have built-in support for it, including Linux.

from rust.

joshtriplett avatar joshtriplett commented on September 4, 2024

cc @m-ou-se as the resident expert on our synchronization code.

from rust.

the8472 avatar the8472 commented on September 4, 2024

One data point of someone wanting priority inheritance for game development: https://users.rust-lang.org/t/mutex-priority-inversion/114584?u=the8472

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.