Tuning system performance

Tuning system performance

Insert image description here

Adjust tuning configuration files

Tuning the system

Administrators can adjust device settings to optimize system performance based on multiple use case workloads. The tuned daemon is tuned dynamically/statically using tuning profiles that reflect specific workload requirements.

Configure static tuning

The tuned daemon applies system settings when the service starts or when a new tuning profile is selected. Static tuning configures predefined kernel parameters in the configuration file that are applied by tuned at runtime.

Configure dynamic tuning

Tuned monitors system activity and adjusts settings based on changes in operating behavior.

[root@workstation ~]# yum install tuned -y

[root@workstation ~]# systemctl enable --now tuned
[root@workstation ~]# systemctl status tuned
● tuned.service - Dynamic System Tuning Daemon
   Loaded: loaded (/usr/lib/systemd/system/tuned.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-07-19 10:03:01 EDT; 1min 0s ago
     Docs: man:tuned(8)
           man:tuned.conf(5)
           man:tuned-adm(8)
 Main PID: 7507 (tuned)
   CGroup: /system.slice/tuned.service
           └─7507 /usr/bin/python2 -Es /usr/sbin/tuned -l -P

Jul 19 10:03:00 workstation systemd[1]: Starting Dynamic System Tuning Daemon...
Jul 19 10:03:01 workstation systemd[1]: Started Dynamic System Tuning Daemon.

Select a tuning profile

Tuned provides configuration files for:

  • Energy-efficient
  • Performance

Performance-enhancing configuration files:

  • Storage/network low latency
  • Storage/network high throughput
  • Virtual machine performance

tuned-adm is used to change tuned daemon settings.

#确定当前活动调优的配置文件
[root@workstation ~]# tuned-adm active
Current active profile: virtual-guest
#列出可用配置文件

[root@workstation ~]# tuned-adm list
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- hpc-compute                 - Optimize for HPC compute workloads
- 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

#切换活动配置文件为更符合系统调优要求的其他配置文件
[root@workstation ~]# tuned-adm profile throughput-performance
[root@workstation ~]# tuned-adm active
Current active profile: throughput-performance
#为系统推荐调优配置文件
[root@workstation ~]# tuned-adm recommend
virtual-guest
#回复当前配置文件所作设置更改


[root@workstation ~]# tuned-adm off
[root@workstation ~]# tuned-adm active
No current active profile.

Affect process progress

relative priority

Different processes have different importance. The process scheduler can be configured to use different scheduling policies for different processes. The scheduling policy for most processes running on conventional systems is called SCHED_OTHER.

Since not all processes are equally important, the priority can be set through policies called process nice values. For any process, it can be organized into 40 different levels of nice values.

Nice level values ​​range from -20 (highest) to 19 (lowest). By default, the process will inherit the nice level of the parent process, which is usually 0. The higher the nice level, the lower the priority.

Set nice level and permissions

Setting a lower nice level for a CPU-intensive process may have a negative impact on the performance of other processes running on the same system. Only the root user can lower the nice level.

Tasks: 101 total,   1 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   995896 total,   605916 free,   134648 used,   255332 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   678000 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
  7893 root      20   0  161880   2192   1556 R  0.7  0.2   0:00.11 top
  7703 root      20   0       0      0      0 S  0.3  0.0   0:02.34 kworker/0:0
     1 root      20   0  128152   6708   4176 S  0.0  0.7   0:01.66 systemd
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.20 ksoftirqd/0
     5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.42 kworker/u256:0

The top command can interactively view and manage processes. The default configuration displays two columns: nice level and priority. NI displays the nice value of the process, and PR displays the scheduling priority.

Show nice value


[root@workstation ~]# ps axo pid,comm,nice,cls --sort=-nice
   PID COMMAND          NI CLS
    32 khugepaged       19  TS
    31 ksmd              5  TS
     1 systemd           0  TS
     2 kthreadd          0  TS
     3 ksoftirqd/0       0  TS
     6 kworker/u256:0    0  TS
     7 migration/0       -  FF
     8 rcu_bh            0  TS
     9 rcu_sched         0  TS
    11 watchdog/0        -  FF
    13 kdevtmpfs         0  TS
    15 khungtaskd        0  TS

Start processes with different nice levels

#开启一个后台作业
[root@workstation ~]# sha1sum /dev/zero &
[1] 7897
#新进程nice值从0继承(shell进程ni值为0,是作业的父进程)
[root@workstation ~]# ps -o pid,comm,nice 7897
   PID COMMAND          NI
  7897 sha1sum           0

[root@workstation ~]# nice -n 15 top&
[1] 7940
#更改nice值
[root@workstation ~]# ps -o pid,comm,nice 7940
   PID COMMAND          NI
  7940 top              15
[root@workstation ~]# renice -n 19 7940
7940 (process ID) old priority 15, new priority 19

Guess you like

Origin blog.csdn.net/weixin_51882166/article/details/131867637