3.2. Performance Tuning with tuned and tuned-adm
The tuned tuning service can adapt the operating system to perform better under certain workloads by setting a tuning profile. The tuned-adm command-line tool allows users to switch between different tuning profiles.
tuned Profiles Overview
Several pre-defined profiles are included for common use cases, but tuned also enables you to define custom profiles, which can be either based on one of the pre-defined profiles, or defined from scratch. In Red Hat Enterprise Linux 7, the default profile is
throughput-performance
.
The profiles provided with tuned are divided into two categories: power-saving profiles, and performance-boosting profiles. The performance-boosting profiles include profiles focus on the following aspects:
- low latency for storage and network
- high throughput for storage and network
- virtual machine performance
- virtualization host performance
tuned Boot Loader plug-in
You can use the
tuned Bootloader plug-in
to add parameters to the kernel (boot or dracut) command line. Note that only the GRUB 2 boot loader is supported and a reboot is required to apply profile changes. For example, to add the quiet
parameter to a tuned profile, include the following lines in the tuned.conf
file:
[bootloader] cmdline=quietSwitching to another profile or manually stopping the tuned service removes the additional parameters. If you shut down or reboot the system, the kernel parameters persist in the
grub.cfg
file.
Environment Variables and Expanding tuned Built-In Functions
If you run
tuned-adm profile profile_name
and then grub2-mkconfig -o profile_path
after updating GRUB 2 configuration, you can use Bash environment variables, which are expanded after running grub2-mkconfig
. For example, the following environment variable is expanded to nfsroot=/root
:
[bootloader] cmdline="nfsroot=$HOME"
You can use
tuned
variables as an alternative to environment variables. In the following example, ${isolated_cores}
expands to 1,2
, so the kernel boots with the isolcpus=1,2
parameter:
[variables] isolated_cores=1,2 [bootloader] cmdline=isolcpus=${isolated_cores}
In the following example,
${non_isolated_cores}
expands to 0,3-5
, and the cpulist_invert
built-in function is called with the 0,3-5
arguments:
[variables] non_isolated_cores=0,3-5 [bootloader] cmdline=isolcpus=${f:cpulist_invert:${non_isolated_cores}}
The
cpulist_invert
function inverts the list of CPUs. For a 6-CPU machine, the inversion is 1,2
, and the kernel boots with the isolcpus=1,2
command-line parameter.
Using tuned environment variables reduces the amount of necessary typing. You can also use various built-in functions together with tuned variables. If the built-in functions do not satisfy your needs, you can create custom functions in Python and add them to tuned in the form of plug-ins. Variables and built-in functions are expanded at run time when the tuned profile is activated.
The variables can be specified in a separate file. You can, for example, add the following lines to
tuned.conf
:
[variables] include=/etc/tuned/my-variables.conf [bootloader] cmdline=isolcpus=${isolated_cores}If you add
isolated_cores=1,2
to the /etc/tuned/my-variables.conf
file, the kernel boots with the isolcpus=1,2
parameter.
Modifying Default System tuned Profiles
There are two ways of modifying the default system tuned profiles. You can either create a new tuned profile directory, or copy the directory of a system profile and edit the profile as needed.
Procedure 3.1. Creating a New Tuned Profile Directory
- In
/etc/tuned/
, create a new directory named the same as the profile you want to create:/etc/tuned/my_profile_name/
. - In the new directory, create a file named
tuned.conf
, and include the following lines at the top:[main] include=profile_name
- Include your profile modifications. For example, to use the settings from the
throughput-performance
profile with the value ofvm.swappiness
set to 5, instead of default 10, include the following lines:[main] include=throughput-performance [sysctl] vm.swappiness=5
- To activate the profile, run:
# tuned-adm profile my_profile_name
Creating a directory with a new
tuned.conf
file enables you to keep all your profile modifications after system tuned profiles are updated.
Alternatively, copy the directory with a system profile from
/user/lib/tuned/
to /etc/tuned/
. For example:
# cp -r /usr/lib/tuned/throughput-performance /etc/tuned
Then, edit the profile in
/etc/tuned
according to your needs. Note that if there are two profiles of the same name, the profile located in /etc/tuned/
is loaded. The disadvantage of this approach is that if a system profile is updated after a tuned
upgrade, the changes will not be reflected in the now-outdated modified version.
Resources
For more information, see Section A.4, “tuned” and Section A.5, “tuned-adm”. For detailed information on using tuned and tuned-adm, see the tuned(8) and tuned-adm(1) manual pages.