Skip to contents

Analyzes requested versus empirically observed Peak RSS memory, walltime, and cross-chunk straggler imbalance from a completed or partially failed slurm_submit() job, slurm_status() telemetry object, slurm_autopilot() run, or parsed parse_sacct_output() table. Quantifies memory waste %, walltime slack %, and straggler ratio (max / median chunk time), and emits a concrete recommended tightened resource_spec() for the next run.

Usage

slurm_efficiency_report(
  x,
  resources = NULL,
  mem_safety = 1.25,
  time_safety = 1.35,
  mem_min_mb = 256L,
  mem_round_mb = 128L,
  time_min_minutes = 5,
  time_round_minutes = 5
)

Arguments

x

A slurmpilot_job, slurmpilot_autopilot, slurmpilot_status, or data frame from parse_sacct_output().

resources

Optional slurmpilot_resources object (required when x is a slurmpilot_status or sacct data frame; inferred automatically from slurmpilot_job or slurmpilot_autopilot).

mem_safety

Safety multiplier applied to observed peak RSS when computing recommended --mem. Default 1.25.

time_safety

Safety multiplier applied to observed max walltime when computing recommended --time. Default 1.35.

mem_min_mb

Minimum recommended --mem in MB. Default 256L.

mem_round_mb

Rounding granularity in MB for recommended --mem. Default 128L.

time_min_minutes

Minimum recommended --time in minutes. Default 5.

time_round_minutes

Rounding granularity in minutes for recommended --time. Default 5.

Value

An S3 object of class "slurmpilot_efficiency" containing:

  • classification: one of "efficient", "over_provisioned", "under_provisioned", or "imbalanced".

  • metrics: named list of utilization, waste, slack, straggler ratio, and failure counts.

  • chunks: per-chunk telemetry tibble with mem_util_pct and time_util_pct.

  • requested_resources: original slurmpilot_resources spec.

  • recommended_resources: tightened (or escalated) slurmpilot_resources spec for the next run.

  • recommendations: character vector of concrete optimization actions.

Examples

be <- mock_slurm_backend(max_workers = 2L)
res <- resource_spec(n_tasks = 6L, chunk_size = 2L, mem_mb = 2048L, time_minutes = 30)
job <- slurm_submit(be, function(x) mean(rnorm(200)), as.list(1:6), resources = res)
slurm_wait(job, poll_interval = 0.05)
#> 
#> ── slurmpilot Job Status: slurmpilot_job [COMPLETED] 
#> • Progress: 3/3 chunks (100%) | running=0, pending=0, failed=0, oom=0,
#>   timeout=0, cancelled=0
#> • Peak RSS max: 120.4 MB | Cumulative walltime: 0.90s
eff <- slurm_efficiency_report(job)
print(eff)
#> 
#> ── slurmpilot Post-Mortem Efficiency Audit: slurmpilot_job [over_provisioned] 
#> • Memory: 120.4 MB max / 2048 MB req (5.9% util, 94.1% waste)
#> • Walltime: 0.3s max / 1800s req (0.0% util, 100.0% slack)
#> • Load balance: straggler ratio 1.12x across 3 chunks
#> • Recommended next flags: --array=1-3 --cpus-per-task=1 --mem=256M
#>   --time=00:05:00
#> ℹ Memory waste is 94.1% (peak 120.4 MB vs 2G requested); tighten --mem to 256M.
#> ℹ Walltime slack is 100.0% (max 0.3s vs 00:30:00 requested); tighten --time to
#>   00:05:00.
unlink(be$root_dir, recursive = TRUE)