From dcc0d2cd7d475f35d8c7c7222487f98f25a744b9 Mon Sep 17 00:00:00 2001 From: Derek Feichtinger Date: Fri, 26 Jun 2026 18:06:18 +0200 Subject: [PATCH] corrected CPU waste calculation. Failed jobs counted as waste --- slurm-eff-tool.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/slurm-eff-tool.py b/slurm-eff-tool.py index d62b88c..b340f17 100755 --- a/slurm-eff-tool.py +++ b/slurm-eff-tool.py @@ -831,7 +831,11 @@ def make_single_row(rec: JobRecord, dflt_mpcpu: float) -> OutputRow: waste_cpu = None if rec.cpu_eff is not None: - waste_cpu = walltime * (100-rec.cpu_eff) * rec.cpus + # We count failed jobs as wasted CPU! + if rec.state != state_mappings['COMPLETED']: + waste_cpu = walltime * rec.cpus + else: + waste_cpu = walltime * (100-rec.cpu_eff)/100 * rec.cpus jobid = rec.jobidraw if jobid == "": @@ -897,7 +901,11 @@ def make_aggregate_row(records: list[JobRecord], username: str, waste_cpu=None if cpu_efficiency is not None and walltime is not None: - waste_cpu = count * walltime * (100-cpu_efficiency) * first.cpus + # We count failed jobs as wasted CPU! + if first.state != state_mappings['COMPLETED']: + waste_cpu = count * walltime * first.cpus + else: + waste_cpu = count * walltime * (100-cpu_efficiency)/100 * first.cpus return OutputRow( username=username,