What is the best way to measure processor “spare” time on a Linux system

For some customers for whom we develop software, we are obliged to "guarantee" a certain amount of spare resources (memory, disk space, processor). Memory and disk space are simple, but the processor is a bit more complex.

One of the methods we used is to create a process that consumes a guaranteed amount of processor time (say, 2.5 seconds every 5 seconds). We run this process with the highest priority to ensure that it starts and consumes all the required processor cycles.

If our regular applications can run at an acceptable level of performance and can transfer all of their functional tests while free time is running, we “assume” that we have fulfilled our commitment to spare processor time.

I am sure that there are other methods for doing the same, and would like to know about them.

+4
source share
4 answers

So this may not be exactly the answer you are looking for, but if all you want to do is make sure that your application does not exceed certain resource limits and that you are running Linux, you can configure / etc / security / limits.con (there may be another file in your distribution of choice) to force restrictions for a specific user and only start the process under that user. This, of course, assumes that you have this level of control over the client’s work environment.

+2
source

If I understand correctly, your problem is that the application also works while this percentage of processing power is unavailable.

The most undeniable approach is to use insufficiently powerful equipment for your testing. If the processor in your setup allows you, you can disable it on the Internet. The Linux kernel gives you a simple interface for this, see /sys/devices/system/cpu/cpu0/cpufreq/ . There are also many GUI applications for this.

If your processor is not able to change the clock frequency online, you can do it in a tough way and choose a smaller multiplier in your BIOS.

I think you get the point. If it runs at 1600 MHz instead of 2400 MHz, you can guarantee 33% of the processor’s free time.

+2
source

SAR is a standard * nix process that collects information about the online use of system resources. It also has a command line tool that allows you to create various reports, and it is common to save data to a database.

+1
source

With a multi-core / processor system, you can use Affinity to your advantage.

0
source

Source: https://habr.com/ru/post/1277146/


All Articles