-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-perfperformance issuesperformance issuesBroken WindowBugs / technical debt to be addressed immediatelyBugs / technical debt to be addressed immediatelyC-bugCategory: bugCategory: bug
Description
It's incredible that we aren't actually doing this already. When we load a project that contains multiple workspaces we do not deduplicate equal crates in the crategraph! That means just for the sysroot alone that it is loaded multiple times into memory and queries executed on the sysroot of one workspace are not reused for another. It wouldn't surprise me if some of the high memory usage reports we get comes from projects that have a lot of cargo workspaces in them.
Here all we do is append crates, but we are not deduplicating them. Nor are we doing so after having built the final crategraph.
rust-analyzer/crates/base-db/src/input.rs
Lines 495 to 515 in 2365762
/// Extends this crate graph by adding a complete disjoint second crate | |
/// graph and adjust the ids in the [`ProcMacroPaths`] accordingly. | |
/// | |
/// The ids of the crates in the `other` graph are shifted by the return | |
/// amount. | |
pub fn extend(&mut self, other: CrateGraph, proc_macros: &mut ProcMacroPaths) -> u32 { | |
let start = self.arena.len() as u32; | |
self.arena.extend(other.arena.into_iter().map(|(id, mut data)| { | |
let new_id = id.shift(start); | |
for dep in &mut data.dependencies { | |
dep.crate_id = dep.crate_id.shift(start); | |
} | |
(new_id, data) | |
})); | |
*proc_macros = mem::take(proc_macros) | |
.into_iter() | |
.map(|(id, macros)| (id.shift(start), macros)) | |
.collect(); | |
start | |
} |
jhgglnicolaenkoder
Metadata
Metadata
Assignees
Labels
A-perfperformance issuesperformance issuesBroken WindowBugs / technical debt to be addressed immediatelyBugs / technical debt to be addressed immediatelyC-bugCategory: bugCategory: bug