Skip to content

Reduce overhead in the typescript sdk#4744

Open
joshua-spacetime wants to merge 1 commit intomasterfrom
joshua/ts-sdk-perf
Open

Reduce overhead in the typescript sdk#4744
joshua-spacetime wants to merge 1 commit intomasterfrom
joshua/ts-sdk-perf

Conversation

@joshua-spacetime
Copy link
Copy Markdown
Collaborator

@joshua-spacetime joshua-spacetime commented Apr 3, 2026

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 ClientMessage object path and re-encoded the method name each time. Now the SDK caches UTF-8 encoded reducer/procedure names and uses direct CallReducer / CallProcedure writers 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

MAX_INFLIGHT_PER_WORKER=512 pnpm run bench test-1 --seconds 10 --concurrency 50 --alpha 1.5 --connectors spacetimedb

@joshua-spacetime joshua-spacetime changed the title Reducer overhead in the typescript sdk Reduce overhead in the typescript sdk Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant