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

Large number of #[async_trait] implementations greatly increases compile time #174

Closed
patrickfreed opened this issue Jul 30, 2021 · 1 comment

Comments

@patrickfreed
Copy link

In the test suite for the mongodb crate, we included a large number of #[async_trait] implementations, and this lead to roughly 1 minute of compile type for any incremental change to the tests (via cargo check --tests). Using -Zself-profile, it was determined that nearly all of this time was spent in evaluate_obligation. After converting all of the #[async_trait]s and their implementations to vanilla traits that returned BoxFuture manually, the evaluate_obligation portion of the compilation time was almost completely eliminated.

For more context, see rust-lang/rust#87012 (comment).

I'm not sure if this is a bug in the implementation of async_trait or simply a limitation of doing macro-based traits, but I figured it was worth reporting here. Let me know if there's any more useful information I can provide.

@dtolnay
Copy link
Owner

dtolnay commented Jul 30, 2021

https://users.rust-lang.org/t/extremely-slow-compile-times-in-test-suite/61842/2 is the right diagnosis. Something is accidentally quadratic in rustc when this kind of thing happens. If evaluate_obligation is taking nontrivial time that's a rustc bug so rust-lang/rust#87012 is the appropriate place to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants