Skip to content

Batch SQE submission#36

Merged
vadimskipin merged 2 commits into
mainfrom
vskipin/submit-batching
May 10, 2026
Merged

Batch SQE submission#36
vadimskipin merged 2 commits into
mainfrom
vskipin/submit-batching

Conversation

@vadimskipin
Copy link
Copy Markdown
Collaborator

net-perf @ 1024 connections (60s/10s)

  ┌────────────────┬─────────┬─────────┬─────────────────────────────────────────────────────────┐
  │     Metric     │ Before  │  After  │                            Δ                            │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ RPS            │ 1917k   │ 2223k   │ +16%                                                    │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ p50            │ 154 µs  │ 447 µs  │ +190%                                                   │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ p95            │ 3493 µs │ 671 µs  │ −81%                                                    │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ p99            │ 3607 µs │ 861 µs  │ −76%                                                    │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ p99.9          │ 3816 µs │ 1787 µs │ −53%                                                    │
  ├────────────────┼─────────┼─────────┼─────────────────────────────────────────────────────────┤
  │ p99/p50 spread │ 23×     │ 1.9×    │ distribution tightened from bimodal to roughly unimodal │
  └────────────────┴─────────┴─────────┴─────────────────────────────────────────────────────────┘

  Engine ratios at 1024 conns

  ┌───────────────────────┬─────────────────────────┬───────────────────────────┐
  │                       │         Before          │           After           │
  ├───────────────────────┼─────────────────────────┼───────────────────────────┤
  │ silk vs raw epoll RPS │ 0.79×                   │ 0.89×                     │
  ├───────────────────────┼─────────────────────────┼───────────────────────────┤
  │ silk vs asio RPS      │ ~5.0×                   │ ~5.9×                     │
  ├───────────────────────┼─────────────────────────┼───────────────────────────┤
  │ silk vs raw epoll p99 │ 0.15× (epoll 7× better) │ 0.64× (epoll 1.6× better) │
  └───────────────────────┴─────────────────────────┴───────────────────────────┘

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces bounded batching for io_uring SQE submission in the fiber scheduler to reduce syscall frequency and improve high-concurrency tail latency, and updates the performance documentation accordingly.

Changes:

  • Add threshold-gated submitIo(flush) to batch SQEs and amortize io_uring_submit across multiple fibers.
  • Force-flush partial batches at dispatch/steal boundaries and in latency-sensitive paths (wakeup/proxy).
  • Update docs/perf.md benchmark results and latency-profiler explanations to reflect the new submission model.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/fibers/fiber.cpp Implements threshold-based SQE batching, adds forced flush points, and moves IO submit profiling into submitIo().
docs/perf.md Refreshes net-perf metrics and updates the latency-profiler narrative for dispatch-batch submission.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fibers/fiber.cpp
Comment on lines +884 to 898
if (profiler)
{
uint64_t startCycles = Tsc::getCycles();

int r = ::io_uring_submit(&ring);
SILK_ASSERT(r >= 0);

profileEvent(ProfileEventKind::IO_SUBMIT, 0, Tsc::getCycles() - startCycles);
}
else
{
int r = ::io_uring_submit(&ring);
SILK_ASSERT(r >= 0);
}

Comment thread src/fibers/fiber.cpp Outdated
Comment on lines +850 to +852
// flush=false (default): pressure-relief mode for dispatch loops -- only
// submit once at least IO_URING_FLUSH_THRESHOLD SQEs are queued, otherwise
// let the next fiber accumulate more work before paying the syscall.
Comment thread src/fibers/fiber.cpp
Comment on lines +858 to +860
// IO_SUBMIT profile event represents the syscall cost; per-fiber latency
// lives in IO_WAIT. Category 0 because a single io_uring_enter covers SQEs
// from any fibers that contributed.
@vadimskipin vadimskipin force-pushed the vskipin/submit-batching branch from 6eab67b to 5814c2f Compare May 10, 2026 13:27
@vadimskipin vadimskipin merged commit bfed219 into main May 10, 2026
14 checks passed
@vadimskipin vadimskipin deleted the vskipin/submit-batching branch May 10, 2026 13:40
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