From dc650af0c0205c7bb3b8d7294e6ccf5ab651859f Mon Sep 17 00:00:00 2001 From: Lars T Hansen Date: Mon, 2 Oct 2023 08:34:44 +0200 Subject: [PATCH] Make timeout 5s, and share it --- src/amd.rs | 3 +-- src/main.rs | 2 ++ src/nvidia.rs | 3 +-- src/process.rs | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/amd.rs b/src/amd.rs index dde7865..f778453 100644 --- a/src/amd.rs +++ b/src/amd.rs @@ -16,6 +16,7 @@ use crate::command::{self, CmdError}; use crate::nvidia; use crate::ps::UserTable; +use crate::TIMEOUT_SECONDS; use std::cmp::Ordering; @@ -139,8 +140,6 @@ PID 28154 is using 1 DRM device(s): ])); } -const TIMEOUT_SECONDS: u64 = 2; // For `rocm-smi` - const AMD_CONCISE_COMMAND: &str = "rocm-smi"; // Return a vector of AMD GPU utilization indexed by device number: (gpu%, mem%) diff --git a/src/main.rs b/src/main.rs index 726e9b6..a406285 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,8 @@ mod ps; mod slurm; mod util; +const TIMEOUT_SECONDS: u64 = 5; // For subprocesses + #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Cli { diff --git a/src/nvidia.rs b/src/nvidia.rs index 6f0cc28..f0af5f7 100644 --- a/src/nvidia.rs +++ b/src/nvidia.rs @@ -9,6 +9,7 @@ use crate::command::{self, CmdError}; use crate::util; use crate::ps::UserTable; +use crate::TIMEOUT_SECONDS; #[cfg(test)] use crate::util::map; @@ -49,8 +50,6 @@ pub fn get_nvidia_information( } } -const TIMEOUT_SECONDS: u64 = 2; // For `nvidia-smi` - // For prototyping purposes (and maybe it's good enough for production?), parse the output of // `nvidia-smi pmon`. This output has a couple of problems: // diff --git a/src/process.rs b/src/process.rs index e8e3dfb..35b8d05 100644 --- a/src/process.rs +++ b/src/process.rs @@ -1,6 +1,7 @@ /// Collect CPU process information without GPU information, by running `ps`. use crate::command::{self, CmdError}; +use crate::TIMEOUT_SECONDS; use crate::util; #[derive(PartialEq)] @@ -27,8 +28,6 @@ pub fn get_process_information() -> Result, CmdError> { } } -const TIMEOUT_SECONDS: u64 = 2; // for `ps` - // `--cumulative` and `bsdtime` are to make sure that the cpu time accounted to exited child // processes (the cutime and cstime fields of /proc/pid/status) is used and printed. Note // `cputimes` is unaffected by `--cumulative`.