dtolnay / dtolnay/proc-macro2

Investigating compressing fallback spans into fewer bytes

Open
#167 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
934
Forks
135
PR merge metrics
No merged PRs in 30d

Description

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:

```rust
enum Span { // tag + padding = 4 bytes
Compiler(proc_macro::Span), // 4 bytes
Fallback(struct Span { // 8 bytes
lo: u32,
hi: u32,
}),
}
```

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.