Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22494 from Veykril/push-ozktuvyllzpx
minor: Fix garbage collection running too frequently
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index a9ce6f728b..5ed522ceee 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -478,6 +478,7 @@ impl GlobalState { (false, false) }; + let mut gc_elapsed = None; if self.is_quiescent() { let became_quiescent = !was_quiescent; if became_quiescent { @@ -541,8 +542,10 @@ impl GlobalState { && self.fmt_pool.handle.is_empty() && current_revision != self.last_gc_revision { + let gc_start = Instant::now(); self.analysis_host.trigger_garbage_collection(); - self.last_gc_revision = current_revision; + self.last_gc_revision = self.analysis_host.raw_database().nonce_and_revision().1; + gc_elapsed = Some(gc_start.elapsed()); } } @@ -588,10 +591,14 @@ impl GlobalState { let loop_duration = loop_start.elapsed(); if loop_duration > Duration::from_millis(100) && was_quiescent { tracing::warn!( - "overly long loop turn took {loop_duration:?} (event handling took {event_handling_duration:?}): {event_dbg_msg}" + "overly long loop turn took {loop_duration:?}:\n\ + (event handling took {event_handling_duration:?}): {event_dbg_msg}\n\ + (garbage collection took {gc_elapsed:?})" ); self.poke_rust_analyzer_developer(format!( - "overly long loop turn took {loop_duration:?} (event handling took {event_handling_duration:?}): {event_dbg_msg}" + "overly long loop turn took {loop_duration:?}:\n\ + (event handling took {event_handling_duration:?}): {event_dbg_msg}\n\ + (garbage collection took {gc_elapsed:?})" )); } } |