nodedb_mem/engine.rs
1//! Engine identification for memory budget tracking.
2
3/// Identifies a subsystem that owns a memory budget.
4///
5/// Each engine operates within its allocated memory ceiling. The governor
6/// tracks allocations per engine and rejects requests that would exceed
7/// the budget.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum EngineId {
10 /// HNSW vector index, distance computation buffers, quantized caches.
11 Vector,
12
13 /// redb B-Tree, splintr inverted index, schema metadata.
14 Sparse,
15
16 /// loro CRDT state, merge buffers, operation logs.
17 Crdt,
18
19 /// Gorilla-encoded memtables, Zstd dictionaries, log buffers.
20 Timeseries,
21
22 /// DataFusion query execution: sorts, aggregates, hash tables.
23 Query,
24
25 /// WAL write buffers, group commit staging.
26 Wal,
27
28 /// SPSC bridge buffers, slab allocator, envelope staging.
29 Bridge,
30}
31
32impl EngineId {
33 /// All known engine identifiers (for iteration in the governor).
34 pub const ALL: &'static [EngineId] = &[
35 EngineId::Vector,
36 EngineId::Sparse,
37 EngineId::Crdt,
38 EngineId::Timeseries,
39 EngineId::Query,
40 EngineId::Wal,
41 EngineId::Bridge,
42 ];
43}
44
45impl std::fmt::Display for EngineId {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 match self {
48 EngineId::Vector => write!(f, "vector"),
49 EngineId::Sparse => write!(f, "sparse"),
50 EngineId::Crdt => write!(f, "crdt"),
51 EngineId::Timeseries => write!(f, "timeseries"),
52 EngineId::Query => write!(f, "query"),
53 EngineId::Wal => write!(f, "wal"),
54 EngineId::Bridge => write!(f, "bridge"),
55 }
56 }
57}