resource_monitor (faber_neuroevolution v1.2.4)
View SourceSystem resource monitoring for adaptive neuroevolution.
This module provides system resource metrics that can be used as inputs to the LTC meta-controller, allowing it to adapt evolution hyperparameters based on current memory and CPU pressure.
Metrics Provided
Raw metrics: - memory_total: Total VM memory usage (bytes) - memory_processes: Memory used by processes (bytes) - memory_binary: Binary memory (bytes) - often the culprit in leaks - scheduler_utilization: Average CPU utilization (0.0 - 1.0) - process_count: Number of processes in the VM - message_queue_len: Total message queue length across monitored processes
Normalized metrics (for LTC input): - memory_pressure: 0.0 (plenty of memory) to 1.0 (critical) - cpu_pressure: 0.0 (idle) to 1.0 (saturated) - process_pressure: 0.0 (few processes) to 1.0 (at limit)
Usage
%% Get raw metrics #{memory_total := Mem} = resource_monitor:get_metrics(),
%% Get normalized metrics for LTC input #{memory_pressure := MemP, cpu_pressure := CpuP} = resource_monitor:get_normalized_metrics(), LtcInputs = [MemP, CpuP, ...]
Summary
Functions
Perform health check and return status.
Get the memory limit for the system.
Get current system resource metrics (raw values).
Get normalized metrics for LTC input (0.0 to 1.0 range).
Check if memory usage is at critical level (>90%).
Check if memory usage is at high level (>70%).
Functions
-spec check_health() -> map().
Perform health check and return status.
Returns a map with health status and any warnings/alerts.
-spec get_memory_limit() -> pos_integer().
Get the memory limit for the system.
Attempts to detect from: 1. MACULA_MEMORY_LIMIT environment variable (bytes) 2. Container cgroup limits 3. System total memory 4. Default fallback (8GB)
-spec get_metrics() -> map().
Get current system resource metrics (raw values).
Returns a map with various resource measurements.
-spec get_normalized_metrics() -> map().
Get normalized metrics for LTC input (0.0 to 1.0 range).
These are suitable for direct use as neural network inputs.
-spec is_memory_critical() -> boolean().
Check if memory usage is at critical level (>90%).
-spec is_memory_high() -> boolean().
Check if memory usage is at high level (>70%).