rust/compiler/rustc_interface/src
Piotr Osiewicz 42e71bb8ea rustc_metadata: Preprocess search paths for better performance
Over in Zed we've noticed that loading crates for a large-ish workspace can take almost 200ms. We've pinned it down to how rustc searches for paths, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded.

This commit introduces a simple FilesIndex that's just a sorted Vec under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said Vec (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes.
FilesIndex is also pre-filtered before any queries are performed using available target information; query prefixes/sufixes are based on the target we are compiling for, so we can remove entries that can never match up front.

Overall, this commit brings down build time for us in dev scenarios by about 6%.
100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-15 10:35:33 +01:00
..
callbacks.rs Do not call source_span when not tracking dependencies. 2024-08-24 16:40:40 +00:00
errors.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
interface.rs add unstable support for outputting file checksums for use in cargo 2024-10-01 21:23:20 -06:00
lib.rs add unstable support for outputting file checksums for use in cargo 2024-10-01 21:23:20 -06:00
passes.rs rustc_metadata: Preprocess search paths for better performance 2024-11-15 10:35:33 +01:00
proc_macro_decls.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
queries.rs fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
tests.rs Use a method to apply RustcOptGroup to getopts::Options 2024-11-08 12:46:39 +11:00
util.rs Auto merge of #132282 - Noratrieb:it-is-the-end-of-serial, r=cjgillot 2024-11-12 15:14:56 +00:00