-
-
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
Handle ASCII identifiers quickly. #94
Conversation
Because they're very common. rustc's lexer has the same optimization. This speeds up various runs of `cargo` in rustc-perf, the best by 4%.
Nice! FWIW @nnethercote there are a lot of inefficiencies in proc-macro2, it's not currently engineered at all to be speedy. That being said it also means there's a lot of opportunities for improvement :) You're likely seeing this related to custom derive (aka In general though we were under the assumption that custom derive was such a small fraction of the compilation process that we wouldn't need to optimize it too much here. If that's not the case though that could be problematic... In any case there's probably much lower hanging fruit in the That clause at the end of the In any case that's a lot of information and there's definitely more to this rabbit hole! I'm fine with whichever strategy you'd like. Would you prefer to land this now and look into those optimizations later? |
I agree, it seems likely that it is all from that macro rule. A Deserialize impl expands to quite a lot of ident tokens. |
Thank you for the detailed explanation. You are right about it being related to In terms of the broader optimization picture: |
I spoke too soon. I see that the Similarly, when compiling I feel like I've just grabbed ahold of a loose thread hanging out of a tangled ball of wool... |
@alexcrichton: on IRC you gave me a patch for Measurements, on a "clean incremental, check" build of cargo:
So this PR still seems worth landing. |
The remaining invocations after the quote patch are probably from Syn parsing the input on the way into the custom derive macro. |
@alexcrichton: I could file a PR for your quote change, but it might be easier if you do it given that you are the patch author. Let me know what you'd prefer. |
This patch as written unfortunately requires Rust 1.20+ and quote currently supports 1.15. Maybe there is a different way to do it? I am not planning to bump rustc version requirements until after 2018 edition ships. |
I can see how to optimize the identifier parsing, but the benefit would be smaller than avoiding (most of) the identifier parsing altogether. |
@dtolnay: is the patch still relevant? Rust 2018 has shipped now. |
Opened a PR: dtolnay/quote#91. |
Because they're very common. rustc's lexer has the same optimization.
This speeds up various runs of
cargo
in rustc-perf, the best by 4%.I admit to not understanding how
proc-macro2
is used when rustc buildscargo
. I don't need to recompile rustc for the changes to take effect, speedwise, so somehowproc-macro2
must be both compiled and run whilecargo
is being compiled.