Repository navigation
Add benchmark - #4
Merged
Merged
Conversation
borrow_dyn_multi_thread* tests occasionally hanged. A wait_to_lend() could register a waker that replaced an active LendGuard's waker, potentially preventing that LendGuard's thread from ever waking up. Fix that up by checking mutex.state in wait_to_lend() and return early if another lend()/wait_to_lend() is in progress. The borrow_dyn_multi_thread* tests need to be adjusted too as instead of deadlocking they would panic now. To properly have multiple concurrent lend-ers it's necessary to synchronize the lending externally, i.e. with a normal async mutex.
```
warning: use of deprecated module `core::intrinsics`: import this function via `std::mem` instead
--> src/mpmc.rs:174:39
|
174 | Ok(unsafe { core::intrinsics::transmute(slot) })
| ^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: use of deprecated module `core::intrinsics`: import this function via `std::mem` instead
--> src/mpmc.rs:235:41
|
235 | Some(unsafe { core::intrinsics::transmute(slot) })
| ^^^^^^^^^
warning: `borrow_mutex` (lib) generated 2 warnings (1 duplicate)
```
The uncontended benchmark was actually affected by the extra CAS+store, making uncontended wait_for_lend() marginally slower than smol::lock::Mutex. Use a separate AtomicWaker for lend() and wait_to_lend(), then don't check for multiple parallel wait_to_lend(). This means it's possible for some wait_to_lend() to overwrite another wait-er's waker, leading to that wait-er not being awoken. It's a misbehavior due to misuse, but too bad. In uncontended case, BorrowMutex is now again marginally faster than smol::lock::Mutex.
darsto
force-pushed
the
fix/benchmark-and-fixes
branch
from
September 27, 2026 14:38
2f9a30d to
8deba88
Compare
darsto
force-pushed
the
fix/benchmark-and-fixes
branch
from
September 27, 2026 14:44
8deba88 to
23c4e56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add benchmark and fixup the bugs it revealed.
While here, fixup no-std builds and add CI for it.