Conversation
Replace per-call System::new() instances with with_global_system() to prevent file descriptor leaks in API mode (long-running metrics loop). Changes: - NVIDIA Jetson (nvidia_jetson.rs): - Line 176: get_process_info() now uses with_global_system() - Line 261: get_gpu_processes() helper now uses with_global_system() - Tenstorrent (tenstorrent.rs): - Line 201: get_process_info() now uses with_global_system() - NVIDIA (nvidia.rs): - Removed system: Mutex<System> field from struct - Migrated get_process_info() to use with_global_system() for consistency This follows the standard pattern already used by AMD reader, Apple Silicon reader, and local collector. Fixes #120
Security & Performance ReviewAnalysis Summary
Review ChecklistSecurity
Performance - Global System Pattern
Correctness
Code Quality
Pre-existing Observation (Not Introduced by This PR)In VerdictThis PR is clean and ready to merge. The changes are mechanical, consistent, and correctly follow the established |
PR Finalization ReportProject Structure
ChecklistTests
Documentation
Code Quality
Changes Verified
All three readers now match the pattern already used by AMD, Apple Silicon, and local collector readers. StatusAll checks passing. Ready for merge. |
Summary
Fixes #120 - Replace per-call
System::new()instances withwith_global_system()to prevent file descriptor leaks in API mode (long-running metrics loop).Problem
The NVIDIA Jetson, Tenstorrent, and NVIDIA readers were creating new
System::new()instances on everyget_process_info()call. In API mode, this runs every interval indefinitely, leaking/procfile descriptors each cycle.Changes
NVIDIA Jetson (
src/device/readers/nvidia_jetson.rs)get_process_info()now useswith_global_system()get_gpu_processes()helper now useswith_global_system()use sysinfo::System;importTenstorrent (
src/device/readers/tenstorrent.rs)get_process_info()now useswith_global_system()use sysinfo::System;importNVIDIA (
src/device/readers/nvidia.rs)system: Mutex<System>field fromNvidiaGpuReaderstructget_process_info()to usewith_global_system()for consistency with the rest of the codebaseApproach
Uses the
with_global_system()function fromsrc/utils/system.rswhich provides a globalMutex<System>instance (GLOBAL_SYSTEM). This is the standard pattern already used by:src/device/readers/amd.rs:583-585)src/device/readers/apple_silicon_native.rs:388)src/view/data_collection/local_collector.rs:304, 433)Testing
cargo buildCloses #120