-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Optimize thread parking on NetBSD #101482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
9657fe0
to
b9eb476
Compare
extern "C" { | ||
fn _lwp_park( | ||
clock_id: clockid_t, | ||
flags: c_int, | ||
ts: *mut timespec, | ||
unpark: lwpid_t, | ||
hint: *const c_void, | ||
unparkhint: *const c_void, | ||
) -> c_int; | ||
fn _lwp_unpark(lwp: lwpid_t, hint: *const c_void) -> c_int; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to add these to the libc
crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syscall behaviour can change slightly with newer versions (e.g. the ts
argument is only modified on NetBSD 9.0 and above, while it is still the same symbol), so it might not necessarily be a good idea to advertise these functions in libc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that matters much for inclusion in the libc
crate. It contains many symbols that aren't fully "stable" or only exist on certain versions of the operating system or underlying libc.
Anyway, this is not a blocker for this PR.
If I understand the documentation correctly, it seems best to pass the address of |
b9eb476
to
e415558
Compare
@bors r+ |
📌 Commit e41555848ed70cc76d4f17387150a108bdea580d has been approved by It is now in the queue for this repository. |
@bors r- |
9831f34
to
adfe1b1
Compare
I've now confirmed that this works on NetBSD 9.3 (x86_64 with QEMU). @rustbot ready |
@bors r+ |
📌 Commit adfe1b171e178e436a3f48ae9774461b5d929d3d has been approved by It is now in the queue for this repository. |
⌛ Testing commit adfe1b171e178e436a3f48ae9774461b5d929d3d with merge 9da77f41d2fc05613b5cb869d0ebf63c2b64d653... |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
adfe1b1
to
81b11ed
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (56b625b): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
As the futex syscall is not present in the latest stable release, NetBSD cannot use the efficient thread parker and locks Linux uses. Currently, it therefore relies on a pthread-based parker, consisting of a mutex and semaphore which protect a state variable. NetBSD however has more efficient syscalls available:
_lwp_park
and_lwp_unpark
. These already provide the exact semantics ofthread::park
andThread::unpark
, but work with thread ids. Instd
, this ID is here stored in an atomic state variable, which is also used to optimize cases were the parking token is already available at the timethread::park
is called.r? @m-ou-se