feat: static dispatch for jsonrpc request handlers#3649
Draft
brbrr wants to merge 4 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (41.60%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3649 +/- ##
==========================================
- Coverage 77.12% 71.96% -5.17%
==========================================
Files 395 399 +4
Lines 35645 36602 +957
==========================================
- Hits 27492 26340 -1152
- Misses 6153 8139 +1986
- Partials 2000 2123 +123 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Bench results:
Time (sec/op)
Allocs/op
Bytes/op
The typed-dispatch refactor only eliminates reflection in the handler call (replacing reflect.Value.Call with a typed closure), but per-request time is dominated by encoding/json's
reflection-driven decode of params — which we still pay because we still use stdlib JSON. The call-site reflection we removed costs ~30-50ns; the per-field json.Unmarshal reflect walks
we kept cost ~400ns each, so the savings get drowned out. The only paths that visibly benefit are call-overhead-dominated ones (no-args, batches, encode-heavy) where the reflect.Call
savings aren't masked — decode-heavy paths come out at parity with main.