Profils d'optimisation

Le daemon tuned permet de selectionner un profil pour optimiser les performances du système, il utilise udev pour surveiller les appareils connectés et ajuste les paramètres du système de façon statique et dynamique en fonction d’un profil sélectionné.

Tuned comporte plusieurs profils prédéfinis pour des cas d’utilisation courants : débit élevé, faible latence, économie d’énergie, etc.

Utilitaire tunned

Pour installer et activer tunned :

# dnf install tuned
# systemctl enable --now tuned

Pour vérifier son bon fonctionnement :

# systemctl is-enabled tuned
# systemctl is-active tuned

Tuned propose plusieurs profils prédéterminés pour l’économie d’énergie et l’amélioration des performances, par exemple : latence|debit stockage, Latence|debit réseau, performance VM, etc.

Tuned statique

Le daemon tuned applique les paramètres d’optimisation au démarrage d’un service (ou lors d’un changement de profil).
L’optimisation statique :

  • configure et applique les paramètres kernel prédéfinis
  • définit les paramètres (performances globales)

Tuned dynamique

Le daemon tuned surveille l’activité du système et ajuste les paramètres d’optimisation.
L’optimisation dynamique :

  • ajuste en continu l’optimisation en fonction de la charge du système

Activer le tuned dynamique

Par défault l’optimisation dynamique n’est pas activée, pour ce faire il faut modifier le fichier /etc/tuned/tuned-main.conf et modifier la variable dynamic_tuning à 1 :

# cat /etc/tuned/tuned-main.conf
[...]
# Dynamicaly tune devices, if disabled only static tuning will be used.
dynamic_tuning = 1

Profils d’optimisation de tuned

Les profils d’optimisation se trouve dans :

  • /usr/lib/tuned
  • /etc/tuned

Chaque profil possède un répertoire à son nom et son fichier de configuration tuned.conf :

# cat /usr/lib/tuned/mon-profil-users-VM/tuned.conf
#
# tuned configuration
#
[main]
summary=Optimize for running inside a VM for users
include=throughput-performance
[sysctl]

# 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 = 20

# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 50

Verifier que le profil fonctionne bien en fonction des critères du fichier de configuration :

# sysctl vm.dirty_ratio
vm.dirty_ratio = 20
# sysctl vm.swappiness
vm.swappiness = 50

Gestion des profils

Liste tous les profils avec tuned-adm list :

# tuned-adm list
total 16
drwxr-xr-x. 2 root root 24 Apr 17 14:31 accelerator-performance
drwxr-xr-x. 2 root root 24 Apr 17 14:31 balanced
drwxr-xr-x. 2 root root 24 Apr 17 14:31 desktop
-rw-r--r--. 1 root root 15113 Jul 21 2021 functions
drwxr-xr-x. 2 root root 24 Apr 17 14:31 hpc-compute
drwxr-xr-x. 2 root root 24 Apr 17 14:31 intel-sst
drwxr-xr-x. 2 root root 24 Apr 17 14:31 latency-performance
drwxr-xr-x. 2 root root 24 Apr 17 14:31 network-latency
drwxr-xr-x. 2 root root 24 Apr 17 14:31 network-throughput
drwxr-xr-x. 2 root root 24 Apr 17 14:31 optimize-serial-console
drwxr-xr-x. 2 root root 41 Apr 17 14:31 powersave
drwxr-xr-x. 2 root root 27 Apr 17 14:31 recommend.d
drwxr-xr-x. 2 root root 24 Apr 17 14:31 throughput-performance
drwxr-xr-x. 2 root root 24 Apr 17 14:31 virtual-guest
drwxr-xr-x. 2 root root 24 Apr 17 14:31 virtual-host

Connaitre le profil actuel avec tuned-adm active :

# tuned-adm active
Current active profile: virtual-guest

Informations sur un profil avec tuned-adm profile_info :

# tuned-adm profile_info hpc-compute
Profile name:
hpc-compute

Profile summary:
Optimize for HPC compute workloads

Profile description:
Configures virtual memory, CPU governors, and network settings for HPC compute workloads.

Appliquer un autre profil avec tuned-adm profile ::

# tuned-adm profile hpc-compute

Avoir une recommandation de profil pour le système avec tuned-adm recommend :

# tuned-adm recommend
virtual-guest

Désactiver tuned avec tuned-adm off ::

# tuned-adm off

/!\ Résumé des commandes

Commandes :

# tuned-adm list                  // lister tous les profils
# tuned-adm active // affiche le profil actuel
# tuned-adm profile_info <profil> // informations sur un profil
# tuned-adm profile <profil> // appliquer un profil
# tuned-adm recommend // avoir une recommandation de profil
# tuned-adm off // desactive tuned

// Installation et bon fonctionnement de tuned
# dnf install tuned
# systemctl enable --now tuned
# systemctl is-enabled tuned
# systemctl is-active tuned
# sysctl vm.swappiness // doit correspondre au fichier de profil

Fichiers :

/etc/tuned/tuned-main.conf    // dynamic_tuning = 1 pour avoir le tuned dynamique
/usr/lib/tuned // emplacement des profils d'optimisation
/etc/tuned // emplacement des profils d'optimisation

Paquets :

tuned

Cas pratiques

Ajustement des profils d’optimisation

Vérification de l’installation, de l’activation et de l’exécution du paquet tuned :

[aline@SERVER01 ~]$ dnf list tuned
[...]
Installed Packages
tuned.noarch 2.18.0-1.el9 @System
[aline@SERVER01 ~]$ systemctl is-enabled tuned
enabled
[aline@SERVER01 ~] systemctl is-active tuned
active

Listing des tunning disponibles. Le profil actif est virtual-guest :

[aline@SERVER01 ~]$ sudo tuned-adm list
Available profiles:
- accelerator-performance - Throughput performance based tuning with disabled higher latency STOP states
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
- hpc-compute - Optimize for HPC compute workloads
- intel-sst - Configure for Intel Speed Select Base Frequency
- 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
- optimize-serial-console - Optimize for serial console use.
- 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

Vérification des valeurs des paramètres vm.dirty_ratio et vm.swappiness dans le fichier de configuration /usr/lib/tuned/virtual-guest :

[aline@SERVER01 ~]$ cat /usr/lib/tuned/virtual-guest/tuned.conf
#
# tuned configuration
#

[main]
summary=Optimize for running inside a virtual guest
include=throughput-performance

[sysctl]
# 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 = 30

# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 30

Vérification de l’application des valeurs du profil d’optimisation sur le système :

[aline@SERVER01 ~]$ sysctl vm.dirty_ratio
vm.dirty_ratio = 30
[aline@SERVER01 ~]$ sysctl vm.swappiness
vm.swappiness = 30

Si on compare le le profil d’optimisation throughput-performance dans usr/lib/tuned/throughput-performance/tuned.conf la valeur des paramètres vm.dirty_ratio et vm.swappiness est différente :

[aline@SERVER01 ~]$ cat /usr/lib/tuned/throughput-performance/tuned.conf
#
# tuned configuration
#
[main]
summary=Broadly applicable tuning that provides excellent performance across a
variety of common server workloads
[...]

[sysctl]
# 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
[...]

Même si le profil actuel est virtual-guest, et que le paramètre vm.dirty_background_ratio n’a pas été défini pour lui, il hérite de la valeur vm.dirty_background_ratio du profil throughput-performance :

[aline@SERVER01 ~]$ sysctl vm.dirty_background_ratio
vm.dirty_background_ratio = 10

Changement du profil d’optimisation actuel par throughput-performance et vérification :

[aline@SERVER01 ~]$ sudo tuned-adm profile throughput-performance

Vérification :

[aline@SERVER01 ~]$ sudo tuned-adm active
Current active profile: throughput-performance

Vérification des valeurs des paramètres vm.dirty_ratio et vm.swappiness :

[aline@SERVER01 ~]$ sysctl vm.dirty_ratio
vm.dirty_ratio = 40
[aline@SERVER01 ~]$ sysctl vm.swappiness
vm.swappiness = 10

Remplacement du profil actuel par balanced :

[aline@SERVER02 ~]$ sudo tuned-adm profile balanced

Informations sur profil tuned actuel :

[aline@SERVER02 ~]$ sudo tuned-adm profile_info
Profile name:
balanced

Profile summary:
General non-specialized tuned profile
[...]

Documentation

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/chap-red_hat_enterprise_linux-performance_tuning_guide-tuned
MAN tuned(8)
MAN tuned.conf(5)
MAN tuned-main.conf(5)
MAN tuned-adm(1)

> Partager <