From e09b9b623e321f72e64b6ba3de6708ff519f524f Mon Sep 17 00:00:00 2001 From: davidcforbes Date: Mon, 8 Jun 2026 12:58:18 -0700 Subject: [PATCH] rust-analyzer: lightweight profile (disable cachePriming + cargo.autoreload) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit serena's symbol tools (find_symbol, find_referencing_symbols, …) only need the symbol index, but the LSP is launched with VS Code's full heavyweight defaults. On a large, actively-built Rust workspace these drove rust-analyzer to 40+ GB RSS and triggered a full re-index on every external `cargo build` (target/ churn). Disabling the two eager/auto re-indexing drivers keeps symbol navigation working at a fraction of the memory: - cachePriming.enable: True -> False (no eager whole-workspace+deps index) - cargo.autoreload: True -> False (no re-index storm on target/ changes) checkOnSave is intentionally LEFT enabled: serena's get_diagnostics_for_file relies on flycheck (`cargo check`) for Rust diagnostics, and disabling it makes that tool return empty (test/solidlsp/rust/test_rust_diagnostics.py fails with []). checkOnSave only spawns transient `cargo check` child processes and is not a driver of rust-analyzer's resident RSS, so keeping it on preserves diagnostics at no meaningful memory cost. Observed on a rustback (multi-crate + rustic_core fork) workspace: repeated 40-44 GB rust-analyzer processes under serena with no VS Code present. Suggest upstream expose a "lightweight"/symbol-only RA profile or a config toggle. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/solidlsp/language_servers/rust_analyzer.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/solidlsp/language_servers/rust_analyzer.py b/src/solidlsp/language_servers/rust_analyzer.py index 2e222b5a85..83e3de8ffd 100644 --- a/src/solidlsp/language_servers/rust_analyzer.py +++ b/src/solidlsp/language_servers/rust_analyzer.py @@ -505,9 +505,19 @@ def _get_initialize_params(repository_absolute_path: str) -> InitializeParams: "showUnlinkedFileNotification": True, "showDependenciesExplorer": True, "assist": {"emitMustUse": False, "expressionFillDefault": "todo"}, - "cachePriming": {"enable": True, "numThreads": 0}, + # rustback lightweight patch: serena's symbol tools don't need + # rust-analyzer's eager whole-workspace+deps cache priming, nor a + # re-index on every cargo metadata / target/ change. On large, + # actively-built Rust workspaces these drove rust-analyzer to + # 40+ GB RSS and re-indexed on every external `cargo build`. + # Disabling them keeps symbol navigation working at a fraction of + # the memory. NOTE: checkOnSave is intentionally left enabled below + # because serena's get_diagnostics_for_file relies on flycheck + # (`cargo check`) for Rust diagnostics. (Upstream: expose these as + # a config knob / a "lightweight" RA profile.) + "cachePriming": {"enable": False, "numThreads": 0}, "cargo": { - "autoreload": True, + "autoreload": False, "buildScripts": { "enable": True, "invocationLocation": "workspace",