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

Method check_engine_pressure

nodedb/src/data/executor/core_loop/pressure.rs:43–75  ·  view source on GitHub ↗

Check engine-level memory pressure at the start of a write handler. - `Normal` / `Warning`: returns `None` — proceed normally. - `Critical`: increments the critical metric counter, returns `None` (handler proceeds; engine-specific flush is the handler's own responsibility — see timeseries ingest for the pattern). - `Emergency`: increments the emergency metric counter, returns `Some(Response)` wit

(
        &self,
        task: &ExecutionTask,
        engine: EngineId,
    )

Source from the content-addressed store, hash-verified

41 /// `Some(Response)` with `ErrorCode::ResourcesExhausted`. The caller
42 /// must return this response immediately without executing the write.
43 pub fn check_engine_pressure(
44 &self,
45 task: &ExecutionTask,
46 engine: EngineId,
47 ) -> Option<Response> {
48 let governor = self.governor.as_ref()?;
49 let pressure = governor.engine_pressure(engine);
50 match pressure {
51 PressureLevel::Normal | PressureLevel::Warning => None,
52 PressureLevel::Critical => {
53 if let Some(ref m) = self.metrics {
54 m.record_backpressure_critical(&engine.to_string());
55 }
56 warn!(
57 core = self.core_id,
58 engine = %engine,
59 "Critical memory pressure — proceeding with engine-specific flush"
60 );
61 None
62 }
63 PressureLevel::Emergency => {
64 if let Some(ref m) = self.metrics {
65 m.record_backpressure_emergency(&engine.to_string());
66 }
67 warn!(
68 core = self.core_id,
69 engine = %engine,
70 "Emergency memory pressure — rejecting write with backpressure"
71 );
72 Some(self.response_error(task, ErrorCode::ResourcesExhausted))
73 }
74 }
75 }
76
77 /// Adjust SPSC read depth based on worst-case pressure across all engines.
78 ///

Calls 6

engine_pressureMethod · 0.80
to_stringMethod · 0.80
response_errorMethod · 0.80
as_refMethod · 0.45