Skip to content

Commit f8f97fe

Browse files
committed
fix: resolve CI warnings and MCP clone
Use NVML helpers for top process selection and derive Clone for MCP GPU process type.
1 parent ba72b23 commit f8f97fe

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

mcp/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub struct GpuInfo {
266266
pub processes: Vec<GpuProcess>,
267267
}
268268

269-
#[derive(Debug, Serialize, Deserialize)]
269+
#[derive(Debug, Serialize, Deserialize, Clone)]
270270
pub struct GpuProcess {
271271
pub pid: u32,
272272
pub name: String,

src/nvml_api.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,22 @@ impl NvmlApi {
153153
let processes = merge_nvml_processes(compute_processes, graphics_processes);
154154

155155
let pids: Vec<u32> = processes.iter().map(|p| p.pid).collect();
156-
let top_proc = processes.first().map(|p| GpuProc {
157-
gpu_index: index as u16,
158-
pid: p.pid,
159-
user: "unknown".to_string(), // Will be filled by process info
160-
proc_name: "unknown".to_string(), // Will be filled by process info
161-
used_mem_mb: match p.used_gpu_memory {
162-
UsedGpuMemory::Used(bytes) => (bytes / 1024 / 1024) as u32,
163-
UsedGpuMemory::Unavailable => 0,
164-
},
165-
start_time: "unknown".to_string(), // Will be filled by process info
166-
container: None,
167-
});
156+
let top_proc = processes
157+
.iter()
158+
.max_by_key(|p| used_gpu_memory_bytes(p))
159+
.map(|p| {
160+
let mut proc = GpuProc {
161+
gpu_index: index as u16,
162+
pid: p.pid,
163+
user: "unknown".to_string(), // Will be filled by process info
164+
proc_name: "unknown".to_string(), // Will be filled by process info
165+
used_mem_mb: used_gpu_memory_mb(p),
166+
start_time: "unknown".to_string(), // Will be filled by process info
167+
container: None,
168+
};
169+
enrich_gpu_proc(&mut proc);
170+
proc
171+
});
168172

169173
Ok(GpuSnapshot {
170174
gpu_index: index as u16,

0 commit comments

Comments
 (0)