-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
perf: incremental json parsing for AppGenesis #21249
Conversation
WalkthroughWalkthroughThe changes introduce incremental JSON parsing to the Changes
Assessment against linked issues
Tip New review modelWe have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. New featuresWalkthrough comment now includes:
Notes:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
x/genutil/types/genesis.go (1)
104-124
: Well-structured function with robust error handling.The
genesisFromReadSeeker
function is well-implemented, efficiently handling JSON decoding with a fallback mechanism. The error messages are descriptive and helpful.Consider addressing the TODO for incremental parsing when the feature becomes available in
cmtjson
.
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between e30dc06 and eb78dd13dcfd29bba087a25efb4989cc737aa699.
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- x/genutil/types/genesis.go (1 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
Additional context used
Path-based instructions (1)
x/genutil/types/genesis.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (1)
x/genutil/types/genesis.go (1)
92-102
: LGTM! But verify the function usage in the codebase.The changes to
AppGenesisFromReader
improve efficiency by leveragingio.ReadSeeker
. The fallback mechanism to handle non-seekable readers is well-implemented.Ensure that all usages of
AppGenesisFromReader
are compatible with these changes.Verification successful
Function usage verified and compatible.
The
AppGenesisFromReader
function is used withio.Reader
types across the codebase, ensuring compatibility with the recent changes. No issues found with the current usages.
x/genutil/types/genesis.go
usesbufio.NewReader(file)
.x/genutil/types/chain_id_test.go
usesstrings.NewReader(BenchmarkGenesis)
.testutil/sims/state_helpers.go
usesbufio.NewReader(file)
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `AppGenesisFromReader` are compatible with the new logic. # Test: Search for the function usage. Expect: Proper handling of io.Reader and io.ReadSeeker. rg --type go -A 5 $'AppGenesisFromReader'Length of output: 1564
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between eb78dd13dcfd29bba087a25efb4989cc737aa699 and 4c6a8e088710fb0460f8ac50885b57c5ba851e5c.
Files selected for processing (1)
- x/genutil/types/genesis.go (2 hunks)
Additional context used
Path-based instructions (1)
x/genutil/types/genesis.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (2)
x/genutil/types/genesis.go (2)
143-150
: LGTM! Simplified file reading logic.The function effectively delegates reading logic to
AppGenesisFromReader
, enhancing maintainability. The use offilepath.Clean
ensures path sanitization.
91-132
: LGTM! Incremental JSON parsing improves performance.The changes effectively enhance performance by utilizing
io.ReadSeeker
for incremental parsing. The fallback mechanism and improved error handling add robustness.Verification successful
Consistent use of
errors.Join
for error handling.The usage of
errors.Join
in theAppGenesisFromReader
function aligns with its application throughout the codebase, ensuring a consistent and robust error handling strategy.
x/genutil/types/genesis.go
: Proper usage oferrors.Join
for combining errors.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of errors.Join in the codebase. # Test: Search for occurrences of errors.Join. Expect: Proper usage in error handling. rg --type go 'errors\.Join'Length of output: 2224
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 4c6a8e088710fb0460f8ac50885b57c5ba851e5c and 52c5bb242986ea1dbc55a6aa3d51b1ca2e1f5d74.
Files selected for processing (1)
- x/genutil/types/genesis.go (3 hunks)
Additional context used
Path-based instructions (1)
x/genutil/types/genesis.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
golangci-lint
x/genutil/types/genesis.go
95-95: naked return in func
AppGenesisFromReader
with 43 lines of code(nakedret)
101-101: naked return in func
AppGenesisFromReader
with 43 lines of code(nakedret)
109-109: naked return in func
AppGenesisFromReader
with 43 lines of code(nakedret)
116-116: naked return in func
AppGenesisFromReader
with 43 lines of code(nakedret)
132-132: naked return in func
AppGenesisFromReader
with 43 lines of code(nakedret)
Additional comments not posted (1)
x/genutil/types/genesis.go (1)
142-149
: LGTM!The function correctly handles file operations and error management.
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 52c5bb242986ea1dbc55a6aa3d51b1ca2e1f5d74 and 28efae216261b65d59596cc04bca599887356317.
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- x/genutil/types/genesis.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- CHANGELOG.md
- x/genutil/types/genesis.go
@julienrbrt @kocubinski updated with latest |
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 28efae216261b65d59596cc04bca599887356317 and 11a38191539ecb70c9380f2313301859b16d0273.
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
I'm not quite sure why |
Hey, thanks! We'll review |
Hi @kocubinski I've answered the question about |
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.
So before the memory cost would've been sizeof(AppGenesis) + sizeof(input_file) but now we have sizeof(AppGenesis) + sizeof(input_file_buffer) which can be a significant when dealing with large files.
Thank you for that clarification, LGTM.
11a3819
to
7bccb45
Compare
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 11a38191539ecb70c9380f2313301859b16d0273 and 7bccb45.
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
ping @julienrbrt @cool-develope, since the rules require 2 approvals, could I please get an additional review on this PR so it can be merged? |
(cherry picked from commit 3db444a)
Co-authored-by: psiphi5 <[email protected]>
Description
Closes: #19269
Incremental JSON parsing for AppGenesis.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Bug Fixes
Documentation