[TOC]
Contents
hide
CPU优化建议使用cpupower设置CPU Performance模式
CPU频率
查看 cpu 的频率
[root@mulangcloud ~]# lscpu|grep Hz
Model name: Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz
CPU MHz: 1616.296
CPU max MHz: 3200.0000
CPU min MHz: 1000.0000
每 4.2 查询一次,所有 cpu 核心的实时频率
watch -n4.2 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""
cpufreq
cpufreq是一个动态调整cpu频率的模块,系统启动时生成一个文件夹/sys/devices/system/cpu/cpu0/cpufreq/,文件夹里有一些 cpu 频率信息.
###scaling_min_freq代表最低频率
[root@mulangcloud ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1000000
###scaling_max_freq代表最高频率
[root@mulangcloud ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
3200000
###scalin_governor代表cpu频率调整模式
[root@mulangcloud ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
performance
cpu 调频模式
模式 | |
---|---|
performance | 将CPU频率固定工作在其支持的最高运行频率上,而不动态调节.追求系统高性能 |
powersave | 将CPU频率设置为最低的所谓“省电”模式,CPU会固定工作在其支持的最低运行频率上. 追求系统低功耗 |
userspace | 运行于用户指定的频率 |
ondemand | 按需快速动态调整CPU频率, 一有cpu计算量的任务,就会立即达到最大频率运行,空闲时间增加就降低频率 |
conservative | 与ondemand不同,平滑地调整CPU频率,频率的升降是渐变式的,会自动在频率上下限调整 |
cpupower
cpupower 是一组为辅助 CPU 调频而设计的用户空间工具。该软件包并非必须,但强烈建议安装,因为它提供了方便的命令行实用程序,并且内置 systemd 服务,可在启动时更改调频器。
查看 cpu 频率
[root@mulangcloud ~]# cpupower frequency-info
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: Cannot determine or is not supported.
hardware limits: 1000 MHz - 3.20 GHz # 硬件限制色频率
available cpufreq governors: performance powersave
current policy: frequency should be within 1000 MHz and 3.20 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: 2.68 GHz (asserted by call to hardware)
boost state support:
Supported: yes
Active: yes
cpupower设置performance
cpupower frequency-set -g performance
mac os 查询 cpu
sysctl -a | grep machdep.cpu