Skip to content

Commit c94e9ef

Browse files
Salsify the crate graph
I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
1 parent 44f18c3 commit c94e9ef

File tree

108 files changed

+3629
-2511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3629
-2511
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/base-db/src/change.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33
44
use std::fmt;
55

6-
use rustc_hash::FxHashMap;
76
use salsa::Durability;
87
use triomphe::Arc;
98
use vfs::FileId;
109

11-
use crate::{CrateGraph, CrateId, CrateWorkspaceData, RootQueryDb, SourceRoot, SourceRootId};
10+
use crate::{CrateGraphBuilder, CratesIdMap, RootQueryDb, SourceRoot, SourceRootId};
1211

1312
/// Encapsulate a bunch of raw `.set` calls on the database.
1413
#[derive(Default)]
1514
pub struct FileChange {
1615
pub roots: Option<Vec<SourceRoot>>,
1716
pub files_changed: Vec<(FileId, Option<String>)>,
18-
pub crate_graph: Option<CrateGraph>,
19-
pub ws_data: Option<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>,
17+
pub crate_graph: Option<CrateGraphBuilder>,
2018
}
2119

2220
impl fmt::Debug for FileChange {
@@ -48,15 +46,11 @@ impl FileChange {
4846
self.files_changed.push((file_id, new_text))
4947
}
5048

51-
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
49+
pub fn set_crate_graph(&mut self, graph: CrateGraphBuilder) {
5250
self.crate_graph = Some(graph);
5351
}
5452

55-
pub fn set_ws_data(&mut self, data: FxHashMap<CrateId, Arc<CrateWorkspaceData>>) {
56-
self.ws_data = Some(data);
57-
}
58-
59-
pub fn apply(self, db: &mut dyn RootQueryDb) {
53+
pub fn apply(self, db: &mut dyn RootQueryDb) -> Option<CratesIdMap> {
6054
let _p = tracing::info_span!("FileChange::apply").entered();
6155
if let Some(roots) = self.roots {
6256
for (idx, root) in roots.into_iter().enumerate() {
@@ -79,12 +73,11 @@ impl FileChange {
7973
let text = text.unwrap_or_default();
8074
db.set_file_text_with_durability(file_id, &text, durability)
8175
}
76+
8277
if let Some(crate_graph) = self.crate_graph {
83-
db.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH);
84-
}
85-
if let Some(data) = self.ws_data {
86-
db.set_crate_workspace_data_with_durability(Arc::new(data), Durability::HIGH);
78+
return Some(crate_graph.set_in_db(db));
8779
}
80+
None
8881
}
8982
}
9083

0 commit comments

Comments
 (0)