stress-ng starts worker processes called stressors. Each loads its own
part of the system: --cpu computes, --vm allocates and walks through
memory, --hdd writes files, --io calls sync(). The number after a key
is how many workers to start. The training machine has version 0.17.
--timeout (-t) limits the run time. Without it stress-ng runs for a
day:
student@ubuntu:~$ stress-ng --cpu 1
stress-ng: info: [1994] defaulting to a 1 day, 0 secs run per stressor
In ps and top the main process is stress-ng, the workers are
stress-ng-cpu, stress-ng-vm and so on. The main one only hands out
work: CPU and memory are used by the workers.
Output and exit code
student@ubuntu:~$ stress-ng --cpu 2 --timeout 70s --metrics-brief
stress-ng: info: [972] setting to a 1 min, 10 secs run per stressor
stress-ng: info: [972] dispatching hogs: 2 cpu
…
stress-ng: info: [972] passed: 2: cpu (2)
stress-ng: info: [972] failed: 0
stress-ng: info: [972] successful run completed in 1 min, 10.01 secs
--metrics-brief added a line for the cpu stressor:
| bogo ops |
real time |
usr time |
sys time |
bogo ops/s (real) |
| 87462 |
70.00 |
68.68 |
0.02 |
1249.39 |
Bogo ops are the stressor's nominal operations: compare them only between
runs of the same stressor on the same machine. Two processes ran for 70
seconds on one CPU and got 68.68 seconds of usr together — half each.
| Code |
Meaning |
| 0 |
success |
| 1 |
an error in the options or the temporary directory |
| 2 |
a stressor failed |
| 3 |
a stressor lacked resources — memory, space |
| 4 |
a stressor is not supported on this system |
| 5 |
a stressor was killed by an unexpected signal |
Stressors
| Key |
What it does |
Where it shows |
--cpu N |
N processes compute |
us in top, load average |
--cpu-load P |
each --cpu loads the CPU by P % |
the process's %CPU |
--vm N --vm-bytes S |
N processes take S of memory each and walk through it |
free, RSS |
--hdd N --hdd-bytes S |
N processes write and delete files of S |
wa, iostat |
--io N |
N processes call sync() |
bo in vmstat |
--cpu 0 starts one process per CPU. --vm-bytes takes a percentage of
available memory too: --vm-bytes 25%. --vm-keep holds the same memory
without freeing it between passes.
stress-ng and OOM
stress-ng gives its workers oom_score_adj 1000: when memory runs out,
the oom-killer picks them first. The main process restarts a killed
worker until the time is up. The --oomable key turns restarts off: the
stressor ends early, and stress-ng prints vm: WARNING: finished
prematurely after just 0.56 secs.