kj-rs: rework the async bridge waker/event machinery - #7010
Open
danlapid wants to merge 1 commit into
Open
Conversation
Contributor
|
APIError: Invalid Anthropic API Key |
2 similar comments
Contributor
|
APIError: Invalid Anthropic API Key |
Contributor
|
APIError: Invalid Anthropic API Key |
Contributor
|
@danlapid Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7010 +/- ##
==========================================
- Coverage 67.79% 67.75% -0.04%
==========================================
Files 468 468
Lines 132275 132339 +64
Branches 21474 21474
==========================================
Hits 89671 89671
- Misses 29528 29593 +65
+ Partials 13076 13075 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mikea
reviewed
Aug 14, 2026
| // only (see requireCurrentOrTearingDown below), so the exception cost is irrelevant. | ||
| const kj::Executor* current = nullptr; | ||
| auto maybeException = | ||
| kj::runCatchingExceptions([&]() { current = &kj::getCurrentThreadExecutor(); }); |
Contributor
There was a problem hiding this comment.
surely we can add utility method for you!
mikea
reviewed
Aug 14, 2026
| @@ -0,0 +1,144 @@ | |||
| // Regression test: FutureWakerCell "neutralize-on-drop". | |||
Contributor
There was a problem hiding this comment.
I don't think this file tests anything? outside of this test?
mikea
reviewed
Aug 14, 2026
| @@ -0,0 +1,321 @@ | |||
| // Regression test: one shared kj Event as the onReady target of MANY concurrent pending nodes. | |||
Contributor
There was a problem hiding this comment.
this too doesn't seem to be kj-rs specific?
danlapid
force-pushed
the
dlapid/rustIoPrep
branch
from
August 14, 2026 23:24
1b12cd5 to
dbc8012
Compare
Groundwork for the tokio-backed Rust I/O backend (kj-rs-tokio / kj-rs-io, landing separately); kj-rs itself stays a pure Promise<->Future bridge. - Replace KjWaker with FutureWakerCell: every cloned waker is a same-thread cell (non-atomic kj::Refcounted; the bridge's single-thread axiom) that arms the owning FuturePollEvent directly via Event::armDepthFirst(). The cell's link to the event is weak and structurally invalidated when the event dies, so wakers Rust retains past the future's lifetime (e.g. parked in a channel's AtomicWaker) neutralize into safe no-ops instead of arming a freed event. Waker ownership round-trips through RawWaker data slots via kj::Rc::disown()/reown() -- hence the capnp-cpp pin bump to the current v2 head, which carries those (merged upstream). - Replace the LinkedGroup machinery (linked-group.h + test) with an intrusive weak link (RustPromiseAwaiter::link / FuturePollEvent::leaves). - Make bridged kj::Promise<T>s eager by default: the Rust future is polled to its first suspension point at conversion, so KJ callers no longer need a manual .eagerlyEvaluate(nullptr); RustFuture::lazily() is the escape hatch for the rare cold case. - Convert panics escaping a bridged future's poll into kj::Exceptions (a rejected promise) instead of aborting the process, mirroring the sync bridge's catch_unwind path. - Add a thread-local armed-waker hook so an integrating kj::EventPort that drives tokio tasks inside its own wait() (the upcoming kj-rs-tokio) can nudge itself out of a blocking park; null/no-op by default. - Split the cxx bridge module out of lib.rs into ffi.rs, and quarantine unsafe into named FFI islands: deny(unsafe_code) crate-wide, re-allowed per-module only where the FFI seam genuinely needs it. - Depend on @capnp-cpp//src/kj:kj-async-core instead of the :kj-async umbrella, keeping kj-rs (and everything built on it) off the concrete kj OS event loop. - Qualify bare uint as kj::uint in src/rust/kj/tests/ffi-test.c++: these dependency changes make that target newly compile on Windows CI, where no global uint exists (POSIX gets one from sys/types.h). - New tests: waker neutralization across event death (neutralize-waker-test), FuturePollEvent shared-event semantics (shared-event-test), and expanded future/awaiter coverage.
danlapid
force-pushed
the
dlapid/rustIoPrep
branch
from
August 15, 2026 03:07
dbc8012 to
731a392
Compare
jasnell
approved these changes
Aug 15, 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.
Groundwork for the tokio-backed Rust I/O backend (kj-rs-tokio / kj-rs-io, landing separately); kj-rs itself stays a pure Promise<->Future bridge.