Skip to content

Load procedural macros asynchronously #8646

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

Closed
matklad opened this issue Apr 24, 2021 · 0 comments · Fixed by #14405
Closed

Load procedural macros asynchronously #8646

matklad opened this issue Apr 24, 2021 · 0 comments · Fixed by #14405
Labels
A-macro macro expansion C-feature Category: feature request E-hard S-actionable Someone could pick this issue up and work on it right now

Comments

@matklad
Copy link
Member

matklad commented Apr 24, 2021

Investigation in #8623 showed that switching the crate graph is slow, and procedural macro loading is a significant contributor. In particular,

https://github.com/matklad/rust-analyzer/blob/8d54fd105cbeb159c39fbc803ed45d450f0fe000/crates/proc_macro_api/src/lib.rs#L79-L82

is called on the main loop for each proc macro, and it's slow, because it reads proc-macro file to get a version, and then waits for the proc-macro server process to dlopen the file and report back.

We should move all this work off the main loop.

Plan:

  • split proc-macros out of crate graph and into a separate salsa query. This is useful in general for "reload proc macros" functionality.
  • make to_crate_graph return a crate graph and proc macros separately
  • switch to the new salsa representation, while keeping the current synchronous loading
  • (the tricky bit) add the main_loop Task to handle loading of proc macros asynchronously
@matklad matklad added E-hard A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Apr 24, 2021
@flodiebold flodiebold added the C-feature Category: feature request label Jun 28, 2022
bors added a commit that referenced this issue Mar 25, 2023
internal: Split out proc-macros from the CrateGraph

cc #8646
bors added a commit that referenced this issue Mar 25, 2023
feat: Load proc-macros asynchronously

Closes #8646
@bors bors closed this as completed in 90340b7 Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-feature Category: feature request E-hard S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants