-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Investigating compressing fallback spans into fewer bytes #167
Comments
Interestingly the That being said, the spans which we get within The table is effectively a 2-way mapping from handle to value, and from value to handle. Something vaguely like the following: struct SpanInterning {
data: BTreeMap<Span, SpanInfo>,
interner: HashMap<SpanInfo, Span>,
} Interestingly, as |
That seems promising. It would be good to benchmark the 4 byte approach using an intern table and nightly_works against an 8 byte approach laid out as:
because our lexer always produces lo and hi separated by the width of the token, so lo can't be u32::MAX. |
Hmm, yeah that could work. We'd likely also want to have some sort of dynamic test failure in case rustc ever decides to change I'm also pretty sure that, even if |
Syn has quite a few places that are |
The compiler's proc_macro::Span uses an efficient encoding in 4 bytes. Currently our span when procmacro2_semver_exempt is enabled is a whopping 12 bytes because it essentially looks like:
And it goes up to 16 bytes when embedded next to 8-byte pointers due to additional padding.
This has a performance impact because syntax trees contain lots of spans.
We need to investigate interning the spans or some other trick to cut the size.
The text was updated successfully, but these errors were encountered: