Chapter 2. Optimizing system performance with TuneD
TuneD is a system tuning service designed to optimize 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 linkLink copied to clipboard!
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 for virtual machines, and balanced for general systems. This ensures optimal performance for 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 optimize 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.
powersaveIt is a profile for maximum power saving performance and can throttle the performance to minimize the actual power consumption. It enables USB autosuspend, Wi-Fi power saving, and Aggressive Link Power Management (ALPM) power savings for SATA host adapters. It also schedules multi-core power savings for systems with a low wakeup rate and activates the
ondemandgovernor. 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 theenergy_performance_preferenceattribute to thepowersaveorpower energysetting. It also changes thescaling_governorpolicy attribute to either theondemandorpowersaveCPU governor.NoteIn some cases, the balanced profile is more efficient than powersave. For tasks such as video transcoding, running at full power completes the job faster. It also enables the system to enter an idle state 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 optimized for high throughput that disables power savings mechanisms. It also enables
sysctlsettings to improve the throughput performance of the disk and network IO. accelerator-performance-
A profile that contains the same tuning as the
throughput-performanceprofile. 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 optimized for low latency and disables power savings mechanisms and enables
sysctlsettings 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-performanceprofile. It additionally disables transparent huge pages and NUMA balancing, and tunes several other network-related sysctl parameters. hpc-compute-
A profile optimized for high-performance computing. It is based on the
latency-performanceprofile. network-throughput-
A profile for throughput network tuning. It is based on the
throughput-performanceprofile. 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-performanceprofile. Among other tasks, it 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-performanceprofile. Among other tasks, it decreases virtual memory swappiness, increases disk readahead values, and enables a more aggressive value of dirty pages writeback. oracle-
A profile optimized for Oracle database loads based on the
throughput-performanceprofile. 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 optimized for desktops, based on the
balancedprofile. It additionally enables scheduler autogroups for better response of interactive applications. optimize-serial-consoleA 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 optimize-serial-consolemssql-
A profile provided for Microsoft SQL Server. It is based on the
throughput-performanceprofile. intel-sstA profile optimized 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-sstawsA profile optimized for AWS EC2 instances. It is based on the
throughput-performanceprofile.For more information about these profiles, see the
tuned-profilesman page on your system.
2.2. Real-time TuneD profiles distributed with RHEL Copy linkLink copied to clipboard!
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-realtimepackage, which is available from the RT or NFV repositories. realtime-virtual-host-
Use in a virtualization host configured for real-time. This is provided by the
tuned-profiles-nfv-hostpackage, which is available from the NFV repository. realtime-virtual-guest-
Use in a virtualization guest configured for real-time. This is provided by the
tuned-profiles-nfv-guestpackage, which is available from the NFV repository.
2.3. Installing and enabling TuneD Copy linkLink copied to clipboard!
As a system administrator, use TuneD to optimize the performance profile 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 customize 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 tunedEnable and start the TuneD service:
# systemctl enable --now tunedOptional: Install TuneD profiles for real-time systems:
For the TuneD profiles for real-time systems enable the
rhel-10repository.# subscription-manager repos --enable=rhel-10-for-x86_64-nfv-beta-rpms# dnf install tuned-profiles-realtime tuned-profiles-nfv
Verification
Check the activation status of the profile:
$ tuned-adm activeCurrent active profile: throughput-performanceCheck if the profile is active and applied:
$ tuned-adm verifyVerification succeeded, current system settings match the preset profile. See tuned log file ('/var/log/tuned/tuned.log') for details.
2.4. Managing TuneD profiles Copy linkLink copied to clipboard!
You can manage TuneD profiles in Red Hat Enterprise Linux, 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 listOptional: To let TuneD recommend the most suitable profile for your system, use the following command:
# tuned-adm recommendthroughput-performanceActivate the profile:
# tuned-adm profile selected-profileAlternatively, you can activate a combination of multiple profiles:
# tuned-adm profile selected-profile1 selected-profile2View the current active TuneD profile on your system:
# tuned-adm activeCurrent active profile: selected-profileDisable all tunings temporarily:
# tuned-adm offThe 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 customization Copy linkLink copied to clipboard!
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 Child profiles inherit parent settings, but can override or add parameters for custom requirements. For example, to create a profile based on the balanced profile that additionally sets ALPM to
min_powerinstead ofmedium_power, use:[main] include=balanced [scsi_host] alpm=min_power- Variables’ usage while customizing profiles
You can define variables while customizing profiles. Variables help to simplify configurations by reducing repetitive definitions. Define your own variables by creating the
[variables]section in a profile and by using:[variables] variable_name=valueTo expand the value of a variable in a profile, use:
${variable_name}Store the variables in different files and use these variables while customizing profiles by adding the filepath to the variable file. For example, add the following lines to the configuration file to consider variables from the separate file:
tuned.conf: [variables] include=/etc/tuned/my-variables.conf [bootloader] cmdline=isolcpus=${isolated_cores}Where
isolated_cores=1,2is added in my-variable.conf file as follows:
my-variable.conf: isolated_cores=1,2
2.6. Built-in functions for profile customization Copy linkLink copied to clipboard!
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.
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}To retrieve the directory path where the profile and the
tuned.conffile are located, use thePROFILE_DIRvariable. It uses 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}}In this example, the
${non_isolated_cores}variable expands to0,3-5. Thecpulist_invertfunction inverts the CPU list. On a system with 6 CPUs,0,3-5inverts to1,2, resulting in the kernel booting with theisolcpus=1,2option.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 cancels profile loading.
assertion_non_equal
Compare two arguments. If they match, the function logs text from the first argument and cancels 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_pstateCPUFreq driver mode. "Active" is returned for newer generation processors not in thePROCESSOR_NAMElist.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 toSTR_FALLBACKor 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.searchis 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.
2.7. TuneD plugins Copy linkLink copied to clipboard!
TuneD profiles use plugins to monitor or optimize 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_profileoption to set the ACPI platform profilesysfsattribute. It is a genericpower/performancepreference 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_intelandsnd_ac97_codeccodecs are supported. The value 0 means that autosuspend is disabled. You can also enforce the controller reset by setting the Boolean option reset_controller totrue. bootloader-
Adds options to the kernel command line. This plugin supports only the GRUB boot loader. Customized non-standard location of the GRUB configuration file can be specified by the
grub2_cfg_fileoption. 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
governoroption. It dynamically changes 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<n>, where<n>is the IRQ number. The special deviceDEFAULTcontrols values written to/proc/irq/default_smp_affinity, which applies to all non-active IRQs. irqbalance-
Manages settings for
irqbalance. The plugin configures CPUs which should be skipped when rebalancing IRQs in/etc/sysconfig/irqbalance. It then restarts irqbalance only if it was previously running. modules-
Applies custom kernel modules options. It can set parameters to kernel modules and creates
/etc/modprobe.d/tuned.conffile. The syntax ismodule=option1=value1 option2=value2…wheremoduleis the module name andoptionx=valuexare module options which might be present. mounts- Enables or disables barriers for mounted filesystems.
net- Configures Wake-on-LAN and interface speed by using the same syntax as the ethtool utility. Also, dynamically changes the interface speed according to the interface utilization.
rtentsk- Avoids inter-processor interruptions caused by enabling or disabling static keys. It has no options. When included, TuneD keeps an open socket with timestamping enabled, thus keeping the static key enabled.
selinux-
Tunes SELinux options. SELinux decisions, such as allowing or denying access, are cached. This cache is known as the Access Vector Cache (AVC). When using these cached decisions, SELinux policy rules need to be checked less, which increases performance. The
avc_cache_thresholdoption adjusts the maximum number of AVC entries. systemd-
Tunes systemd options. The
cpu_affinityoption sets CPU affinity in/etc/systemd/system.conf. This configures the CPU affinity for the service manager and the default CPU affinity for all forked off processes. Add a comma-separated list of CPUs with optional CPU ranges specified by the minus sign (-). scsi_host-
Tunes SCSI host settings (for example,
ALPM). scheduler- Offers a variety of options for the tuning of scheduling priorities, CPU core isolation, and process, thread, and IRQ affinities.
script- Runs external script or binary when loading or unloading a profile.
service- Handles various sysvinit, sysv-rc, openrc, and systemd services specified by the plugin options. Supported service handling commands are start, stop, enable, and disable.
sysctl-
Modifies kernel parameters. Use this plugin only if you want to change system settings that are not covered by other plugins available in TuneD. The syntax is name=value, where name is the same as the name provided by the
sysctlutility. sysfs-
Sets various
sysfssettings specified by the plugin options. The syntax is name=value, where name is thesysfspath to use. usb-
Adjusts USB autosuspend timeout. The value
0means that autosuspend is disabled. uncore-
Limits the maximum and minimum uncore frequency. The options
max_freq_khz,min_freq_khzcorrespond tosysfsfiles exposed by Intel uncore frequency driver. Their values can be specified in kHz or as a percentage of their configurable range. video-
Sets various powersave levels on video cards. Currently, only the
Radeoncards are supported. Thepowersavelevel can be specified by using theradeon_powersaveoption. Supported values are, default, auto, low, mid, high, dynpm, dpm-battery, dpm-balanced, and dpm-perfomance. vm-
Enables or disables transparent huge pages. Valid values for the transparent_hugepages option are:
always, never, madvise.
2.8. Creating a new TuneD profile Copy linkLink copied to clipboard!
You can create a new TuneD profile to customize your requirements for performance optimization.
Prerequisites
- The TuneD service is running. See Installing and enabling TuneD for details.
Procedure
In the
/etc/tuned/profilesdirectory, 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 thebalancedprofile:[main] summary=General non-specialized TuneD profile [cpu] governor=conservative energy_perf_bias=normal [audio] timeout=10 [video] radeon_powersave=dpm-balanced, auto [scsi_host] alpm=medium_powerActivate the profile.
# tuned-adm profile my-profile
Verification
View the profile is active and applied:
$ tuned-adm activeCurrent active profile: my-profile$ tuned-adm verifyVerification succeeded, current system settings match the preset profile. See tuned log file ('/var/log/tuned/tuned.log') for details.
2.9. Modifying an existing TuneD profile Copy linkLink copied to clipboard!
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/profilesdirectory, create a new directory named the same as the profile that you want to create:# mkdir /etc/tuned/profiles/modified-profileIn the new directory, create a file named
tuned.conf, and set the [main] section as follows:[main] include=parent-profileReplace parent-profile with the name of the profile you are modifying, for example:
throughput-performanceInclude your profile modifications. For example, to lower swappiness in the
throughput-performanceprofile, change the value ofvm.swappinessto5, instead of the default10, use:[main] include=throughput-performance [sysctl] vm.swappiness=5Activate the profile.
# tuned-adm profile modified-profile
Verification
View the profile is active and applied:
$ tuned-adm activeCurrent active profile: modified-profile$ tuned-adm verifyVerification succeeded, current system settings match the preset profile. See tuned log file ('/var/log/tuned/tuned.log') for details.
2.10. Enabling TuneD no-daemon mode Copy linkLink copied to clipboard!
You can run TuneD 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 and 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.conffile with the following changes:sudo vi /etc/tuned/tuned-main.confdaemon = 0- Save and close the file.
Restart the tuned service or reapply or switch profile:
# systemctl restart tuned# tuned-adm profile <tuned_profile>Verify the tuned status:
# tuned-adm activeIt seems that tuned daemon is not running, preset profile is not activated. Preset profile: <tuned_profile>