Repository navigation
Keep a dynamic worker's env channels in the server's channel table - #8920
Draft
bartlomieju wants to merge 1 commit into
Draft
bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## biwanczuk/rust-io-channels-crate #8920 +/- ##
===================================================================
Coverage ? 67.77%
===================================================================
Files ? 852
Lines ? 216434
Branches ? 32563
===================================================================
Hits ? 146688
Misses ? 50523
Partials ? 19223 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A dynamic worker had two channel tables. The Rust server's table couldn't hold a C++ channel, so the factory kept the channels its source supplied (its global outbound and the capabilities in its env) in three C++ tables on CompiledWorker::Impl, and RustIoChannelFactory checked them before it asked the Rust table. The Rust side was told how many there were, so that it could number ctx.exports after them. The server's SubrequestChannel and ActorClassChannel are now either one of its own channels or a C++ channel it only stores, and the server's table has an RPC table too. indexDynamicChannels() hands each channel to a DynamicChannels builder as it rewrites the env, and the builder gives it its number, so the server numbers every channel of a worker. A C++ channel goes back to C++ as itself rather than a handle around it, so a facet whose class is a C++ one still fails with the facet error, and only the server's own channels are ever wrapped in a handle; the handle constructors assert that. A channel that is a handle around one of the server's own is unwrapped as it comes in, as config workers store theirs. The io-channels newtypes are now Unpin, which a bridge requires of a Rust type that holds a channel and that C++ borrows mutably, such as the builder. This deletes the three C++ tables, envSubrequestChannel(), the env cases in startSubrequest(), getSubrequestChannelResolved(), getActorClassResolved() and getRpcChannel(), and the channel counts in WorkerInfo with the offsets LinkedChannels kept for them. One difference: worker_unlink() no longer drops a dynamic worker's env channels itself. They go with the server's table when it unlinks the worker, so a request still in flight keeps them until it finishes, as a config worker's channels already were. The subrequest benchmark, run with the order of the two builds alternated on one bazelflare executor, shows no case slower beyond the noise of comparing a build with itself (about 5%).
bartlomieju
force-pushed
the
biwanczuk/rust-io-channels-crate
branch
from
November 26, 2026 10:08
11bb549 to
88560fa
Compare
bartlomieju
force-pushed
the
biwanczuk/rust-io-channels-table
branch
from
November 26, 2026 10:08
b06b34c to
c63c681
Compare
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.
The motivation for this change is to make the Rust server the only owner
of a worker's channel numbers. A dynamic worker loaded through a Worker
Loader had two channel tables: the server's Rust table couldn't hold a
C++ channel, so the factory kept the channels the worker's source
supplied (its global outbound and the capabilities in its
env) inthree C++ tables, looked in them before asking the Rust table, and told
the Rust side how many there were so that it could number
ctx.exportsafter them. The server's
SubrequestChannelandActorClassChannelcannow be a C++ channel that the server only stores, held as an
io-channelstype, and hand the same object back to C++, so a facet'sclass check and channel tokens behave as before. The factory adds a
dynamic worker's channels to the server's table as it rewrites the
env, and the three C++ tables, their special cases in fourIoChannelFactorymethods and the channel counts are gone.One difference is observable. A dynamic worker is unlinked when its
loader drops its stub or the server shuts down, and a request of it
still in flight then, such as one that reached it through a
ctx.exportsstub it handed out, used to lose itsenvchannels andfail with "invalid subrequest channel number" on its next subrequest
through one. It now keeps them until it finishes, as a config worker's
requests already keep theirs; a Worker can reach this only after its
loader has let it go, and the subrequest now succeeds instead of
failing. With the two builds alternated on one bazelflare executor, the
src/bench/subrequestbenchmark shows no case slower beyond the noiseof comparing a build with itself, about 5%. The existing server, io,
channel-interopand Worker Loader tests cover the change.