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

Optimize runtime of #[cargo_test_macro] #7146

Merged
merged 1 commit into from
Jul 19, 2019

Conversation

alexcrichton
Copy link
Member

I've noticed recently that the incremental compile time for our test
suite has felt like it's increased quite a bit. I think one reason is
that everything has to go through #[cargo_test_macro] unconditionally
on all incremental builds, and wow do we have a lot of tests being
pumped through that macro.

Instrumenting the macro a little bit shows that we spend nearly 2.5
seconds on each compilation simply executing this macro (note that it's
in debug mode as well, not release since we typically don't execute
tests in release mode.

This commit instead drops the usage of syn and quote in favor of a
"raw procedural macro" which is much more optimized for just our use
case, even in debug mode. This drops the collective time spent in the
macro to 0.2 seconds, even in debug mode!

@rust-highfive
Copy link

r? @Eh2406

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 18, 2019
@Eh2406
Copy link
Contributor

Eh2406 commented Jul 18, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Jul 18, 2019

📌 Commit 31ada89fe139b42c3060a564697b0b8f41d29706 has been approved by Eh2406

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2019
@bors
Copy link
Contributor

bors commented Jul 18, 2019

⌛ Testing commit 31ada89fe139b42c3060a564697b0b8f41d29706 with merge d0cec6306b395fc23e5f2cd2a414657354a1bcf2...

@bors
Copy link
Contributor

bors commented Jul 18, 2019

💔 Test failed - checks-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 18, 2019
@Eh2406
Copy link
Contributor

Eh2406 commented Jul 18, 2019

fmt needed :-(

@alexcrichton
Copy link
Member Author

@bors: r=Eh2406

@bors
Copy link
Contributor

bors commented Jul 18, 2019

📌 Commit b5b92e0df2b895788a3136313aa40b4f127290f1 has been approved by Eh2406

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2019
@bors
Copy link
Contributor

bors commented Jul 18, 2019

⌛ Testing commit b5b92e0df2b895788a3136313aa40b4f127290f1 with merge bcaba3bff8d9b240fe711190a3c1c4cadb2695e3...

@alexcrichton alexcrichton force-pushed the faster-proc-macro branch 2 times, most recently from 0c1face to 4deaad1 Compare July 18, 2019 15:50
tests/testsuite/config.rs Outdated Show resolved Hide resolved
@alexcrichton
Copy link
Member Author

@bors: r-

@bors bors added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 19, 2019
I've noticed recently that the incremental compile time for our test
suite has felt like it's increased quite a bit. I think one reason is
that everything has to go through `#[cargo_test_macro]` unconditionally
on all incremental builds, and wow do we have a lot of tests being
pumped through that macro.

Instrumenting the macro a little bit shows that we spend nearly 2.5
seconds on each compilation simply executing this macro (note that it's
in debug mode as well, not release since we typically don't execute
tests in release mode.

This commit instead drops the usage of `syn` and `quote` in favor of a
"raw procedural macro" which is much more optimized for just our use
case, even in debug mode. This drops the collective time spent in the
macro to 0.2 seconds, even in debug mode!
@alexcrichton
Copy link
Member Author

@bors: r=Eh2406

@bors
Copy link
Contributor

bors commented Jul 19, 2019

📌 Commit 8887b67 has been approved by Eh2406

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Jul 19, 2019
@bors
Copy link
Contributor

bors commented Jul 19, 2019

⌛ Testing commit 8887b67 with merge 56fca89...

bors added a commit that referenced this pull request Jul 19, 2019
Optimize runtime of `#[cargo_test_macro]`

I've noticed recently that the incremental compile time for our test
suite has felt like it's increased quite a bit. I think one reason is
that everything has to go through `#[cargo_test_macro]` unconditionally
on all incremental builds, and wow do we have a lot of tests being
pumped through that macro.

Instrumenting the macro a little bit shows that we spend nearly 2.5
seconds on each compilation simply executing this macro (note that it's
in debug mode as well, not release since we typically don't execute
tests in release mode.

This commit instead drops the usage of `syn` and `quote` in favor of a
"raw procedural macro" which is much more optimized for just our use
case, even in debug mode. This drops the collective time spent in the
macro to 0.2 seconds, even in debug mode!
@bors
Copy link
Contributor

bors commented Jul 19, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: Eh2406
Pushing 56fca89 to master...

@bors bors merged commit 8887b67 into rust-lang:master Jul 19, 2019
@alexcrichton alexcrichton deleted the faster-proc-macro branch July 19, 2019 18:49
bors added a commit to rust-lang/rust that referenced this pull request Jul 26, 2019
Update cargo

11 commits in e3563dbdcd2e370bc4f11d080f739d82d25773fd..d0f828419d6ce6be21a90866964f58eb2c07cd56
2019-07-16 19:22:44 +0000 to 2019-07-23 21:58:59 +0000
- Remove include/exclude glob warning. (rust-lang/cargo#7170)
- Optimize lock file format for git merge conflicts (rust-lang/cargo#7070)
- Set up CI with Azure Pipelines (rust-lang/cargo#7139)
- Force clippy to run. (rust-lang/cargo#7157)
- Work around #61440 (rust-lang/cargo#7158)
- initial working version of cargo fix --clippy (rust-lang/cargo#7069)
- Optimize runtime of `#[cargo_test_macro]` (rust-lang/cargo#7146)
- Don't fail if we can't acquire readonly lock (rust-lang/cargo#7149)
- Add support for multiple --features options (rust-lang/cargo#7084)
- Fix a typo in an env var name (rust-lang/cargo#7145)
- Add a way to disable all nightly tests (rust-lang/cargo#7142)
@ehuss ehuss added this to the 1.38.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants