Name Last Update
README.md Loading commit data...
piloop Loading commit data...
piloop.c Loading commit data...
piloop.exe Loading commit data...

PILOOP

CygWin/Linux/Unix command to calculate pi in a forever loop, thereby maxing out the CPU cores of the machine. You need to specify the number of concurrent threads, and optionally the priority of the process by specifying a nice value to add.

Syntax

piloop <n> <p>

Where
<n> The number of concurrent threads to run
<p> The priority of the process (added to the default nice value of 0)

On most systems root privileges are needed to change the process nice value.

Set number of threads to the same number as logical cpus in order to load all cpus on the machine.

Set the nice value to 20 to run the process with the lowest possible priority.

This will basicly replace the idle process on the machine. If the number of threads is set to the number of logical cpus, the server will always use all cpus 100% but still perform as normal (since all other processes have higher priority).

If this is run on a virtual machine, the hypervisor will think the server always needs all available cpu resources given to the machine, minimizing the risk of letting the hypervisor think that cpu resources can be shared with some other virtual machines. This helps in for example performance testing, where it is important to have the same amount of resources available each time a performance test is run, in order to compare with previous results in the same machine.

It is of corse better to change the virtual machines resources settings to get dedicated CPU resources and high priority, but this is not always easy to achieve, since some virtualization setups want to have the same settings on all machines and let the hypervisor decide where to put what virtual machines. The nature of performance testing, where one hour of the day can require all available CPU resources and the rest of the day does not use any CPU at all, is extremly difficult for the hypervisor to predict, and provide addequate CPU resources when needed during a test.

For this reason, it is good practice to keep the piloop tool running a day or two before the performance testing starts, in order for the hypervisor to make room and provide CPU resources for all virtual CPU's. In order to not affect other virtual machines by suddenly requireing all CPU's, its also good practice to more slowly increase the number of CPU's being fully loaded with piloop. You can start several piloop processes with a couple of hours in between, where each piloop process loads 25-50% of the available logical CPU's.

Compile

Using GCC and pthreads:

gcc -pthread piloop.c -o piloop

Binary in Repository

The pre-compiled piloop file in the repository is compiled for

piloop: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, 
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, 
BuildID[sha1]=5312cb7d4bc2fab8851badf5ef36ddd91ce2136a, not stripped

The pre-compiled piloop.exe file in the repository is compiled for

piloop.exe: PE32+ executable (console) x86-64, for MS Windows

and requires a CygWin x64 installation. The provided cygwin1.dll can be used to run only piloop.exe. Please note that CygWin is under a different license (https://cygwin.com/licensing.html).