MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / evaluate_memory_pressure

Method evaluate_memory_pressure

nodedb-graph/src/csr/memory.rs:87–104  ·  view source on GitHub ↗

Evaluate graph memory pressure and return promotion/demotion hints. Uses SpillController-compatible thresholds (90%/75% hysteresis): - Above spill threshold: demote cold nodes (spill to potential mmap) - Below restore threshold: promote warm nodes back to hot RAM `utilization` = estimated memory usage as percentage (0-100). Returns `(nodes_to_demote, nodes_to_promote)` counts.

(
        &self,
        utilization: u8,
        spill_threshold: u8,
        restore_threshold: u8,
    )

Source from the content-addressed store, hash-verified

85 /// `utilization` = estimated memory usage as percentage (0-100).
86 /// Returns `(nodes_to_demote, nodes_to_promote)` counts.
87 pub fn evaluate_memory_pressure(
88 &self,
89 utilization: u8,
90 spill_threshold: u8,
91 restore_threshold: u8,
92 ) -> (usize, usize) {
93 if utilization >= spill_threshold {
94 // Above spill threshold: identify cold nodes to demote.
95 let cold = self.cold_nodes(0);
96 (cold.len(), 0)
97 } else if utilization <= restore_threshold {
98 // Below restore threshold: all nodes can stay hot.
99 (0, self.node_count())
100 } else {
101 // In hysteresis band: no action.
102 (0, 0)
103 }
104 }
105
106 /// Estimated memory usage of the dense CSR in bytes.
107 ///

Callers 1

Calls 3

cold_nodesMethod · 0.80
lenMethod · 0.45
node_countMethod · 0.45

Tested by 1