自定义性能调优文件:RHEL8学习系列2
性能配置文件的详细内容
/usr/lib/tuned/
RHEL自带的性能调优profile文件存储在目录中。每个配置文件都有其自己的目录。该配置文件由名为tuned.conf的主要配置文件以及其他文件(例如脚本)组成。
查看现有的(/usr/lib/tuned/目录下的)profile目录:
查看throughput-performance的目录,包含tuned.conf文件:
查看tuned.conf中内容:
[root@repo throughput-performance]# cat tuned.conf
#
# tuned configuration
#
[main]
summary=Broadly applicable tuning that provides excellent performance across a variety of common server workloads
[cpu]
governor=performance
energy_perf_bias=performance
min_perf_pct=100
[disk]
# The default unit for readahead is KiB. This can be adjusted to sectors
# by specifying the relevant suffix, eg. (readahead => 8192 s). There must
# be at least one space between the number and suffix (if suffix is specified).
readahead=>4096
[sysctl]
# ktune sysctl settings for rhel6 servers, maximizing i/o throughput
#
# Minimal preemption granularity for CPU-bound tasks:
# (default: 1 msec# (1 + ilog(ncpus)), units: nanoseconds)
kernel.sched_min_granularity_ns = 10000000
# SCHED_OTHER wake-up granularity.
# (default: 1 msec# (1 + ilog(ncpus)), units: nanoseconds)
#
# This option delays the preemption effects of decoupled workloads
# and reduces their over-scheduling. Synchronous workloads will still
# have immediate wakeup/sleep latencies.
kernel.sched_wakeup_granularity_ns = 15000000
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up. Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 40
# Start background writeback (via writeback threads) at this percentage (system
# default is 10%)
vm.dirty_background_ratio = 10
# PID allocation wrap value. When the kernel's next PID value
# reaches this value, it wraps back to a minimum PID value.
# PIDs of value pid_max or larger are not allocated.
#
# A suggested value for pid_max is 1024 * <# of cpu cores/threads in system>
# e.g., a box with 32 cpus, the default of 32768 is reasonable, for 64 cpus,
# 65536, for 4096 cpus, 4194304 (which is the upper limit possible).
#kernel.pid_max = 65536
# The swappiness parameter controls the tendency of the kernel to move
# processes out of physical memory and onto the swap disk.
# 0 tells the kernel to avoid swapping processes out of physical memory
# for as long as possible
# 100 tells the kernel to aggressively swap processes out of physical memory
# and move them to swap cache
vm.swappiness=10
/etc/tuned/
如果需要定制profile文件,需要将profile文件目录从/usr/lib/tuned/复制到/etc/tuned/的子目录中,然后修改tuned.conf对应的参数。如vm.dirty_ratio = 40。
此外,在/etc/tuned/中还有个全局配置文件tuned-main.conf。
我们查看/etc/tuned/tuned-main.conf文件的内容:
[root@repo tuned]# cat tuned-main.conf
# Global tuned configuration file.
# Whether to use daemon. Without daemon it just applies tuning. It is
# not recommended, because many functions don't work without daemon,
# e.g. there will be no D-Bus, no rollback of settings, no hotplug,
# no dynamic tuning, ...
daemon = 1
# Dynamicaly tune devices, if disabled only static tuning will be used.
dynamic_tuning = 0
# How long to sleep before checking for events (in seconds)
# higher number means lower overhead but longer response time.
sleep_interval = 1
# Update interval for dynamic tunings (in seconds).
# It must be multiply of the sleep_interval.
update_interval = 10
# Recommend functionality, if disabled "recommend" command will be not
# available in CLI, daemon will not parse recommend.conf but will return
# one hardcoded profile (by default "balanced").
recommend_command = 1
# Whether to reapply sysctl from the e.g /etc/sysctl.conf, /etc/sysctl.d, ...
# If enabled these sysctls will be re-appliead after Tuned sysctls are
# applied, i.e. Tuned sysctls will not override system sysctls.
reapply_sysctl = 1
# Default priority assigned to instances
default_instance_priority = 0
# Udev buffer size
udev_buffer_size = 1MB
动态调整
默认情况下,动态调整是禁用的。要启用它,编辑/etc/tuned/tuned-main.conf文件,并将dynamic_tuning选项更改为1。然后定期分析系统统计信息并使用它们来更新系统调整设置。要配置两次更新之间的时间间隔(以秒为单位),请使用update_interval选项。如上小节展示。
在典型的办公室使用的Workstation上,以太网负载很低。只有进出几封电子邮件,或者只会加载某些网页。
对于这些类型的负载,网络接口不必始终保持全速运行。Tuned具有用于网络设备的监视和调整插件,可以检测到这种低活动性,然后自动降低该接口的速度,通常会降低功耗。
如果界面上的活动持续较长时间(例如,由于正在下载DVD映像或打开了带有大附件的电子邮件),则Tuned会检测到此情况,并将界面速度设置为最大,以提供最佳性能。
安装并使用一个profile
安装一个profile的rpm:
yum -y install tuned-profiles-cpu-partitioning
然后在/usr/lib/tuned/目录中可以看到对应的profile子目录:
查看tuned.conf文件:
[root@repo cpu-partitioning]# cat tuned.conf
# tuned configuration
#
[main]
summary=Optimize for CPU partitioning
include=network-latency
[variables]
# User is responsible for updating variables.conf with variable content such as isolated_cores=X-Y
include=/etc/tuned/cpu-partitioning-variables.conf
isolated_cores_assert_check = \\${isolated_cores}
# Fail if isolated_cores are not set
assert1=${f:assertion_non_equal:isolated_cores are set:${isolated_cores}:${isolated_cores_assert_check}}
# tmpdir
tmpdir=${f:strip:${f:exec:/usr/bin/mktemp:-d}}
# Non-isolated cores cpumask including offline cores
isolated_cores_expanded=${f:cpulist_unpack:${isolated_cores}}
isolated_cpumask=${f:cpulist2hex:${isolated_cores_expanded}}
not_isolated_cores_expanded=${f:cpulist_invert:${isolated_cores_expanded}}
isolated_cores_online_expanded=${f:cpulist_online:${isolated_cores}}
not_isolated_cores_online_expanded=${f:cpulist_online:${not_isolated_cores_expanded}}
not_isolated_cpumask=${f:cpulist2hex:${not_isolated_cores_expanded}}
no_balance_cores_expanded=${f:cpulist_unpack:${no_balance_cores}}
# Fail if isolated_cores contains CPUs which are not online
assert2=${f:assertion:isolated_cores contains online CPU(s):${isolated_cores_expanded}:${isolated_cores_online_expanded}}
[sysctl]
kernel.hung_task_timeout_secs = 600
kernel.nmi_watchdog = 0
vm.stat_interval = 10
kernel.timer_migration = 1
[sysfs]
/sys/bus/workqueue/devices/writeback/cpumask = ${not_isolated_cpumask}
/sys/devices/virtual/workqueue/cpumask = ${not_isolated_cpumask}
/sys/devices/system/machinecheck/machinecheck*/ignore_ce = 1
[systemd]
cpu_affinity=${not_isolated_cores_expanded}
[script]
priority=5
script=${i:PROFILE_DIR}/script.sh
[scheduler]
isolated_cores=${isolated_cores}
ps_blacklist=.*pmd.*;.*PMD.*;^DPDK;.*qemu-kvm.*
[bootloader]
priority=10
initrd_remove_dir=True
initrd_dst_img=tuned-initrd.img
initrd_add_dir=${tmpdir}
cmdline_cpu_part=+nohz=on nohz_full=${isolated_cores} rcu_nocbs=${isolated_cores} tuned.non_isolcpus=${not_isolated_cpumask} intel_pstate=disable nosoftlockup
此时,查看可使用的profile,已经增加了CPI分区的profile:
使用这个profile:
#tuned-adm profile cpu-partitioning
此外,我们还可以一次设置多个profile,如下所示:
更多相关文章
- Linux系统性能调优配置文件 : RHEL8学习系列1
- 紫枫术河 imx6 uboot的mtd分区总结(rootfs为ubi文件系统) imx6 ubo
- Shell编程案例:统计指定目录下指定文件大小的个数及总和
- 虚拟文件系统
- gdb core调试
- ramdisk配置、解压、创建rootfs、启动简单分析
- 超级详细|Linux系统下从0到1的玩法大全
- Linux命令cURL如何访问FTP服务器
- Linux crontab命令详解