Skip to content

perf(timer): embed the waiter node in the awaitable frame#322

Merged
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/waiter-embed
Jul 18, 2026
Merged

perf(timer): embed the waiter node in the awaitable frame#322
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/waiter-embed

Conversation

@sgerbino

Copy link
Copy Markdown
Collaborator

Each co_await on a timer previously allocated a waiter_node from the service, amortized through a thread-local cache and a mutex-protected free list. The node now lives inside the awaitable on the suspended coroutine's frame, so a wait performs no allocation and never touches the free-list mutex.

The stop token is borrowed from the awaiting chain's io_env and the stop callback is constructed in place in a raw buffer, so the node owns no destructible state. Completion paths destroy the callback and finish touching the node before posting the continuation or destroying the coroutine, whose frame is the node's storage.

completion_op and canceller are defined non-inline in timer.cpp because the inline waiter_node constructor references do_complete and the vtable from translation units that reach timer.hpp through delay.hpp without including timer_service.hpp.

The waiter free list, thread-local waiter cache, and per-wait create/destroy machinery are removed.

Each co_await on a timer previously allocated a waiter_node from the
service, amortized through a thread-local cache and a mutex-protected
free list. The node now lives inside the awaitable on the suspended
coroutine's frame, so a wait performs no allocation and never touches
the free-list mutex.

The stop token is borrowed from the awaiting chain's io_env and the
stop callback is constructed in place in a raw buffer, so the node
owns no destructible state. Completion paths destroy the callback and
finish touching the node before posting the continuation or destroying
the coroutine, whose frame is the node's storage.

completion_op and canceller are defined non-inline in timer.cpp
because the inline waiter_node constructor references do_complete and
the vtable from translation units that reach timer.hpp through
delay.hpp without including timer_service.hpp.

The waiter free list, thread-local waiter cache, and per-wait
create/destroy machinery are removed.
@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://322.corosio.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-07-17 21:57:07 UTC

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://322.corosio.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://322.corosio.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://322.corosio.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-07-17 22:04:51 UTC

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.52%. Comparing base (e06fca6) to head (ba75e1b).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #322      +/-   ##
===========================================
- Coverage    77.79%   77.52%   -0.28%     
===========================================
  Files           96       96              
  Lines         6985     6900      -85     
  Branches      1682     1664      -18     
===========================================
- Hits          5434     5349      -85     
  Misses        1055     1055              
  Partials       496      496              
Files with missing lines Coverage Δ
include/boost/corosio/detail/timer_service.hpp 90.62% <ø> (-2.58%) ⬇️
src/corosio/src/timer.cpp 100.00% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e06fca6...ba75e1b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sgerbino
sgerbino merged commit f038041 into cppalliance:develop Jul 18, 2026
44 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Jul 18, 2026
@sgerbino
sgerbino deleted the pr/waiter-embed branch July 18, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants