Skip to content

Benches/Opts#143

Merged
sgerbino merged 6 commits intocppalliance:developfrom
sgerbino:pr/benches
Feb 13, 2026
Merged

Benches/Opts#143
sgerbino merged 6 commits intocppalliance:developfrom
sgerbino:pr/benches

Conversation

@sgerbino
Copy link
Collaborator

@sgerbino sgerbino commented Feb 13, 2026

Summary by CodeRabbit

  • Chores
    • Updated internal allocator method calls in TCP server coroutine initialization.
    • Optimized scheduler's inline budget management and signal handling logic.
    • Refactored scheduler context data members for improved resource allocation efficiency.

Add bidirectional multithread socket throughput benchmarks for all
three backends (corosio, asio coroutine, asio callback) with 2/4/8
thread counts and 32 connections. Expand buffer sizes up to 1 MiB.
Move conntrack drain to per-backend scope so backends don't wait on
each other. Make io_context microbenchmarks opt-in via
--enable-microbenchmarks flag.
Ramp up inline budget geometrically (2→16) when fully consumed, and
reset on partial consumption. Skip inlining when the private queue
has pending work to avoid starving queued ops.
Only cap the inline budget when queued work exists but no idle thread
was woken to absorb it. When another thread is available, let the
adaptive ramp-up run unrestricted since the competing work gets
processed in parallel.

This recovers multi-threaded throughput while preserving single-threaded
fairness for concurrent socket pairs.
Corosio does not yet support concurrency hints, so passing num_threads
to Asio's io_context gives it an unfair locking optimization advantage.
Default-construct all io_context instances for an apples-to-apples
comparison.
Two changes to the epoll scheduler's inline completion budget:

1. Remove the private_queue.empty() gate from try_consume_inline_budget().
   In bidirectional mode, descriptor_state produces two completions per
   epoll event (read + write); the second is posted to the private queue,
   which caused the gate to block all subsequent inline completions.

2. Raise the unassisted fairness cap from 1 to 4. The old cap of 1
   effectively disabled inline completions in single-threaded mode,
   negating the symmetric transfer fast path for small-buffer streaming.
   A cap of 4 amortizes scheduling overhead without filling socket
   buffers at large transfer sizes.
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This change updates allocator function calls in tcp_server.hpp and refactors the epoll scheduler implementation to manage inline budget and context state through new inline_budget_max and unassisted members, adds a try_consume_inline_budget() method, and changes unlock_and_signal_one() to return bool.

Changes

Cohort / File(s) Summary
TCP Server Allocator Update
include/boost/corosio/tcp_server.hpp
Updated allocator source in promise_type initializers from capy::current_frame_allocator() to capy::get_current_frame_allocator().
Epoll Scheduler Context & Signaling
src/corosio/src/detail/epoll/scheduler.hpp, src/corosio/src/detail/epoll/scheduler.cpp
Added inline_budget_max and unassisted state members to scheduler_context; expanded reset_inline_budget() logic to handle unassisted contexts with dynamic budget adjustment; added new try_consume_inline_budget() method; changed unlock_and_signal_one() return type from void to bool to indicate whether waiters existed; updated do_one() to manage unassisted state based on signaling outcomes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through scheduler's dance,
With budgets new and context's stance,
Unassisted flags now track the way,
While allocators fresh guide the day!
Signaling returns a truthful call,
Better balance serves us all. 🌱

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (15 files):

⚔️ include/boost/corosio/tcp_server.hpp (content)
⚔️ perf/bench/asio/callback/http_server_bench.cpp (content)
⚔️ perf/bench/asio/callback/socket_throughput_bench.cpp (content)
⚔️ perf/bench/asio/coroutine/http_server_bench.cpp (content)
⚔️ perf/bench/asio/coroutine/socket_throughput_bench.cpp (content)
⚔️ perf/bench/corosio/socket_throughput_bench.cpp (content)
⚔️ perf/bench/main.cpp (content)
⚔️ src/corosio/src/detail/epoll/scheduler.cpp (content)
⚔️ src/corosio/src/detail/epoll/scheduler.hpp (content)
⚔️ src/corosio/src/detail/kqueue/acceptors.cpp (content)
⚔️ src/corosio/src/detail/kqueue/op.hpp (content)
⚔️ src/corosio/src/detail/kqueue/scheduler.cpp (content)
⚔️ src/corosio/src/detail/kqueue/scheduler.hpp (content)
⚔️ src/corosio/src/detail/kqueue/sockets.cpp (content)
⚔️ src/corosio/src/detail/kqueue/sockets.hpp (content)

These conflicts must be resolved before merging into develop.
Resolve conflicts locally and push changes to this branch.
Title check ❓ Inconclusive The title 'Benches/Opts' is vague and does not clearly convey what changes were made. It's unclear whether this refers to benchmarks, optimizations, or both, and doesn't summarize the actual modifications to the codebase. Use a more descriptive title that clearly indicates the main purpose of the changes, such as 'Optimize inline budget management and allocator handling in scheduler and TCP server' or 'Refactor scheduler inline budget and frame allocator usage'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch pr/benches
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.96%. Comparing base (085506f) to head (0c1a98b).
⚠️ Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
src/corosio/src/detail/epoll/scheduler.cpp 62.50% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #143      +/-   ##
===========================================
- Coverage    81.24%   80.96%   -0.28%     
===========================================
  Files           64       64              
  Lines         5710     5721      +11     
===========================================
- Hits          4639     4632       -7     
- Misses        1071     1089      +18     
Files with missing lines Coverage Δ
include/boost/corosio/tcp_server.hpp 80.43% <100.00%> (ø)
src/corosio/src/detail/epoll/scheduler.hpp 0.00% <ø> (ø)
src/corosio/src/detail/epoll/scheduler.cpp 80.31% <62.50%> (-3.19%) ⬇️

Continue to review full report in Codecov by Sentry.

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

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

@cppalliance-bot
Copy link

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

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

2026-02-13 18:07:00 UTC

@sgerbino sgerbino merged commit 03fef8f into cppalliance:develop Feb 13, 2026
17 checks passed
@sgerbino sgerbino deleted the pr/benches branch February 13, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants