Repository navigation
Shrink the size of Expr - #12610
Merged
Merged
Shrink the size of Expr#12610
Expr#12610Conversation
IanManske
marked this pull request as ready for review
April 21, 2024 15:55
sholderbach
reviewed
Apr 21, 2024
sholderbach
left a comment
Member
There was a problem hiding this comment.
You are really on a refactor train
Generally appreciate the named fields on the new AST types.
I have some nitpicks around construction.
Other than that some benchmark numbers for parsing something larger (e.g. also from nuon) may be useful here.
IanManske
commented
Apr 21, 2024
Co-authored-by: Stefan Holderbach <[email protected]>
Member
|
Inclined to get this in soon if there are no objections by others as this is a breaking change for plugin signatures and generally has the potential to cause some minor merge conflicts if this branch diverges for too long. |
Member
Author
|
Ok merging, since it looks like there's no other objections 😅. |
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.
Description
Continuing from #12568, this PR further reduces the size of
Exprfrom 64 to 40 bytes. It also reducesExpressionfrom 128 to 96 bytes andTypefrom 32 to 24 bytes.This was accomplished by:
Exprwith multiple fields (e.g.,Expr::Thing(A, B, C)), merging the fields into new AST struct types and then boxing this struct (e.g.Expr::Thing(Box<ABC>)).Vec<T>withBox<[T]>in multiple places.Exprs andExpressions should rarely be mutated, if at all, so this optimization makes sense.By reducing the size of these types, I didn't notice a large performance improvement (at least compared to #12568). But this PR does reduce the memory usage of nushell. My config is somewhat light so I only noticed a difference of 1.4MiB (38.9MiB vs 37.5MiB).