Skip to content
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

Order rules in quote_token! and quote_token_spanned! by frequency. #209

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Order rules in quote_token! and quote_token_spanned! by frequency. #209

merged 1 commit into from
Mar 17, 2022

Conversation

nnethercote
Copy link
Contributor

This reduces cargo check times by 4-9% on a few crates that use
quote! heavily.

This reduces `cargo check` times by 4-9% on a few crates that use
`quote!` heavily.
@nnethercote
Copy link
Contributor Author

Here are some cargo-check measurements done with the harness from rustc-perf and six crates known to use quote! heavily.

Benchmark & Profile Scenario % Change Significance Factor?
pest_generator-2.1.3 check incr-unchanged -9.59% 47.97x
num-derive-0.3.3 check incr-unchanged -9.31% 46.55x
futures-macro-0.3.19 check incr-unchanged -7.71% 38.56x
mockall_derive-0.11.0 check incr-unchanged -7.69% 38.45x
pest_generator-2.1.3 check full -5.88% 29.42x
num-derive-0.3.3 check full -5.63% 28.14x
pest_generator-2.1.3 check incr-full -5.34% 26.68x
num-derive-0.3.3 check incr-full -5.24% 26.20x
futures-macro-0.3.19 check full -4.64% 23.18x
mockall_derive-0.11.0 check full -4.31% 21.54x
futures-macro-0.3.19 check incr-full -4.05% 20.24x
mockall_derive-0.11.0 check incr-full -3.90% 19.48x
scroll_derive-0.11.0 check incr-full -0.00% 0.01x
scroll_derive-0.11.0 check full 0.00% 0.01x
ctor-0.1.21 check full -0.00% 0.00x
ctor-0.1.21 check incr-unchanged -0.00% 0.00x
ctor-0.1.21 check incr-full -0.00% 0.00x
scroll_derive-0.11.0 check incr-unchanged -0.00% 0.00x

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Would swapping the two token arguments of quote_token! help? Naïvely it seems like matching immediately on the first token, instead of parsing an ident in every rule before matching on the second token, might be quicker.

@dtolnay dtolnay merged commit 3d12669 into dtolnay:master Mar 17, 2022
@nnethercote nnethercote deleted the reorder-quote_token branch March 17, 2022 08:49
@nnethercote
Copy link
Contributor Author

Would swapping the two token arguments of quote_token! help?

Quite possibly. I'll try it tomorrow, and likewise for the macros above quote_token!.

@lqd
Copy link
Contributor

lqd commented Mar 17, 2022

I was curious and tried David's suggestion: it does indeed improve things a tiny bit.

Benchmark & Profile Scenario % Change Significance Factor ?
pest_generator-2.1.3 check incr-unchanged -2.18% 10.91x
num-derive-0.3.3 check incr-unchanged -2.05% 10.26x
mockall_derive-0.11.0 check incr-unchanged -1.79% 8.97x
pest_generator-2.1.3 check full -1.34% 6.69x
num-derive-0.3.3 check full -1.21% 6.06x
pest_generator-2.1.3 check incr-full -1.18% 5.90x
futures-macro-0.3.19 check incr-unchanged -1.17% 5.86x
num-derive-0.3.3 check incr-full -1.09% 5.47x
mockall_derive-0.11.0 check full -1.00% 5.00x
mockall_derive-0.11.0 check incr-full -0.88% 4.39x
futures-macro-0.3.19 check full -0.71% 3.57x
futures-macro-0.3.19 check incr-full -0.61% 3.06x

I'll open a PR shortly.

Repository owner locked and limited conversation to collaborators Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants