-
Notifications
You must be signed in to change notification settings - Fork 450
Separate SyntaxArena for parsing #1063
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
Conversation
@swift-ci Please test |
cc: @jpsim Another optimization, mainly for reducing memory usage. |
30515fe
to
c978222
Compare
🤦 Forgot to rebase onto up-to-date #1053. Updated. |
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
In terms of memory usage I see a modest improvement in SwiftLint going from 159MB to 152MB. I’ll happily take it! |
public convenience init() { | ||
self.init(slabSize: 128) | ||
} |
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.
Couldn't we just not use a BumpPtrAllocator
for the non-parsing case at all? It's only ever going to have a single allocation, so it still seems wasteful to use the BumpPtrAllocator
here.
I love this in general though :)
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.
It still may allocate multiple nodes. See SyntaxData.replacingSelf(_:arena:)
and SyntaxData.replacingChild(_:at:arena:)
By this, single modifier call uses single arena, and creates multiple RawSyntax
in it, from the leaf to the root. And I think that is a good thing.
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.
Okay, fair enough. I think it'd be interesting to compare against allocating as needed but this is okay too 👍
c978222
to
08cb744
Compare
@swift-ci Please test |
/// Parse `source` into as trivia into a list of `RawTriviaPiece` using | ||
/// `parseTriviaFunction`. |
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.
/// Parse `source` into as trivia into a list of `RawTriviaPiece` using | |
/// `parseTriviaFunction`. | |
/// Parse `source` into a list of `RawTriviaPiece` using `parseTriviaFunction`. |
Minimize the default memory footprint of SyntaxArena. Introduce ParsingSyntaxArena as a subclass of SyntaxArena optimized for parsing.
08cb744
to
b087dd3
Compare
@swift-ci Please test |
Minimize the default memory footprint of
SyntaxArena
(for non-parsing). IntroduceParsingSyntaxArena
as a subclass ofSyntaxArena
optimized for parsing.