diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-09-29 20:23:15 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-29 20:23:15 +0100 |
commit | 80b0b0ea03a36451210c6f1beec66aa1150f194f (patch) | |
tree | c5a634e9836978c0fbb679c2529eea518add1196 /crates/ide_db/src | |
parent | 7283783b98ed61ee4f94961b81ad06e2344098d2 (diff) | |
parent | e7df0ad2fb48166937fdd061e1ae559c72a81990 (diff) |
Merge #6095
6095: Remove periodic gc stub r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide_db/src')
-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 |
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 | ||
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 | } | ||