From 00f9d1cdee372c48b48b1d237dcdb75f65d7f46d Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Thu, 26 Feb 2026 19:08:08 -0800 Subject: fix: Dramatically decrease daemon memory usage (#3211) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduces memory usage of the atuin-daemon search index by ~80% through string interning, compact UUID storage, and eliminating redundant data. ## Changes * **Eliminate Vec\**: Replaced the per-command `Vec` with just `most_recent_id: [u8; 16]` and `most_recent_timestamp: i64`. We only ever needed the most recent history ID for search results - the full invocation history was never used. * **UUID byte storage**: Store UUIDs as `[u8; 16]` instead of 36-byte strings, saving 40 bytes per UUID. * **String interning with lasso**: Use `ThreadedRodeo` to deduplicate `cwd` and `hostname` strings in the filter sets. These values are highly repetitive (most commands run from a small set of directories on the same host), so interning has an outsized effect. * **DashSet → HashSet**: Since `CommandData` lives inside a `DashMap` (already synchronized), the inner sets don't need their own locks. Switched to `HashSet` for directories/hosts and `HashSet<[u8; 16]>` for sessions. * **Arc\ for commands**: Changed the `commands` DashMap key and `frecency_map` keys from `String` to `Arc`, enabling zero-copy sharing between the two maps. * **Remove dead code**: Removed `CommandData.command` field that was duplicating the DashMap key. ## Results With 60k history entries, observed memory usage dropped from ~200MB to ~40MB. --- crates/atuin-daemon/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/atuin-daemon/Cargo.toml') diff --git a/crates/atuin-daemon/Cargo.toml b/crates/atuin-daemon/Cargo.toml index 816d5961..90f875d5 100644 --- a/crates/atuin-daemon/Cargo.toml +++ b/crates/atuin-daemon/Cargo.toml @@ -28,6 +28,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true } dashmap = "5.5.3" +lasso = { version = "0.7", features = ["multi-threaded"] } tonic-types = "0.14" tonic = "0.14" tonic-prost = "0.14" -- cgit v1.3.1