diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/status.rs | 5 | ||||
-rw-r--r-- | crates/ide_db/src/change.rs | 15 | ||||
-rw-r--r-- | crates/ide_db/src/lib.rs | 15 | ||||
-rw-r--r-- | crates/ide_db/src/wasm_shims.rs | 19 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 19 |
6 files changed, 13 insertions, 64 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 31f2bcba3..96dae9ee0 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -144,10 +144,6 @@ impl AnalysisHost { | |||
144 | self.db.apply_change(change) | 144 | self.db.apply_change(change) |
145 | } | 145 | } |
146 | 146 | ||
147 | pub fn maybe_collect_garbage(&mut self) { | ||
148 | self.db.maybe_collect_garbage(); | ||
149 | } | ||
150 | |||
151 | pub fn collect_garbage(&mut self) { | 147 | pub fn collect_garbage(&mut self) { |
152 | self.db.collect_garbage(); | 148 | self.db.collect_garbage(); |
153 | } | 149 | } |
diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs index c23708181..1427c50cf 100644 --- a/crates/ide/src/status.rs +++ b/crates/ide/src/status.rs | |||
@@ -37,13 +37,12 @@ pub(crate) fn status(db: &RootDatabase) -> String { | |||
37 | let macro_syntax_tree_stats = macro_syntax_tree_stats(db); | 37 | let macro_syntax_tree_stats = macro_syntax_tree_stats(db); |
38 | let symbols_stats = LibrarySymbolsQuery.in_db(db).entries::<LibrarySymbolsStats>(); | 38 | let symbols_stats = LibrarySymbolsQuery.in_db(db).entries::<LibrarySymbolsStats>(); |
39 | format!( | 39 | format!( |
40 | "{}\n{}\n{}\n{} (macros)\n\n\nmemory:\n{}\ngc {:?} seconds ago", | 40 | "{}\n{}\n{}\n{} (macros)\n{} total\n", |
41 | files_stats, | 41 | files_stats, |
42 | symbols_stats, | 42 | symbols_stats, |
43 | syntax_tree_stats, | 43 | syntax_tree_stats, |
44 | macro_syntax_tree_stats, | 44 | macro_syntax_tree_stats, |
45 | memory_usage(), | 45 | memory_usage(), |
46 | db.last_gc.elapsed().as_secs(), | ||
47 | ) | 46 | ) |
48 | } | 47 | } |
49 | 48 | ||
@@ -121,7 +120,7 @@ struct LibrarySymbolsStats { | |||
121 | 120 | ||
122 | impl fmt::Display for LibrarySymbolsStats { | 121 | impl fmt::Display for LibrarySymbolsStats { |
123 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | 122 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
124 | write!(fmt, "{} ({}) symbols", self.total, self.size) | 123 | write!(fmt, "{} ({}) index symbols", self.total, self.size) |
125 | } | 124 | } |
126 | } | 125 | } |
127 | 126 | ||
diff --git a/crates/ide_db/src/change.rs b/crates/ide_db/src/change.rs index 8b4fd7ab8..7f98111c4 100644 --- a/crates/ide_db/src/change.rs +++ b/crates/ide_db/src/change.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Defines a unit of change that can applied to a state of IDE to get the next | 1 | //! Defines a unit of change that can applied to a state of IDE to get the next |
2 | //! state. Changes are transactional. | 2 | //! state. Changes are transactional. |
3 | 3 | ||
4 | use std::{fmt, sync::Arc, time}; | 4 | use std::{fmt, sync::Arc}; |
5 | 5 | ||
6 | use base_db::{ | 6 | use base_db::{ |
7 | salsa::{Database, Durability, SweepStrategy}, | 7 | salsa::{Database, Durability, SweepStrategy}, |
@@ -81,8 +81,6 @@ impl fmt::Debug for RootChange { | |||
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); | ||
85 | |||
86 | impl RootDatabase { | 84 | impl RootDatabase { |
87 | pub fn request_cancellation(&mut self) { | 85 | pub fn request_cancellation(&mut self) { |
88 | let _p = profile::span("RootDatabase::request_cancellation"); | 86 | let _p = profile::span("RootDatabase::request_cancellation"); |
@@ -126,23 +124,12 @@ impl RootDatabase { | |||
126 | } | 124 | } |
127 | } | 125 | } |
128 | 126 | ||
129 | pub fn maybe_collect_garbage(&mut self) { | ||
130 | if cfg!(feature = "wasm") { | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | if self.last_gc_check.elapsed() > GC_COOLDOWN { | ||
135 | self.last_gc_check = crate::wasm_shims::Instant::now(); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | pub fn collect_garbage(&mut self) { | 127 | pub fn collect_garbage(&mut self) { |
140 | if cfg!(feature = "wasm") { | 128 | if cfg!(feature = "wasm") { |
141 | return; | 129 | return; |
142 | } | 130 | } |
143 | 131 | ||
144 | let _p = profile::span("RootDatabase::collect_garbage"); | 132 | let _p = profile::span("RootDatabase::collect_garbage"); |
145 | self.last_gc = crate::wasm_shims::Instant::now(); | ||
146 | 133 | ||
147 | let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); | 134 | let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); |
148 | 135 | ||
diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs index 70ada02f3..0d209c6ec 100644 --- a/crates/ide_db/src/lib.rs +++ b/crates/ide_db/src/lib.rs | |||
@@ -10,7 +10,6 @@ pub mod defs; | |||
10 | pub mod search; | 10 | pub mod search; |
11 | pub mod imports_locator; | 11 | pub mod imports_locator; |
12 | pub mod source_change; | 12 | pub mod source_change; |
13 | mod wasm_shims; | ||
14 | 13 | ||
15 | use std::{fmt, sync::Arc}; | 14 | use std::{fmt, sync::Arc}; |
16 | 15 | ||
@@ -36,8 +35,6 @@ use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase}; | |||
36 | )] | 35 | )] |
37 | pub struct RootDatabase { | 36 | pub struct RootDatabase { |
38 | storage: salsa::Storage<RootDatabase>, | 37 | storage: salsa::Storage<RootDatabase>, |
39 | pub last_gc: crate::wasm_shims::Instant, | ||
40 | pub last_gc_check: crate::wasm_shims::Instant, | ||
41 | } | 38 | } |
42 | 39 | ||
43 | impl fmt::Debug for RootDatabase { | 40 | impl fmt::Debug for RootDatabase { |
@@ -99,11 +96,7 @@ impl Default for RootDatabase { | |||
99 | 96 | ||
100 | impl RootDatabase { | 97 | impl RootDatabase { |
101 | pub fn new(lru_capacity: Option<usize>) -> RootDatabase { | 98 | pub fn new(lru_capacity: Option<usize>) -> RootDatabase { |
102 | let mut db = RootDatabase { | 99 | let mut db = RootDatabase { storage: salsa::Storage::default() }; |
103 | storage: salsa::Storage::default(), | ||
104 | last_gc: crate::wasm_shims::Instant::now(), | ||
105 | last_gc_check: crate::wasm_shims::Instant::now(), | ||
106 | }; | ||
107 | db.set_crate_graph_with_durability(Default::default(), Durability::HIGH); | 100 | db.set_crate_graph_with_durability(Default::default(), Durability::HIGH); |
108 | db.set_local_roots_with_durability(Default::default(), Durability::HIGH); | 101 | db.set_local_roots_with_durability(Default::default(), Durability::HIGH); |
109 | db.set_library_roots_with_durability(Default::default(), Durability::HIGH); | 102 | db.set_library_roots_with_durability(Default::default(), Durability::HIGH); |
@@ -121,11 +114,7 @@ impl RootDatabase { | |||
121 | 114 | ||
122 | impl salsa::ParallelDatabase for RootDatabase { | 115 | impl salsa::ParallelDatabase for RootDatabase { |
123 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { | 116 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { |
124 | salsa::Snapshot::new(RootDatabase { | 117 | salsa::Snapshot::new(RootDatabase { storage: self.storage.snapshot() }) |
125 | storage: self.storage.snapshot(), | ||
126 | last_gc: self.last_gc, | ||
127 | last_gc_check: self.last_gc_check, | ||
128 | }) | ||
129 | } | 118 | } |
130 | } | 119 | } |
131 | 120 | ||
diff --git a/crates/ide_db/src/wasm_shims.rs b/crates/ide_db/src/wasm_shims.rs deleted file mode 100644 index 7af9f9d9b..000000000 --- a/crates/ide_db/src/wasm_shims.rs +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | //! A version of `std::time::Instant` that doesn't panic in WASM. | ||
2 | |||
3 | #[cfg(not(feature = "wasm"))] | ||
4 | pub use std::time::Instant; | ||
5 | |||
6 | #[cfg(feature = "wasm")] | ||
7 | #[derive(Clone, Copy, Debug)] | ||
8 | pub struct Instant; | ||
9 | |||
10 | #[cfg(feature = "wasm")] | ||
11 | impl Instant { | ||
12 | pub fn now() -> Self { | ||
13 | Self | ||
14 | } | ||
15 | |||
16 | pub fn elapsed(&self) -> std::time::Duration { | ||
17 | std::time::Duration::new(0, 0) | ||
18 | } | ||
19 | } | ||
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 06ab9d508..c2d0ac791 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -189,19 +189,16 @@ impl GlobalState { | |||
189 | } | 189 | } |
190 | lsp_server::Message::Response(resp) => self.complete_request(resp), | 190 | lsp_server::Message::Response(resp) => self.complete_request(resp), |
191 | }, | 191 | }, |
192 | Event::Task(task) => { | 192 | Event::Task(task) => match task { |
193 | match task { | 193 | Task::Response(response) => self.respond(response), |
194 | Task::Response(response) => self.respond(response), | 194 | Task::Diagnostics(diagnostics_per_file) => { |
195 | Task::Diagnostics(diagnostics_per_file) => { | 195 | for (file_id, diagnostics) in diagnostics_per_file { |
196 | for (file_id, diagnostics) in diagnostics_per_file { | 196 | self.diagnostics.set_native_diagnostics(file_id, diagnostics) |
197 | self.diagnostics.set_native_diagnostics(file_id, diagnostics) | ||
198 | } | ||
199 | } | 197 | } |
200 | Task::Workspaces(workspaces) => self.switch_workspaces(workspaces), | ||
201 | Task::Unit => (), | ||
202 | } | 198 | } |
203 | self.analysis_host.maybe_collect_garbage(); | 199 | Task::Workspaces(workspaces) => self.switch_workspaces(workspaces), |
204 | } | 200 | Task::Unit => (), |
201 | }, | ||
205 | Event::Vfs(mut task) => { | 202 | Event::Vfs(mut task) => { |
206 | let _p = profile::span("GlobalState::handle_event/vfs"); | 203 | let _p = profile::span("GlobalState::handle_event/vfs"); |
207 | loop { | 204 | loop { |