Skip to content

perf: batch request handoff with recv_many - #100

Merged
j03-dev merged 1 commit into
perf/t1-release-allocatorfrom
perf/t2-batch-handoff
Oct 31, 2026
Merged

j03-dev merged 1 commit into
perf/t1-release-allocatorfrom
perf/t2-batch-handoff

Conversation

@j03-dev

@j03-dev j03-dev commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

T2: batch request handoff

Stacked on #99 (perf/t1-release-allocator). Base this PR on perf/t1-release-allocator, not main, until #99 lands.

Change

process_requests now drains the request channel in batches with recv_many(&mut batch, 64) and processes the drained batch on the existing single consumer. Ownership, ordering, back-pressure, and channel_capacity are unchanged.

Step B (spawning the batch instead of processing it sequentially) was not pursued: Step A shows a small positive result, and keeping the single consumer avoids changing request ordering/concurrency semantics in this ticket.

Before/after (T1 -> T2)

Same app/build as #99, swapped .so variants in place, 10 interleaved rounds x 10s, server 0-3, wrk 4-7, -t4 -c64.

metric T1 T2 delta
median req/s 61,792 66,017 +6.8%
paired median req/s (T2/T1) +2.7%
p50 0.850 ms 0.817 ms -3.9%
p99 3.75 ms 3.28 ms -12.5%
CPU ms/request 0.03118 0.03085 -1.1%
context switches/request 0.18729 0.18273 -2.4%

Context switches/request (the available user-space futex proxy; kernel futex symbols are unavailable with perf_event_paranoid=2 and no sudo) drop by 2.4%. CPU/request drops by 1.1%.

Host load is noisy and cyclical; the paired medians are the more reliable comparison. Absolute req/s is only valid within the interleaved run.

Validation

  • cargo fmt --check: pass
  • cargo check: pass
  • pytest -q tests: 38 passed

CI note

Linux wheels are now built on manylinux_2_28 (glibc >= 2.28) so mimalloc 0.1.52 builds on the cross targets; the older manylinux2014 cross toolchains lack stdatomic.h and reject -Wdate-time. The deltas above were measured on x86_64 with the same allocator on both sides. On the rebased stack, cargo fmt --check, cargo test --lib --bins, and the full pytest suite (39 passed) all pass.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4abb879d-e67c-4e5a-8fb9-582aace701be

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@j03-dev
j03-dev force-pushed the perf/t2-batch-handoff branch 2 times, most recently from 3197ba8 to e00e8e8 Compare October 31, 2026 04:34
@j03-dev
j03-dev force-pushed the perf/t1-release-allocator branch from 6a81a6e to 08df142 Compare October 31, 2026 05:05
@j03-dev
j03-dev force-pushed the perf/t2-batch-handoff branch from e00e8e8 to b3e2330 Compare October 31, 2026 05:06
@j03-dev
j03-dev force-pushed the perf/t2-batch-handoff branch from b3e2330 to 1a1a7dd Compare October 31, 2026 05:06
@j03-dev
j03-dev merged commit 5dd73ba into perf/t1-release-allocator Oct 31, 2026
15 of 17 checks passed
@j03-dev
j03-dev deleted the perf/t2-batch-handoff branch October 31, 2026 06:08
j03-dev added a commit that referenced this pull request Nov 4, 2026
* perf: use mimalloc and enable fat LTO

* ci: build manylinux wheels on glibc 2.28

* perf: batch request handoff with recv_many (#100)

* perf: run async handlers concurrently (#101)

* chore: bump pyo3 version

* chore: format code

* fix: ci
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.

1 participant