Repository navigation
bench(rwlock): add upgradable lock stage timings - #405
ismaeelakin wants to merge 6 commits into
Conversation
| name = "ecosystem" | ||
| path = "benches/ecosystem/main.rs" | ||
|
|
||
| [[bench]] |
There was a problem hiding this comment.
cargo x bench -- --list worked before and now fails, because the default run includes this target and it rejects --list. I'd leave it out of the default run and smoke-test it separately in CI.
| let mut upgrade = pin!(RwLockUpgradableReadGuard::upgrade(guard)); | ||
| let start = Instant::now(); | ||
| poll_pending(upgrade.as_mut(), &mut context); | ||
| drop(readers); |
There was a problem hiding this comment.
drop(readers) also frees the Vec inside the timed window. Reusing one buffer across rounds and calling clear() here avoids that.
| let start = Instant::now(); | ||
| let guard = poll_ready(lock.upgradable_read(), &mut context); | ||
| acquisition += start.elapsed(); | ||
|
|
||
| let start = Instant::now(); | ||
| let writer = poll_ready(RwLockUpgradableReadGuard::upgrade(guard), &mut context); | ||
| promotion += start.elapsed(); | ||
|
|
||
| black_box(*writer); | ||
| drop(writer); |
There was a problem hiding this comment.
An empty timed interval costs about 15 ns on my M5, roughly half the reported acquisition and promotion times. Could we print that baseline alongside the results?
orthur2
left a comment
There was a problem hiding this comment.
Thanks for adding the queued cases.
|
Thanks as well for the careful review. I kept upgradable_stages out of the default cargo x bench run so cargo x bench -- --list works, and added a separate CI smoke run for the target. The reader buffer is now reused, so its backing allocation is not freed inside the timed interval. I also report an empty interval with the same clock calls, without subtracting it from the measurements. The default listing, stage smoke run, and target-selection test each passed, cargo x test passed as well. |
What changed
Adds stage timings for the
UpgradableRwLockinvestigation in #404:--testsupport for the repository benchmark smoke runThis PR adds the measurement step requested in #404; it does not change the lock implementation or establish a speedup. Per-operation clock reads add overhead. Reader-promotion timings include dropping the readers and the wake/handoff, and queued acquisition includes the writer's handoff. The benchmark manually polls futures with a non-scheduling waker, so its timings exclude executor scheduling overhead. Treat the results as diagnostics.
Verification
Passed locally on Windows 11 (Intel Core i5-6300U):
cargo x testand benchmark runs with stable rustc 1.99.1cargo x lintwith nightly rustc 1.101.0cargo x bench -- --testcargo x bench --bench upgradable_stages -- --rounds 1000000 --repeat 5The local timings and their run-to-run spread are recorded in issue #404.
Refs #404