perf(runtime): publish worker counters without atomic RMW - #1018
Conversation
There was a problem hiding this comment.
Pull request overview
Optimizes scheduler metric publication while preserving existing APIs and semantics.
Changes:
- Replaces atomic RMW counter updates with worker-local increments and relaxed stores.
- Adds metric concurrency coverage and microbenchmarks.
- Documents the new publication model.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
include/elio/runtime/worker_thread.hpp |
Adds owner-local counters and publication helpers. |
include/elio/runtime/scheduler.hpp |
Uses publication helpers on execution and steal paths. |
tests/unit/test_scheduler.cpp |
Adds concurrent task-counter coverage. |
examples/microbench.cpp |
Benchmarks RMW versus single-writer publication. |
README.md |
Summarizes the optimization. |
wiki/Performance-Tuning.md |
Documents metric publication behavior. |
CHANGELOG.md |
Records the performance change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
b962e1a to
f6ac6d2
Compare
|
@copilot please re-review only; do not make direct code modifications. |
Re-reviewed the revised test. The 128-round two-way handshake correctly guarantees concurrent overlap for every sample: the coroutine cannot advance past round N until the external reader has acknowledged it, so all 128 reads are guaranteed to occur while the coroutine is still live. The |
Description
Removes atomic read-modify-write instructions from per-resume and successful-steal metric updates. Each worker now increments owner-local counters and publishes the exact updated value through relaxed atomic stores for external readers.
This preserves the public metric APIs, per-resume/per-steal counting meaning, and monotonic relaxed-snapshot behavior while reducing fixed scheduler hot-path cost.
Type of Change
Related Issues
Closes #1017
Changes Made
Core Changes
fetch_addoperations with local increments followed by relaxed atomic snapshot stores.fetch_addwith single-writer publication.API Changes
None. Existing scheduler metric accessors and return types are unchanged.
Testing
Unit Tests
Sanitizer Testing
Test Results
Spawn and nested context-switch measurements remained within the observed run-to-run noise range.
Checklist
Code Quality
-WerrorDocumentation
Testing
Compatibility
Performance
Reviewer Guidance
Please focus on: