mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Remove periodic gc stub
This commit is contained in:
parent
7283783b98
commit
e7df0ad2fb
6 changed files with 13 additions and 64 deletions
|
@ -144,10 +144,6 @@ impl AnalysisHost {
|
|||
self.db.apply_change(change)
|
||||
}
|
||||
|
||||
pub fn maybe_collect_garbage(&mut self) {
|
||||
self.db.maybe_collect_garbage();
|
||||
}
|
||||
|
||||
pub fn collect_garbage(&mut self) {
|
||||
self.db.collect_garbage();
|
||||
}
|
||||
|
|
|
@ -37,13 +37,12 @@ pub(crate) fn status(db: &RootDatabase) -> String {
|
|||
let macro_syntax_tree_stats = macro_syntax_tree_stats(db);
|
||||
let symbols_stats = LibrarySymbolsQuery.in_db(db).entries::<LibrarySymbolsStats>();
|
||||
format!(
|
||||
"{}\n{}\n{}\n{} (macros)\n\n\nmemory:\n{}\ngc {:?} seconds ago",
|
||||
"{}\n{}\n{}\n{} (macros)\n{} total\n",
|
||||
files_stats,
|
||||
symbols_stats,
|
||||
syntax_tree_stats,
|
||||
macro_syntax_tree_stats,
|
||||
memory_usage(),
|
||||
db.last_gc.elapsed().as_secs(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,7 @@ struct LibrarySymbolsStats {
|
|||
|
||||
impl fmt::Display for LibrarySymbolsStats {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{} ({}) symbols", self.total, self.size)
|
||||
write!(fmt, "{} ({}) index symbols", self.total, self.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Defines a unit of change that can applied to a state of IDE to get the next
|
||||
//! state. Changes are transactional.
|
||||
|
||||
use std::{fmt, sync::Arc, time};
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
use base_db::{
|
||||
salsa::{Database, Durability, SweepStrategy},
|
||||
|
@ -81,8 +81,6 @@ impl fmt::Debug for RootChange {
|
|||
}
|
||||
}
|
||||
|
||||
const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
|
||||
|
||||
impl RootDatabase {
|
||||
pub fn request_cancellation(&mut self) {
|
||||
let _p = profile::span("RootDatabase::request_cancellation");
|
||||
|
@ -126,23 +124,12 @@ impl RootDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn maybe_collect_garbage(&mut self) {
|
||||
if cfg!(feature = "wasm") {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.last_gc_check.elapsed() > GC_COOLDOWN {
|
||||
self.last_gc_check = crate::wasm_shims::Instant::now();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn collect_garbage(&mut self) {
|
||||
if cfg!(feature = "wasm") {
|
||||
return;
|
||||
}
|
||||
|
||||
let _p = profile::span("RootDatabase::collect_garbage");
|
||||
self.last_gc = crate::wasm_shims::Instant::now();
|
||||
|
||||
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ pub mod defs;
|
|||
pub mod search;
|
||||
pub mod imports_locator;
|
||||
pub mod source_change;
|
||||
mod wasm_shims;
|
||||
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
|
@ -36,8 +35,6 @@ use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase};
|
|||
)]
|
||||
pub struct RootDatabase {
|
||||
storage: salsa::Storage<RootDatabase>,
|
||||
pub last_gc: crate::wasm_shims::Instant,
|
||||
pub last_gc_check: crate::wasm_shims::Instant,
|
||||
}
|
||||
|
||||
impl fmt::Debug for RootDatabase {
|
||||
|
@ -99,11 +96,7 @@ impl Default for RootDatabase {
|
|||
|
||||
impl RootDatabase {
|
||||
pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
|
||||
let mut db = RootDatabase {
|
||||
storage: salsa::Storage::default(),
|
||||
last_gc: crate::wasm_shims::Instant::now(),
|
||||
last_gc_check: crate::wasm_shims::Instant::now(),
|
||||
};
|
||||
let mut db = RootDatabase { storage: salsa::Storage::default() };
|
||||
db.set_crate_graph_with_durability(Default::default(), Durability::HIGH);
|
||||
db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
|
||||
db.set_library_roots_with_durability(Default::default(), Durability::HIGH);
|
||||
|
@ -121,11 +114,7 @@ impl RootDatabase {
|
|||
|
||||
impl salsa::ParallelDatabase for RootDatabase {
|
||||
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
|
||||
salsa::Snapshot::new(RootDatabase {
|
||||
storage: self.storage.snapshot(),
|
||||
last_gc: self.last_gc,
|
||||
last_gc_check: self.last_gc_check,
|
||||
})
|
||||
salsa::Snapshot::new(RootDatabase { storage: self.storage.snapshot() })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//! A version of `std::time::Instant` that doesn't panic in WASM.
|
||||
|
||||
#[cfg(not(feature = "wasm"))]
|
||||
pub use std::time::Instant;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Instant;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
impl Instant {
|
||||
pub fn now() -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
pub fn elapsed(&self) -> std::time::Duration {
|
||||
std::time::Duration::new(0, 0)
|
||||
}
|
||||
}
|
|
@ -189,8 +189,7 @@ impl GlobalState {
|
|||
}
|
||||
lsp_server::Message::Response(resp) => self.complete_request(resp),
|
||||
},
|
||||
Event::Task(task) => {
|
||||
match task {
|
||||
Event::Task(task) => match task {
|
||||
Task::Response(response) => self.respond(response),
|
||||
Task::Diagnostics(diagnostics_per_file) => {
|
||||
for (file_id, diagnostics) in diagnostics_per_file {
|
||||
|
@ -199,9 +198,7 @@ impl GlobalState {
|
|||
}
|
||||
Task::Workspaces(workspaces) => self.switch_workspaces(workspaces),
|
||||
Task::Unit => (),
|
||||
}
|
||||
self.analysis_host.maybe_collect_garbage();
|
||||
}
|
||||
},
|
||||
Event::Vfs(mut task) => {
|
||||
let _p = profile::span("GlobalState::handle_event/vfs");
|
||||
loop {
|
||||
|
|
Loading…
Reference in a new issue