0

I'm trying to test a server under specific workloads. I'm using stress-ng to simulate a x% cpu load: stress-ng -c 1 -l x

I also trying to use stress-ng to simulate a memory load of x megabytes: stress-ng -vm 1 --vm-bytes xM. This command creates a vm stressor that allocates roughly the amount of memory requested. However, it also generates a 100% cpu utilisation. My guess is that this is due to the stressor continuously accessing the allocated memory to force it to be mapped to real memory.

Is there any way to limit the amount of CPU used by the memory stressor?

pablochacin
  • 210
  • 1
  • 2
  • 8

2 Answers2

0

stress-ng always hits systems hard. For example, the --cpu-method option has documentation for the best one to "make a CPU run hot". "It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces."

Profile what exactly it does if you are curious. Easy on Linux, installing debug symbols then perf top is a good start. Both on the stress tests, and other applications.

Regarding -vm, mmap(), touching pages, and munmap() in a tight loop is going to be brutal to the virtual memory system, and be memory bottlenecked. Instructions per clock is probably going to be terrible, and not show what the CPU can do when kept fed with data. Symptoms at the host metrics level will include a very large % of system CPU time.

stress-ng -vm 1 --vm-hang 0 will sleep virtual memory (VM) workers indefinitely, after touching the memory. Try this if you want to allocate a large anonymous memory area, but not do anything with it. Questionable utility, I suspect, but you can do it.

This will not perform like practical applications do:

  • stress-ng does not do useful work; this is not a benchmark.
  • Memory or CPU workers are not I/O bound waiting for slow disks or network.
  • CPU method algorithms, while diverse and real world, are not what you might see from say a transactional database.
  • No file I/O, if relevant to this application. stress-ng has file stressors, but not surprisingly they will hit the system hard.

Still useful to be sure hosts don't fall over under stress.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
0

In general one can limit the cpu usage with -l <percent> so if it should use 6 Cores on 50 Percent usage, I do:

stress-ng -c 6 -l 50

There should be mentioned that the documentation states: "This option only applies to the --cpu stressor option and not to all of the cpu class of stressors." Manpage