-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
SyncSender::send
enters a busy-wait loop if the buffer is full
#106668
Comments
cc @ibraheemdev |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium T-compiler |
Are you seeing this issue in real world code? |
The problem is that the loop uses rust/library/std/src/sync/mpmc/array.rs Lines 330 to 334 in 51b0345
rust/library/std/src/sync/mpmc/utils.rs Lines 118 to 120 in 51b0345
rust/library/std/src/sync/mpmc/utils.rs Lines 141 to 143 in 51b0345
We need to use |
Oh that is true, I think |
Iiuc
|
The current std mpsc implementation doesn't use hybrid spinning ( (Whether that is the optimal behavior is another topic; Both crossbeam and parking_lot do hybrid spinning before blocking, so both crossbeam's Backoff and parking_lot's SpinWait are designed to follow that behavior. ) |
@kawadakk The spinning behavior was changed from the original crossbeam implementation in the port:
|
@ibraheemdev Ah, I see - the intention is that |
…anieu Fix `mpsc::SyncSender` spinning behavior Resolves rust-lang#106668.
…anieu Fix `mpsc::SyncSender` spinning behavior Resolves rust-lang#106668.
Fix `mpsc::SyncSender` spinning behavior Resolves rust-lang/rust#106668.
Code
I tried this code:
I expected to see this happen: Blocking indefinitely without consuming significant CPU time
Instead, this happened: 100% CPU usage (backtrace shown below)
rust/library/std/src/sync/mpmc/array.rs
Lines 322 to 335 in 51b0345
Version it worked on
It most recently worked on:
nightly-2022-11-13
(nightly),1.66.0
(latest stable)Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
The text was updated successfully, but these errors were encountered: