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.4, ParallelCluster 3.15.0).
$ 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 1088K 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.4, ParallelCluster 3.15.0).
$ sacct -j 42,43 --format=JobID,JobName,Elapsed,MaxRSS,ReqMem,ReqCPUS,CPUTime,State -X
JobID JobName Elapsed MaxRSS ReqMem ReqCPUS CPUTime State
------------ ---------- ---------- ---------- ---------- -------- ---------- ----------
42 val_bp2a 00:00:16 24G 8 00:02:08 COMPLETED
43 val_bp2b 00:00:15 8G 4 00:01:00 COMPLETED