-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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] Reduce allocs when parsing Program #2562
Merged
Merged
Conversation
This file contains 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
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
d0cd
reviewed
Oct 24, 2024
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.
In general, I am in favor of this PR.
I think it would be good to establish a more rigorous evaluation process for these sorts of parser changes.
For example, a regression test suite that checks against all programs deployed on-chain.
zosorock
requested review from
evanmarshall,
lukenewman,
asharma13524,
fulltimemike,
zkxuerb,
zklimaleo and
a team
October 26, 2024 02:30
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.
Motivation
Replaces #2516
Original PR message:
(transferred from ProvableHQ#5, and asking @d0cd for a review as suggested there)
Program parsing is something that has always been prominent in node heap profiles, and this PR targets its highest-level bits.
While parsing its components, we currently use a combination of the functions many1 and alt, which cause us to clone the parsed input at least once (more if it's not the expected component) for every component; this can be avoided by removing the use of alt in favor of a new intermediate function which is able to determine the type of the parsed component in advance and select the right parsing function without "making guesses". This is what the 1st commit does.
The 2nd commit avoids all the clones of program components that we currently perform presumably as a workaround introduced in order to be able to manage the notoriously tricky nom errors. With some refactoring (i.e. applying map_res only to potential errors), we are able to remove many allocations.
These changes reduce the number of allocations caused by the parsing of a Program in a 15-minute run of a --dev node by ~8% (an absolute decrease of over 54k allocs), making the process faster. The impact on the performance of the node as a whole depends on the number and size of the Programs it has to process.
Test Plan
CI run link