Chapter 2. Optimizing system performance with TuneD
Chapter 2. Optimising system performance with TuneD
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/monitoring_and_managing_system_status_and_performance/optimising-system-performance-with-tuned
Chapter 2. Optimising system performance with TuneD TuneD is a system tuning service designed to optimise system performance and power consumption by using predefined or custom profiles. It includes predefined profiles suited for different workloads, such as high throughput, low latency, and power saving.
2.1. TuneD profiles distributed with RHEL
Copy link During installation, TuneD automatically selects the most suitable profile based on the system type. For example, the throughput-performance is selected for compute nodes, virtual-guest is selected for virtual machines, and balanced is selected for general systems, ensuring optimal performance to the environment. Profiles are divided mainly into two categories:
power-saving profiles that reduce power consumption with minimal performance impact, and performance-boosting profiles that optimise system resources for improved speed and responsiveness. Following is the list of notable profiles distributed with RHEL to select based on the system load:
balanced It is the default power-saving profile and is intended to be a compromise between performance and power consumption. It uses auto-scaling and auto-tuning whenever possible. powersave It is a profile for maximum power saving performance and can throttle the performance to minimise the actual power consumption. It enables USB autosuspend, Wi-Fi power saving, and Aggressive Link Power Management (ALPM) power savings for SATA host adapters, and also schedules multi-core power savings for systems with a low wakeup rate and activates the ondemand governor. It enables AC97 audio power saving or, depending on your system, HDA-Intel power savings with a 10 seconds timeout. If your system contains a supported Radeon graphics card with enabled KMS, the profile configures it to automatic power saving. It changes the energy_performance_preference attribute to the powersave or power energy setting. It also changes the scaling_governor policy attribute to either the ondemand or powersave CPU governor.
Note In some cases, the balanced profile is more efficient than powersave. For tasks such as video transcoding, running at full power completes the job faster, allowing the machine to idle and switch to efficient power-saving modes sooner. Throttling the machine reduces power during the task but extends its duration, potentially increasing overall energy use. Thus, the balanced profile is often a better choice.
throughput-performance A server profile optimised for high throughput that disables power savings mechanisms and enables sysctl settings that improve the throughput performance of the disk and network IO. accelerator-performance A profile that contains the same tuning as the throughput-performance profile. Additionally, it locks the CPU to low C states so that the latency is less than 100us. This improves the performance of certain accelerators, such as GPUs. latency-performance A server profile optimised for low latency and disables power savings mechanisms and enables sysctl settings that improve latency. CPU governor is set to performance and the CPU is locked to the low C states (by PM QoS). network-latency A profile for low latency network tuning. It is based on the latency-performance profile. It additionally disables transparent huge pages and NUMA balancing, and tunes several other network-related sysctl parameters. hpc-compute A profile optimised for high-performance computing. It is based on the latency-performance profile. network-throughput A profile for throughput network tuning. It is based on the throughput-performance profile. It additionally increases kernel network buffers. virtual-guest A profile designed for Red Hat Enterprise Linux virtual machines and VMWare guests based on the throughput-performance profile that, among other tasks, decreases virtual memory swappiness and increases disk readahead values. It does not disable disk barriers. virtual-host A profile designed for virtual hosts based on the throughput-performance profile that, among other tasks, decreases virtual memory swappiness, increases disk readahead values, and enables a more aggressive value of dirty pages writeback. oracle A profile optimised for Oracle database loads based on the throughput-performance profile. It additionally disables transparent huge pages and modifies other performance-related kernel parameters. This profile is provided by the tuned-profiles-oracle package. desktop A profile optimised for desktops, based on the balanced profile. It additionally enables scheduler autogroups for better response of interactive applications. optimise-serial-console A profile that tunes down I/O activity to the serial console by reducing the printk value. This should make the serial console more responsive. This profile is intended to be used as an overlay on other profiles. For example:
tuned-adm profile throughput-performance optimise-serial-console
mssql A profile provided for Microsoft SQL Server. It is based on the throughput-performance profile. intel-sst A profile optimised for systems with user-defined Intel Speed Select Technology configurations. This profile is intended to be used as an overlay on other profiles. For example:
tuned-adm profile cpu-partitioning intel-sst
aws A profile optimised for AWS EC2 instances. It is based on the throughput-performance profile.
For more information about these profiles, see the tuned-profiles man page on your system.
2.2. Real-time TuneD profiles distributed with RHEL
RHEL ships some profiles specifically for systems running the real-time kernel. Without a special kernel build, they do not configure the system to be real-time. On RHEL, the profiles are available with additional repositories.
realtime Use on bare metal real-time systems. This is provided by the tuned-profiles-realtime package, which is available from the RT or NFV repositories. realtime-virtual-host Use in a virtualisation host configured for real-time. This is provided by the tuned-profiles-nfv-host package, which is available from the NFV repository. realtime-virtual-guest Use in a virtualisation guest configured for real-time. This is provided by the tuned-profiles-nfv-guest package, which is available from the NFV repository. 2.3. Installing and enabling TuneD
As a system administrator, you can use the TuneD daemon to optimise the performance profile of your system for a variety of use cases. You must install and enable TuneD to start using it.
After installation, the /usr/lib/tuned/profiles directory stores distribution-specific profiles. Each profile is stored in its own subdirectory. The profile includes the profile configuration file, named tuned.conf and optionally other files, such as helper scripts. Also, to customise a profile, copy the profile directory into /etc/tuned/profiles, which stores the files related to the custom profiles. In cases where profiles with the same name exist, the custom profile located in /etc/tuned/profiles takes precedence.
Prerequisites
You have administrative privileges. Procedure
Install the TuneD package:
dnf install tuned
Enable and start the TuneD service:
systemctl enable –now tuned
Optional: Install TuneD profiles for real-time systems:
For the TuneD profiles for real-time systems enable the rhel-10 repository.
subscription-manager repos –enable=rhel-10-for-x86_64-nfv-beta-rpms
dnf install tuned-profiles-realtime tuned-profiles-nfv
Verification
Verify that the profile is active and applied:
$ tuned-adm active Current active profile: throughput-performance $ tuned-adm verify Verification succeeded, current system settings match the preset profile. See tuned log file (‘/var/log/tuned/tuned.log’) for details. Show more
2.4. Managing TuneD profiles
You can manage TuneD profiles in your Red Hat Enterprise Linux system, including listing available profiles, setting a specific profile, and disabling TuneD when necessary. Proper management of profiles optimizes system performance for specific workloads, such as using the cpu-partitioning profile for low-latency applications.
Prerequisites
You have installed and enabled TuneD. You have administrative privileges. Procedure
List all the available predefined TuneD profiles:
$ tuned-adm list
Optional: To let TuneD recommend the most suitable profile for your system, use the following command:
tuned-adm recommend
throughput-performance
Activate the profile:
tuned-adm profile selected-profile
Alternatively, you can activate a combination of multiple profiles:
tuned-adm profile selected-profile1 selected-profile2
View the current active TuneD profile on your system:
tuned-adm active
Current active profile: selected-profile
Disable all tunings temporarily:
tuned-adm off
The tunings are applied again after the TuneD service restarts.
Optional: Stop and disable the TuneD service permanently:
systemctl disable –now tuned
2.5. Profile inheritance and variables for profile customisation
TuneD supports profile inheritance, variable usage, and built-in functions to create new or modify existing profiles efficiently.
The pre-installed and custom profiles are available in the following directories:
Pre-installed profiles: Located in /usr/lib/tuned/profiles/ Custom profiles: Created in /etc/tuned/profiles/
Profile Inheritance TuneD profiles can inherit settings from other profiles by using the include option in the [main] section. Profile inheritance means a child profile inherits all settings from its parent but can override or add new parameters based on the custom requirements. For example, to create a profile based on the balanced profile, which additionally sets ALPM to the min_power instead of the medium_power, which is originally set by the balanced profile, use:
[main] include=balanced
[scsi_host] alpm=min_power Show more
Variables’ usage while customising profiles You can define variables while customising profiles. Variables help to simplify configurations by reducing repetitive definitions. You can define your own variables by creating the [variables] section in a profile and by using:
[variables] variable_name=value
To expand the value of a variable in a profile, use:
${variable_name}
You can also store the variables in different files and use these variables while customising profiles by adding the filepath to the variable file. For example, you can add the following lines to configuration file to consider variables from the separate file:
tuned.conf: [variables] include=/etc/tuned/my-variables.conf
[bootloader] cmdline=isolcpus=${isolated_cores} Show more
Where isolated_cores=1,2 is added in my-variable.conf file as follows:
my-variable.conf: isolated_cores=1,2
2.6. Built-in functions for profile customisation
You can use the built-in functions in TuneD profiles to dynamically expand at runtime when a profile is activated. Use built-in functions with TuneD variables to modify and process values dynamically within a profile. Additionally, you can extend TuneD with custom functions by creating and integrating custom Python functions as plugins.
Syntax to start a built-in function ${f:function_name:argument_1:argument_2}
Also, to retrieve the directory path where the profile and the tuned.conf file are located, use the PROFILE_DIR variable, which requires the following syntax:
${i:PROFILE_DIR}
Example of isolating CPU cores by using a built-in function [variables] non_isolated_cores=0,3-5
[bootloader] cmdline=isolcpus=${f:cpulist_invert:${non_isolated_cores}} Show more
In this example, the ${non_isolated_cores} variable expands to 0,3-5. The cpulist_invert function inverts the CPU list. On a system with 6 CPUs, 0,3-5 inverts to 1,2, resulting in the kernel booting with the isolcpus=1,2 option.
Expand Table 2.1. Available built-in functions: Function name Description assertion
Compare two arguments. If they do not match, the function logs text from the first argument and aborts profile loading.
assertion_non_equal
Compare two arguments. If they match, the function logs text from the first argument and aborts profile loading.
calc_isolated_cores
Calculates and returns isolated cores. The argument specifies how many cores per socket to reserve for housekeeping. If not specified, one core per socket is reserved for housekeeping and the rest are isolated.
check_net_queue_count
Checks whether the user has specified a queue count for net devices. If not, it returns the number of housekeeping CPUs.
cpuinfo_check
Checks regular expressions against /proc/cpuinfo. Accepts arguments in the form: REGEX1, STR1, REGEX2, STR2, …[, STR_FALLBACK]. If REGEX1 matches something in /proc/cpuinfo, it expands to STR1; if REGEX2 matches, it expands to STR2. It stops on the first match. If no regular expression matches, it expands to STR_FALLBACK or an empty string if no fallback is provided.
cpulist2devs
Converts a CPU list to device strings.
cpulist2hex
Converts a CPU list to a hexadecimal CPU mask.
cpulist2hex_invert
Converts a CPU list to a hexadecimal CPU mask and inverts it.
cpulist_invert
Inverts a list of CPUs to make its complement. For example, on a system with 4 CPUs (0-3), the inversion of the list 0,2,3 is 1.
cpulist_online
Checks whether the CPUs from the list are online. Returns the list containing only online CPUs.
cpulist_pack
Packs a CPU list in the form of 1,2,3,5 to 1-3,5.
cpulist_present
Checks whether the CPUs from the list are present. Returns the list containing only present CPUs.
cpulist_unpack
Unpacks a CPU list in the form of 1-3,4 to 1,2,3,4.
exec
Executes a process and returns its output.
hex2cpulist
Converts a hexadecimal CPU mask to a CPU list.
intel_recommended_pstate
Checks the processor code name and returns the recommended intel_pstate CPUFreq driver mode. “Active” is returned for newer generation processors not in the PROCESSOR_NAME list.
iscpu_check
Checks regular expressions against the output of iscpu. Accepts arguments in the form: REGEX1, STR1, REGEX2, STR2, …[, STR_FALLBACK]. If REGEX1 matches something in the output, it expands to STR1; if REGEX2 matches, it expands to STR2. It stops on the first match. If no regular expression matches, it expands to STR_FALLBACK or an empty string if no fallback is provided.
package2cpus
Provides a CPU device list for a package (socket).
package2uncores
Provides an uncore device list for a package (socket).
regex_search_ternary
Ternary regular expression operator. Takes arguments in the form: STR1, REGEX, STR2, STR3. If REGEX matches STR1 (re.search is used), STR2 is returned; otherwise, STR3 is returned.
log
Expands to the concatenation of arguments and logs the result, useful for debugging.
kb2s
Converts KB to disk sectors.
s2kb
Converts disk sectors to KB.
strip
Creates a string from all passed arguments and deletes both leading and trailing white spaces.
virt_check
Checks whether TuneD is running inside a virtual machine (VM) or on bare metal. Inside a VM, the function returns the first argument. On bare metal, the function returns the second argument, even in case of an error.
Show more 2.7. TuneD plugins
TuneD profiles use plugins to monitor or optimise different devices on the system. TuneD uses two types of plugins:
Monitoring plugins
Used for gathering system data such as, CPU load, disk I/O, and network traffic. The output of the monitoring plugins can be used by tuning plugins for dynamic tuning. Monitoring plugins are automatically instantiated whenever their metrics are needed by any of the enabled tuning plugins. The available monitoring plugins are:
disk
Gets disk load (number of IO operations) per device and measurement interval.
net
Gets network load (number of transferred packets) per network card and measurement interval.
load
Gets CPU load per CPU and measurement interval.
Tuning plugins
Each tuning plugin tunes an individual subsystem and takes several parameters that are populated from the TuneD profiles. Each subsystem can have multiple devices, such as multiple CPUs or network cards, handled by individual instances of the tuning plugins. Specific settings for individual devices are also supported. The available tuning plugins are:
acpi
Configures the ACPI driver. Use the platform_profile option to set the ACPI platform profile sysfs attribute. It is a generic power/performance preference API for other drivers. Multiple profiles can be specified, separated by |. The first available profile is selected.
audio
Sets the autosuspend timeout for audio codecs to the value specified by the timeout option. Currently, the snd_hda_intel and snd_ac97_codec codecs are supported. The value 0 means that autosuspend is disabled. You can also enforce the controller reset by setting the Boolean option reset_controller to true.
bootloader
Adds options to the kernel command line. This plugin supports only the GRUB boot loader. Customised non-standard location of the GRUB configuration file can be specified by the grub2_cfg_file option. The kernel options are added to the current GRUB configuration and its templates. The system needs to be rebooted for the kernel options to take effect.
cpu
Manages CPU governor and power settings by setting the CPU governor to the value specified by the governor option and dynamically changing the Power Management Quality of Service (PM QoS) CPU Direct Memory Access (DMA) latency according to the CPU load.
disk
Manages disk settings such as apm, scheduler_quantum, readahead, readahead_multiply, spindown.
eeepc_she
Dynamically sets the front-side bus (FSB) speed according to the CPU load.
irq
Handles individual interrupt requests (IRQ) as devices and multiple plugin instances can be defined, each addressing different devices or irqs. The device names used by the plugin are irq
Optimising CPU Scheduling with the TuneD Scheduler Plugin (Red Hat Knowledgebase) 2.8. Creating a new TuneD profile
You can create a new TuneD profile to customise your requirements for performance optimisation.
Prerequisites
The TuneD service is running. See Installing and Enabling TuneD for details. Procedure
In the /etc/tuned/profiles directory, create a new directory named the same as the profile that you want to create:
mkdir /etc/tuned/profiles/my-profile
In the new directory, create a file named tuned.conf. Edit the file and add a [main] section and plug in definitions in it, according to your requirements. For example, see the configuration of the balanced profile:
[main] summary=General non-specialised TuneD profile
[cpu] governor=conservative energy_perf_bias=normal
[audio] timeout=10
[video] radeon_powersave=dpm-balanced, auto
[scsi_host] alpm=medium_power Show more
Activate the profile.
tuned-adm profile my-profile
Verification
View the profile is active and applied:
$ tuned-adm active Current active profile: my-profile $ tuned-adm verify Verification succeeded, current system settings match the preset profile. See tuned log file (‘/var/log/tuned/tuned.log’) for details. Show more
2.9. Modifying an existing TuneD profile
You can modify the parameters of an existing profile to suit your custom requirements. A modified child profile can be created based on an existing TuneD profile.
Prerequisites
The TuneD service is running. See Installing and enabling TuneD for details. Procedure
In the /etc/tuned/profiles directory, create a new directory named the same as the profile that you want to create:
mkdir /etc/tuned/profiles/modified-profile
In the new directory, create a file named tuned.conf, and set the [main] section as follows:
[main] include=parent-profile
Replace parent-profile with the name of the profile you are modifying, for example: throughput-performance
Include your profile modifications. For example, to lower swappiness in the throughput-performance profile, change the value of vm.swappiness to 5, instead of the default 10, use:
[main] include=throughput-performance
[sysctl] vm.swappiness=5 Show more
Activate the profile.
tuned-adm profile modified-profile
Verification
View the profile is active and applied:
$ tuned-adm active Current active profile: modified-profile $ tuned-adm verify Verification succeeded, current system settings match the preset profile. See tuned log file (‘/var/log/tuned/tuned.log’) for details. Show more
2.10. Enabling TuneD no-daemon mode
TuneD can be run in no-daemon mode, which does not require any resident memory. In this mode, TuneD applies the settings and then exits. However, note that this mode disables certain features, including D-Bus support, hot plug support, and rollback functionality for settings.
Prerequisites
You have root privileges or appropriate permissions to modify the system configuration. Procedure
Edit the /etc/tuned/tuned-main.conf file with the following changes:
sudo vi /etc/tuned/tuned-main.conf daemon = 0
Save and close the file. Restart the tuned service or reapply or switch profile:
systemctl restart tuned
tuned-adm profile
Verify the tuned status:
tuned-adm active
It seems that tuned daemon is not running, preset profile is not activated.
Preset profile: