Skip to content

Load procedural macros asynchronously #8646

@matklad

Description

@matklad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionC-featureCategory: feature requestE-hardS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions