Repository navigation
perf: run async handlers concurrently - #101
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
j03-dev
force-pushed
the
perf/t2-batch-handoff
branch
from
October 31, 2026 04:30
f091976 to
3197ba8
Compare
j03-dev
force-pushed
the
perf/t3-async-concurrency
branch
from
October 31, 2026 04:30
3617a6b to
5d2b7be
Compare
j03-dev
force-pushed
the
perf/t2-batch-handoff
branch
from
October 31, 2026 04:34
3197ba8 to
e00e8e8
Compare
j03-dev
force-pushed
the
perf/t3-async-concurrency
branch
from
October 31, 2026 04:34
5d2b7be to
3fe2f37
Compare
j03-dev
force-pushed
the
perf/t2-batch-handoff
branch
from
October 31, 2026 05:06
e00e8e8 to
b3e2330
Compare
j03-dev
force-pushed
the
perf/t3-async-concurrency
branch
from
October 31, 2026 05:06
3fe2f37 to
96f6f5c
Compare
j03-dev
force-pushed
the
perf/t2-batch-handoff
branch
from
October 31, 2026 05:06
b3e2330 to
1a1a7dd
Compare
j03-dev
force-pushed
the
perf/t3-async-concurrency
branch
from
October 31, 2026 05:06
96f6f5c to
00be212
Compare
Base automatically changed from
perf/t2-batch-handoff
to
perf/t1-release-allocator
October 31, 2026 06:08
j03-dev
force-pushed
the
perf/t3-async-concurrency
branch
from
October 31, 2026 06:11
00be212 to
5152df6
Compare
j03-dev
added a commit
that referenced
this pull request
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
T3: run async handlers concurrently
Stacked on #100 (
perf/t2-batch-handoff); base this PR onperf/t2-batch-handoffuntil the stack lands.Problem
In async mode,
process_requestsawaited every handler on the single consumer task, soasync defhandlers ran one at a time. 20 concurrent requests to a handler that doesawait asyncio.sleep(0.5)took ~10s.Change
pyo3_async_runtimes::tokio::get_current_locals.pyo3_async_runtimes::tokio::scope(locals, ...)so the handler still sees the correct Python event loop and contextvars.JoinSet; abort and drain it on shutdown.Before/after
tests/test_http_server.py::test_async_handlers_run_concurrently: 20 concurrentGET /slow, each handlerawait asyncio.sleep(0.5).Test assertion:
< 2.0 s. Before fails, after passes.The test runs the async app in a subprocess (
tests/async_app.py) so it does not collide with the session-scoped sync server:ctrlc::set_handleris process-global and only one server can own it per process.Sync-mode regression check (swapped
.so, 10 interleaved rounds x 10s, server0-3,wrk4-7):Sync mode is within noise; the change only affects async mode.
Validation
cargo fmt --check: passcargo clippy --all-targets --all-features: only the pre-existingtoo_many_argumentswarning insrc/response.rscargo test --lib --bins: passpytest -q tests: 39 passedCI note
Linux wheels are now built on
manylinux_2_28(glibc >= 2.28) somimalloc 0.1.52builds on the cross targets; the older manylinux2014 cross toolchains lackstdatomic.hand 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 fullpytestsuite (39 passed) all pass.