Reduce allocations on event/request hot paths#50
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/SLNE-Development/surf-redis/sessions/09827c12-6747-4552-bd9b-c03aee05cb35 Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SLNE-Development/surf-redis/sessions/09827c12-6747-4552-bd9b-c03aee05cb35 Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
twisti-dev
April 30, 2026 22:52
View session
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.
Profiling-driven cleanup of the publish/dispatch hot paths in
RedisEventBusImplandRequestResponseBusImpl. Wire format and public API are unchanged.Streaming envelope serialization
Publish previously did
encodeToJsonElement(fullJsonElementtree allocation) followed byencodeToString(re-walks the tree). Replaced with encode-onlyKSerializers that stream the typed payload straight into the output:Element names match the existing data-class envelopes so
JsonNamingStrategy.SnakeCaseproduces identical bytes. The receive path still uses the data-class envelopes (concrete payload type unknown untileventClassis read).Other changes
handleIncomingMessagenow launches one coroutine that iterates handlers, instead of one per handler. Per-handler exception isolation preserved via try/catch.responseTypeRegistrywrites.containsKeyshort-circuits the per-requestputIfAbsentonce the response type has been seen.registrationLock.writeblocks in both buses — one write per handler, no inconsistent intermediate state.KotlinSerializerCache. Added aMISSINGsentinel inside theClassValueso classes without a serializer aren't re-resolved on every lookup.serializeEvent/serializeRequest/serializeResponsehelpers and theEventEnvelope.forEvent/RequestEnvelope.forRequest/ResponseEnvelope.forResponsefactories.Not done
processStreamEventsplit avoidance, (9)Flux.intervalpolling, (10) counted-loop iteration — out of scope for the recommended subset.LuaScriptExecutorcached-SHA fast-path — Aedile'sgetIfPresentissuspendand.underlying()is parameterized overDeferred<V>, notV. Left as-is pending a way to verify against a working build.Build note
The repo's settings plugin (
dev.slne.surf.api.gradle.settings, hosted onrepo.slne.dev/reposilite.slne.dev) isn't reachable from this sandbox, so changes were not compiled here.