-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Reduce size of syntax::tokenstream::TokenTree #54535
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
Comments
It may be unfortunate to do this but inlining all the fields of enum TokenTree {
Token(Span, Token),
- Delimited(DelimSpan, Delimited),
+ Delimited(DelimSpan, DelimToken, ThinTokenStream),
}
-
- struct Delimited {
- delim: DelimToken,
- tts: ThinTokenStream,
- } |
@dtolnay Were there APIs on |
Inlining DelimSpan does not help. There are five methods on Delimited: rust/src/libsyntax/tokenstream.rs Lines 46 to 81 in a072d1b
|
How does |
The |
@dtolnay I was going to take a look at this but it seems it might have already been done (and so this can be closed). The current pub enum TokenTree {
Token(Span, token::Token),
Delimited(DelimSpan, DelimToken, TokenStream),
} |
Thanks, looks like this was fixed in #56369. |
#53902 raised the size of TokenTree from 32 bytes to 40 bytes, resulting in increased max-rss across a variety of benchmarks by up to 6%.
Here are the data structures involved: playground
Even among the 32 bytes a lot of those were padding. It should be possible to rearrange a few things to drop back to 32 bytes while retaining all the information currently represented.
@nnethercote
The text was updated successfully, but these errors were encountered: