aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-09-29 20:13:58 +0100
committerAleksey Kladov <[email protected]>2020-09-29 20:22:48 +0100
commite7df0ad2fb48166937fdd061e1ae559c72a81990 (patch)
treec5a634e9836978c0fbb679c2529eea518add1196 /crates/ide_db
parent7283783b98ed61ee4f94961b81ad06e2344098d2 (diff)
Remove periodic gc stub
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/change.rs15
-rw-r--r--crates/ide_db/src/lib.rs15
-rw-r--r--crates/ide_db/src/wasm_shims.rs19
3 files changed, 3 insertions, 46 deletions
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
4use std::{fmt, sync::Arc, time}; 4use std::{fmt, sync::Arc};
5 5
6use base_db::{ 6use 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
84const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
85
86impl RootDatabase { 84impl 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;
10pub mod search; 10pub mod search;
11pub mod imports_locator; 11pub mod imports_locator;
12pub mod source_change; 12pub mod source_change;
13mod wasm_shims;
14 13
15use std::{fmt, sync::Arc}; 14use std::{fmt, sync::Arc};
16 15
@@ -36,8 +35,6 @@ use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase};
36)] 35)]
37pub struct RootDatabase { 36pub 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
43impl fmt::Debug for RootDatabase { 40impl fmt::Debug for RootDatabase {
@@ -99,11 +96,7 @@ impl Default for RootDatabase {
99 96
100impl RootDatabase { 97impl 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
122impl salsa::ParallelDatabase for RootDatabase { 115impl 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"))]
4pub use std::time::Instant;
5
6#[cfg(feature = "wasm")]
7#[derive(Clone, Copy, Debug)]
8pub struct Instant;
9
10#[cfg(feature = "wasm")]
11impl 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}