fix server_native callback wakeups and request uri handling - #12
kingwill101 wants to merge 14 commits into
Conversation
Cap shared proxy runtimes to one worker thread and back off native direct polling when idle. Also coalesce direct wakeup callbacks and keep regression tests for the new runtime behavior.
Use synchronous request delivery for NativeHttpServer and drain short bursts of queued direct frames before yielding. This removes extra event queue hops in the callback path and improves framework benchmarks in native mode.
Use a direct encoded-payload fast path for non-detached callback responses and fall back to full bridge frames only when detach/tunnel semantics are needed. This cuts temporary response-header allocations in the native callback path.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
To view this pull requests documentation preview, visit the following URL: docs.page/kingwill101/routed~12 Documentation is deployed and generated using docs.page. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
|
Note Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
✅ Created PR with unit tests: #13 |
|
@kingwill101 Great work on the pr. Love your work . Just had a question what if you used actix or even directly io_uring instead of tokyo. Can server native be scaled even more , as the more costly part of it is the boundary between dart and rust, so i don't think that can be optimised. I was working on a proof of concept dart with hot paths and http parsing in zig from io_uring in linux.
I even raised a discussion in the dart sdk about a custom server specific runtime. It would be great if dart eventually progresses on the server side and makes it more performant |
Summary
HttpRequest.uri/requestedUrireconstruction forserver_nativebridge requests so the request scheme remains available to framework codeHttpRequestcompatibility and bridge URI behaviorWhy
A recent performance refactor left two regressions on the issue #10 branch:
BridgeHttpRequest.uribecame origin-form for normal requests, which clearedhttpRequest.uri.schemeand broke downstream consumers that derive request scheme fromHttpRequest.uridirectRequestCallbackwas unset, so the first queued frame after idle could sit until the next poll window expiredImpact
Request.scheme/X-Forwarded-Protobehavior forserver_nativerequests againnativeCallback: truedirect transportRoot Cause
The branch that reduced isolate-scaling overhead switched callback request URI materialization to a relative URI and changed the direct queue drain loop to idle/backoff polling without wiring Rust's existing direct callback wake signal into Dart.
Validation
dart analyze packages/server_native/lib/src/bridge/bridge_runtime_request.dart packages/server_native/lib/src/bridge/bridge_runtime_request_uri.dart packages/server_native/lib/src/server_boot_proxy_direct.dart packages/server_native/test/bridge_runtime_test.dart packages/server_native/test/serve_ffi_http_test.dartdart test packages/server_native/test/bridge_runtime_test.dartdart test test/serve_ffi_http_test.dartfrompackages/server_nativedart test test/ffi_http_server_test.dart --plain-name "NativeHttpServer reconstructs requestedUri from forwarded headers"frompackages/server_nativeIssue #10 Repro Check
Local
wrkrun on an 8-logical-CPU Linux host with-t8 -c200 -d15s:dart:io x1dart:io x8server_native x1server_native x8That reproducer no longer shows the flat multi-isolate behavior from #10;
server_nativescaled by about 57.8% on this host.Fixes #10