Reduce overhead in the typescript sdk#4744
Merged
joshua-spacetime merged 1 commit intomasterfrom Apr 6, 2026
Merged
Conversation
bbcbcaf to
9bec1cf
Compare
This was referenced Apr 6, 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.
Description of Changes
1. Cache the connection-id hex prefix and reuse it when generating event IDs
Previously, the SDK rebuilt the connection-id string on every event. Now it computes the prefix once per connection-id update and reuses it.
2. Replace Promise-chained inbound message processing with a synchronous ordered drain loop
Now inbound messages are still processed through a direct drain loop instead of a promise chain to reduce scheduler overhead.
3. Cache encoded reducer/procedure names and use specialized CallReducer/CallProcedure writers
Previously, reducer/procedure calls always went through the generic
ClientMessageobject path and re-encoded the method name each time. Now the SDK caches UTF-8 encoded reducer/procedure names and uses directCallReducer/CallProcedurewriters on the hot path, while keeping the generic path as fallback.API and ABI breaking changes
None
Expected complexity level and risk
2
Testing
Manual: 100K -> 130K TPS running keynote-2 benchmark on apple m2