ioxide.Kestrel: on-reactor services — run ioxide.pg / ioxide.file on the reactor from endpoints#88
Merged
Merged
Conversation
…rel endpoints Lets an endpoint run ioxide.pg / ioxide.file on the connection's reactor, so DB and file I/O stay thread-per-core (Npgsql / blocking file I/O would hop to the ThreadPool instead). - IoxideTransportOptions.OnReactorStart: per-reactor startup hook (open ring-native clients here: PgPool.Start, AssetReader.CreatePool, ...). - IReactorFeature on the ConnectionContext + HttpContext.OnReactor(work) helper: resolves the connection's reactor and runs the work on it — inline when the endpoint is already on that reactor (warm/keep-alive), marshaled via ScheduleOnReactor when not (the first request of a connection, which Kestrel dispatches to the ThreadPool). The ring I/O always runs on the reactor. - IoxideReactor current-reactor seam (ThreadStatic, bound in OnStart) + ReactorPinReader: pins the first read of each connection onto the reactor. - No changes to ioxide / ioxide.pg / ioxide.file / ioxide.tls — only their existing public APIs are used. - Bump packages to 0.0.16.
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.
Lets a Kestrel endpoint run ring-native I/O (ioxide.pg, ioxide.file) on the connection's reactor, so DB and file I/O stay thread-per-core. Without it, Npgsql / blocking file I/O hop to the ThreadPool (Npgsql opens its own connections and the request continuation resumes off-reactor), losing the io_uring advantage for DB-backed endpoints.
Bumps packages to 0.0.16. No changes to
ioxide/ioxide.pg/ioxide.file/ioxide.tls— only their existing public APIs are used, so GenHTTP and other consumers are unaffected.API
IoxideTransportOptions.OnReactorStart: per-reactor startup hook — open ring-native clients here (PgPool.Start(r, …),AssetReader.CreatePool(r, …)).HttpContext.OnReactor(work): resolves the connection's reactor (IReactorFeature) and runsworkon it.How it stays on-reactor
OnReactorrunsworkinline (ioxide's inline resume preserved).OnReactormarshalsworkonto the reactor viaScheduleOnReactor. The query/read always runs on the reactor.ReactorPinReaderadditionally pins the first read of each connection onto the reactor, so header parse stays thread-per-core too.Verified
20/20 fresh connections ran a Postgres query — query thread = reactor every time (marshaled when cold, inline when warm), zero errors.