Skip to content

Best Practices

Exercises

  1. 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
If `MaxRSS` is 2G but you requested 8G, you are wasting 6G that other users could use. If `Elapsed` is 5 minutes but you requested 30, future jobs can use a tighter `--time` to improve scheduling priority. Expected output: Validated 2026-04-15 on 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 
  1. 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
The right-sized job often starts sooner because the scheduler can fit it into smaller gaps in the cluster. Over hundreds of jobs (e.g., in an array), this difference adds up significantly. Expected output: Validated 2026-04-15 on 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 

References