-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[libSyntax] Store the token's text in the SyntaxArena #35733
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
8be3707
to
8355d88
Compare
748ca47
to
2509f59
Compare
@swift-ci Please test |
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.
LGTM!
Ah sorry wrong PR |
Do the same thing that we are already doing for trivia: Since RawSyntax nodes always live inside a SyntaxArena, we don't need to tail-allocate an OwnedString to store the token's text. Instead we can just copy it to the SyntaxArena. If we copy the entire source buffer to the syntax arena at the start of parsing, this means that no more copies are required later on. Plus we also avoid ref-counting the OwnedString which should also increase performance.
This decreases the size of RawSyntax nodes from 88 to 64 bytes by - Avoiding some padding by moving RefCount further up - Limiting the length of tokens and their trivia to 32 bits. We would hit this limit with files >4GB but we also hit this limit at other places like the TextLength property in the Common bits.
2509f59
to
c1d65de
Compare
@swift-ci Please test |
Build failed |
@swift-ci Please smoke test macOS platform |
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.
Thanks!
This PR contains commits from #35649
Do the same thing that we are already doing for trivia: Since
RawSyntax
nodes always live inside aSyntaxArena
, we don't need to tail-allocate anOwnedString
to store the token's text. Instead we can just copy it to theSyntaxArena
. If we copy the entire source buffer to the syntax arena at the start of parsing, this means that no more copies are required later on. Plus we also avoid ref-counting theOwnedString
which should also increase performance.Performance checklist (performed on my local machine)