centos7 sets CPU performance

CPU dynamic energy-saving technology is used to reduce server power consumption. By selecting different power management strategies in the idle state of the system, the server power consumption can be reduced to varying degrees. A lower power consumption strategy means that the CPU wakes up more slowly and has a greater impact on performance.

For applications requiring high delay and Performance, it is recommended to turn off the dynamic adjustment function of CPU, prohibit CPU sleep, and fix the CPU frequency to the highest. It is generally recommended to change the power management to Performance in the server BIOS. If the CPU mode is found to be conservative or powersave, you can use cpupower to set the CPU Performance mode, and the effect is also quite significant.

Five modes of cpufreq

Cpufreq is a module that dynamically adjusts the CPU frequency. When the system starts, it generates a folder / sys/devices/system/cpu/cpu0/cpufreq /, which contains several files, including scaling_min_freq stands for the lowest frequency, scaling_max_freq stands for the highest frequency, scaling_ Governor stands for CPU frequency adjustment mode, which is used to control CPU frequency.

cd /sys/devices/system/cpu/cpu0/cpufreq/

affected_cpus
bios_limit
cpuinfo_cur_freq
cpuinfo_max_freq
cpuinfo_min_freq
cpuinfo_transition_latency
freqdomain_cpus
related_cpus
scaling_available_frequencies
scaling_available_governors
scaling_cur_freq
scaling_driver
scaling_governor
scaling_max_freq
scaling_min_freq
scaling_setspeed

View current regulator

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative

View frequency information

cpupower frequency-info

analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us
  hardware limits: 800 MHz - 2.10 GHz
  available frequency steps:  2.10 GHz, 2.10 GHz, 2.00 GHz, 1.90 GHz, 1.80 GHz, 1.70 GHz, 1.60 GHz, 1.50 GHz, 1.40 GHz, 1.30 GHz, 1.20 GHz, 1.10 GHz, 1000 MHz, 900 MHz, 800 MHz
  available cpufreq governors: conservative userspace powersave ondemand performance
  current policy: frequency should be within 800 MHz and 2.10 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 2.10 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

1. performance: as the name suggests, it only focuses on efficiency, and the CPU frequency is fixed at the maximum operating frequency it supports, rather than dynamic adjustment.

2. Userspace: the earliest cpufreq subsystem provides users with this flexibility through userspace governor. The system gives the decision-making power of frequency conversion strategy to the user state application program, and provides the corresponding interface for the user state application program to adjust the CPU running frequency. That is, the model that has been used for a long time. It can be configured by manually editing the configuration file.

3. Powersave: set the CPU frequency to the lowest so-called "power saving" mode, and the CPU will work at the lowest operating frequency it supports. Therefore, these two kinds of Governors belong to static governors, that is, when they are used, the running frequency of CPU will not be dynamically adjusted according to the change of system running load. These two kinds of Governors correspond to two extreme application scenarios. Using performance governor is the greatest pursuit of system high performance, while using powersave governor is the greatest pursuit of system low power consumption.

4. Ondemand: quickly and dynamically adjust the CPU frequency as needed. As soon as there is a task with CPU calculation, it will immediately reach the maximum frequency and return to the minimum frequency after execution; Ondemand: userspace is the detection of kernel state, user state adjustment and low efficiency. Ondemand is a governor that people have long wanted to see working completely in the kernel state and can sample and analyze the system load at more fine-grained intervals. On demand governor, it is detected that the system load exceeds up_ The percentage set by threshold indicates that the user currently needs the CPU to provide more powerful processing power. Therefore, the ondemand governor will set the CPU to run at the highest frequency. However, when the ondemand governor detects that the system load drops and the CPU running frequency can be reduced, which frequency should it be reduced to? The initial implementation of the ondemand governor is to lower to the next available frequency within the optional frequency range. For example, the CPU supports three optional frequencies, namely 1.67GHz, 1.33GHz and 1GHz. If the ondemand governor finds that the operating frequency can be reduced when the CPU is running at 1.67GHz, then 1.33GHz will be selected as the target frequency of the frequency reduction.

5. conservative: unlike ondemand, the CPU frequency is adjusted smoothly. The rise and fall of the frequency is gradual and will be automatically adjusted at the upper and lower limits of the frequency. The difference between ondemand and ondemand is that it allocates the frequency on demand rather than blindly pursuing the highest frequency;

cpupower set performance

The effect of switching from conservative or powersave to performance is still powerful

# CentOS kernel tools installation
yum install kernel-tools

# Ubuntu installs CPU mode without graphical switcher
apt install cpufrequtils

# cpupower set performance
cpupower frequency-set -g performance

# View current regulator
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
performance

Keywords: Linux

Added by mvd7793 on Mon, 31 Jan 2022 02:10:25 +0200