-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve getBlockByNumber
performance with lazy-loaded JSON
#266
Conversation
to reduce redundant JSON marshalling and unmarshalling to improve performance
eth_blockNumber
eth_getBlockByNumber
eth_getBlockByNumber
getBlockByNumber
performance with lazy-loaded JSON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @wanliqun)
rpc/lazy.go
line 8 at r2 (raw file):
) type lazyDecodedJsonObject[T any] struct {
Better to add necessary comment for performance consideration.
rpc/lazy.go
line 9 at r2 (raw file):
type lazyDecodedJsonObject[T any] struct { cachedBytes json.RawMessage
Why not use []byte
type directly? Because the input parameter type of UnmarshalJSON
is []byte
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @boqiu)
rpc/lazy.go
line 8 at r2 (raw file):
Previously, boqiu (Bo QIU) wrote…
Better to add necessary comment for performance consideration.
Done
rpc/lazy.go
line 9 at r2 (raw file):
Previously, boqiu (Bo QIU) wrote…
Why not use
[]byte
type directly? Because the input parameter type ofUnmarshalJSON
is[]byte
.
I think `json.RawMessage` is okay because it explicitly indicates that the field contains raw JSON data, improving code readability and understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @wanliqun)
to reduce redundant JSON marshalling and unmarshalling to improve performance
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)