perf(runtime): sample worker progress for block detection - #1023
Conversation
d703f4f to
3533758
Compare
There was a problem hiding this comment.
Pull request overview
Moves worker-block detection off the coroutine-resume hot path by sampling progress counters in the autoscaler.
Changes:
- Adds sampled worker-progress tracking and opt-in timestamp diagnostics.
- Adds unit/integration coverage and microbenchmarks.
- Documents the sampled
on_blockcontract and performance impact.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
CHANGELOG.md |
Records the performance change. |
README.md |
Summarizes sampled block detection. |
examples/microbench.cpp |
Benchmarks timestamp diagnostic costs. |
include/elio/runtime/autoscaler.hpp |
Implements progress-counter sampling. |
include/elio/runtime/scheduler.hpp |
Removes unconditional timestamp updates. |
include/elio/runtime/worker_thread.hpp |
Makes timestamp tracking opt-in. |
tests/unit/test_autoscaler.cpp |
Tests sampling and blocked-worker behavior. |
wiki/API-Reference.md |
Documents last_task_time(). |
wiki/Examples.md |
Clarifies on_block semantics. |
wiki/Performance-Tuning.md |
Documents behavior and performance guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot please re-review the current head only; do not make direct code modifications or push commits. |
Review of current head (
Overall The core design — sampling counters in the autoscaler tick rather than publishing timestamps on every resume — is sound. The |
3533758 to
a2332d3
Compare
|
Addressed the current-head review points in
Local Release, ASAN, and TSAN validation remains green for both @copilot please re-review the current head only; do not make direct code modifications or push commits. |
Review of current head ( All seven points from the previous review have been addressed. Here is the verification pass:
No new issues found in this revision. The design, state-machine logic, and test coverage look correct. |
Description
Move autoscaler worker-block detection off the coroutine-resume hot path. The
on_blocktrigger now samples each worker's published completed-resume counter once per autoscaler tick and measures how long a non-idle worker has made no sampled progress.Ordinary resumes no longer call
steady_clock::now()or publish an atomic time point. The concreteworker_thread::last_task_time()diagnostic remains source-compatible: its first call opts that worker into exact timestamp tracking for subsequent resumes.Type of Change
Related Issues
Closes #1019
Related to #1017
Changes Made
Core Changes
worker_thread::run_task().last_task_time()through an opt-in diagnostic flag.API Changes (if applicable)
No signature changes.
on_blockis now explicitly documented as best-effort sampled detection:block_threshold;tick_interval.Calling
worker_thread::last_task_time()enables exact per-resume timestamps for that worker from then on. Periodic monitoring should prefer scheduler execution counters.Migration Guide (if breaking change)
Not applicable. Existing call sites remain source-compatible.
Testing
Unit Tests
Integration Tests
Sanitizer Testing
Test Results
Checklist
Code Quality
Documentation
Testing
Compatibility
Performance (if applicable)
Performance Results
Pinned to CPUs 0-4 on the same GCC 12 Release environment:
Task-spawn and general context-switch results remained within run-to-run noise. These figures are local directional evidence; CI compiles and smoke-tests benchmarks but does not enforce timing thresholds on shared runners.
Screenshots / Diagrams
Not applicable.
Additional Notes
The mixed service-latency smoke still reports roughly the configured 5 ms local backlog before I/O and remote-inbox service. That is expected: this PR removes per-resume metric overhead but intentionally does not implement the separate scheduler service-quantum change.
Reviewer Guidance
Areas requiring special attention:
last_task_time().Questions for reviewers:
on_blockcontract precise enough about the possible one-tick detection lag?