Skip to content

Commit

Permalink
Merge pull request #109 from lars-t-hansen/w-longer-timeout
Browse files Browse the repository at this point in the history
Make timeout 5s, and share it.  Fix #92.
  • Loading branch information
bast authored Oct 4, 2023
2 parents 651187e + dc650af commit 66fe3e0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use crate::command::{self, CmdError};
use crate::nvidia;
use crate::ps::UserTable;
use crate::TIMEOUT_SECONDS;

use std::cmp::Ordering;

Expand Down Expand Up @@ -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%)
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/nvidia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
//
Expand Down
3 changes: 1 addition & 2 deletions src/process.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -27,8 +28,6 @@ pub fn get_process_information() -> Result<Vec<Process>, 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`.
Expand Down

0 comments on commit 66fe3e0

Please sign in to comment.