Best Practices
Exercises¶
- Estimate resources for a job
Submit a short test job (a small dataset or a quick analysis), then use sacct to see how many resources it actually consumed. Compare the actual usage to what you requested. Were you close, or did you over- or under-request?
Hint / Solution
# Submit a test job (adjust the command to your workload)
sbatch --job-name=resource_test --time=00:30:00 --ntasks=1 \
--cpus-per-task=4 --mem=8G --wrap="your_analysis_command input.dat"
# After the job completes, check actual resource usage
sacct -j <jobid> --format=JobID,JobName,Elapsed,MaxRSS,MaxVMSize,CPUTime,ReqMem,ReqCPUS,State
# Interpretation:
# Elapsed = wall-clock time (compare to --time)
# MaxRSS = peak memory used (compare to --mem)
# CPUTime = total CPU seconds consumed
# ReqMem = what you requested
# ReqCPUS = CPUs you requested
slurm-training-val (Slurm 25.11.8, ParallelCluster 3.16.1).
$ sacct -j 42 --format=JobID,JobName,Elapsed,MaxRSS,MaxVMSize,CPUTime,ReqMem,ReqCPUS,State
JobID JobName Elapsed MaxRSS MaxVMSize CPUTime ReqMem ReqCPUS State
------------ ---------- ---------- ---------- ---------- ---------- ---------- -------- ----------
42 val_bp1 00:00:30 00:02:00 8G 4 COMPLETED
42.batch batch 00:00:30 952K 0 00:02:00 4 COMPLETED
- Compare resource efficiency
Submit the same short job twice with different resource requests -- once with generous resources and once with a tighter fit based on your measurements from Exercise 1. Compare the wait time and efficiency of each.
Hint / Solution
# Run 1: Generous resources
sbatch --job-name=generous --time=02:00:00 --ntasks=1 \
--cpus-per-task=8 --mem=32G --wrap="your_analysis_command input.dat"
# Run 2: Right-sized resources (based on actual usage from Exercise 1)
sbatch --job-name=rightsized --time=00:30:00 --ntasks=1 \
--cpus-per-task=4 --mem=8G --wrap="your_analysis_command input.dat"
# Compare both jobs after completion
sacct -j <jobid1>,<jobid2> \
--format=JobID,JobName,Elapsed,MaxRSS,ReqMem,ReqCPUS,CPUTime,State
# Check how long each waited in the queue
sacct -j <jobid1>,<jobid2> \
--format=JobID,JobName,Submit,Start,Elapsed,State
slurm-training-val (Slurm 25.11.8, ParallelCluster 3.16.1).
$ sacct -j 42,43 --format=JobID,JobName,Elapsed,MaxRSS,ReqMem,ReqCPUS,CPUTime,State -X
JobID JobName Elapsed MaxRSS ReqMem ReqCPUS CPUTime State
------------ ---------- ---------- ---------- ---------- -------- ---------- ----------
42_2 val_ja3 00:00:10 256M 1 00:00:10 CANCELLED+
42_3 val_ja3 00:00:10 256M 1 00:00:10 CANCELLED+
42 val_bp2a 00:00:16 24G 8 00:02:08 COMPLETED
43 val_bp2b 00:00:15 8G 4 00:01:00 COMPLETED
- Compute job efficiency by hand
Pick one completed job and compute its CPU efficiency from sacct fields: TotalCPU / (AllocCPUS × Elapsed). Then compare with what seff reports.
Hint / Solution
# Pick a finished job and pull the raw fields (-X = allocation line only)
sacct -j <jobid> -X --format=JobID,AllocCPUS,Elapsed,TotalCPU,State
# Example arithmetic: AllocCPUS=4, Elapsed=00:10:00, TotalCPU=00:20:00
# core-seconds allocated = 4 * 600 = 2400
# core-seconds used = 20 * 60 = 1200
# efficiency = 1200 / 2400 = 50%
# Cross-check (if seff is installed)
seff <jobid>
slurm-training-val (Slurm 25.11.8, ParallelCluster 3.16.1).
$ sacct -j 42 -X --format=JobID,AllocCPUS,Elapsed,TotalCPU,State
JobID AllocCPUS Elapsed TotalCPU State
------------ ---------- ---------- ---------- ----------
42 2 00:00:04 00:00:00 COMPLETED
$ seff 42
Job ID: 42
Cluster: slurm-training-val
User/Group: ec2-user/ec2-user
State: COMPLETED (exit code 0)
Nodes: 1
Cores per node: 2
CPU Utilized: 00:00:03
CPU Efficiency: 37.50% of 00:00:08 core-walltime
Job Wall-clock time: 00:00:04
Memory Utilized: 4.73 MB
Memory Efficiency: 0.02% of 30.40 GB (30.40 GB/node)
References¶
- SchedMD: Quick Start User Guide
- SchedMD: FAQ
- SchedMD: Troubleshooting Guide
- SMU Slurm Best Practices
- SchedMD: sbatch man page (
--mem-update,--wait,--dependency) - SchedMD: sbcast man page
- reportseff