动态调优CPU性能模式(CPU性能调节)

小编:饿狼 更新时间:2022-09-29

主要依赖Tuned,在CentOS / RHEL 7和Fedora上,默认情况下已预先安装并激活了tuned,但在较旧版本的CentOS / RHEL 6.x上,需要使用以下yum命令进行安装。

yum install tuned -y

安装后,您将找到以下重要的调整配置文件。

  • /etc/tuned - 调整配置目录。
  • /etc/tuned/tuned-main.conf - 调整的邮件配置文件。
  • /usr/lib/tuned/ - 存储所有调优配置文件的子目录。

列出自带的模式,实际上就是目录/usr/lib/tuned/里的目录对应list出的条目,我们可以自己创建目录写配置文件来定制一个模式

# tuned-adm list Available profiles: - balanced - General non-specialized tuned profile - desktop - Optimize for the desktop use-case - latency-performance - Optimize for deterministic performance at the cost of increased power consumption - network-latency - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance - network-throughput - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks - powersave - Optimize for low power consumption - throughput-performance - Broadly applicable tuning that provides excellent performance across a variety of common server workloads - virtual-guest - Optimize for running inside a virtual guest - virtual-host - Optimize for running KVM guests Current active profile: virtual-guest # ll /usr/lib/tuned/ total 16 drwxr-xr-x. 2 root root 24 Sep 23 11:12 balanced drwxr-xr-x. 2 root root 24 Sep 23 11:12 desktop -rw-r--r--. 1 root root 13997 Jul 5 2018 functions drwxr-xr-x. 2 root root 24 Sep 23 11:12 latency-performance drwxr-xr-x. 2 root root 24 Sep 23 11:12 network-latency drwxr-xr-x. 2 root root 24 Sep 23 11:12 network-throughput drwxr-xr-x. 2 root root 41 Sep 23 11:12 powersave drwxr-xr-x. 2 root root 27 Sep 23 11:12 recommend.d drwxr-xr-x. 2 root root 24 Sep 23 11:12 throughput-performance drwxr-xr-x. 2 root root 24 Sep 23 11:12 virtual-guest drwxr-xr-x. 2 root root 24 Sep 23 11:12 virtual-host

常用模式介绍:

  • balanced

它的目的是成为性能和功耗之间的折衷。它试图尽量使用自动调节。它有好的结果对于大多数负载。唯一的缺点是增加了延迟。在当前调释放它使CPU、磁盘、音频和视频插件和激活ondemand调控器。radeon_powersave设置为自动。

  • desktop

针对桌面系统设计的节能Profile,对SATA适配器、CPU、网络和磁盘插件应用ALPM策略

  • latency-performance

典型低延迟的性能模式。此配置会禁用动态调整机制和透明的大页面。cpuspeed模式改变为performance,将性能低的CPU锁定C状态(通过PM QoS)。同时将磁盘 IO 的调度算法更改为 deadline,在Red Hat Enterprise Linux 6.5和更高版本中cpu_dma_latency参数的值注册为1(可能的最低延迟,早期值为0),用于电源管理服务质量,以尽可能限制延迟。

  • throughput-performance

高吞吐量优化模式。用于典型吞吐量性能调整的服务器配置文件,它禁止 tuned 和 ktune 节能机制。如果系统没有企业级存储,则建议使用此配置文件。与相同latency-performance,除了:

  • kernel.sched_wakeup_granularity_ns(调度程序唤醒粒度)设置为15毫秒
  • vm.dirty_ratio 设置为40%: 脏数据限制,内存里的脏数据百分比不能超过这个值。如果脏数据超过这个数量,新的IO请求将会被阻挡,直到脏数据被写进磁盘。这是造成IO卡顿的重要原因,但这也是保证内存中不会存在过量脏数据的保护机制
  • 透明的大页面已启用
  • virtual-guest

基于企业存储配置文件,在其他任务,增加虚拟内存swappiness和减少磁盘预读值。它没有禁用磁盘屏障。

  • oracle

基于throughput-performance模式,它另外禁用透明的巨大的页面和修改内核参数相关的一些其他性能。这个配置文件是由tuned-profiles-oracle包。在6.8及以后版本可用。

  • network-latency

包括“latency-performance”,禁用 transparent_hugepages,禁用 NUMA 平衡并启用一些基于延迟的网络调整。

  • network-throughput

包括“throughput-performance”,并增加网络堆栈缓冲区大小。

获取当前模式

$ tuned-adm active Current active profile: balanced $ tuned-adm profile_mode Profile selection mode: auto

切换到throughput-performance模式

$ tuned-adm profile throughput-performance

官方文档: https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/power_management_guide/tuned