Let's talk about TuneD.
Now, what is TuneD all about?
It's about system tuning and optimization.
In the PROC SYS directory, in the PROC pseudo file system,
there's a lot of tunables.
And different files in this directory
contain the current setting as its value.
You can change the current value by echoing
a new value into the file.
For instance, there is a swappiness file.
Use CAT to have a look at it.
And if you want to change it, use echo 40
and use output redirection to make the change.
This is the only way how it works,
because this file can't be opened with an editor.
Now, if you want to make the settings persistent,
you write them to a file in etc sysctl.d.
So create a file with the name swappiness.conf
and give it the value vmswappiness is 40
to make it persistent.
Now, using the PROC pseudo file system is one way,
but it requires a lot of expertise.
And that is why there's TuneD.
It was introduced to make tuning easier.
TuneD is a system D service that works at different profiles.
You can use TuneD ADM list to show the current profiles.
And these profiles have names that
correspond to specific workloads.
For instance, there's a profile with the name virtual guest.
If you're in a virtualization guest,
well, you can use TuneD ADM profile virtual guest
to set this profile as the default.
Each profile contains a file with the name TuneD.conf.
And that has a wide range of performance-related settings.
Now, when you are using TuneD, you
should wonder where you want to manage your tuning information.
Is TuneD going to be the main source?
Or do you want sysctl and the tunables
in the PROC pseudo file system?
Well, that is decided by using reapply sysctl is one.
In etc TuneD, TuneD main.conf.
And if you set it to one, that means
that sysctl will win in case of conflict.
If you set it to zero, it means that TuneD
will win in case of conflict.
Now, when using TuneD, there's a couple of default profiles.
You can also create custom profiles.
Just store them in a directory in etc TuneD.
In this directory, create a subdirectory
with a specific name.
And in this subdirectory, create TuneD.conf
that contains the requested performance settings.
And you will notice that TuneD is automatically
picking it up.
Let me demonstrate how you can work with TuneD.
Here on the slide, you have part one of the demo.
Let me guide you through it and explain what is going on.
So let me start with DNF install minus y TuneD.
Why do I do that?
Well, I'm on a graphical system where lots of packages
have already been installed on the exam.
That's not so sure, so you might have to install the RPM
package as well.
And let me use systemctl enable minus minus now TuneD
to make sure that the systemd TuneD service is actually
running.
And then we can use TuneD ADM list.
This is listing all the different profiles.
And you can see that the current active profile is balanced.
So this balance, that has been a selection
that is made while installing this virtual machine based
on different properties that were detected.
You can use TuneD ADM recommend to ask your system
if any better option is available.
And look at that.
The system thinks that a virtual guest
would be a better option.
Well, I'm not going for virtual guest.
I'm going for the custom profile here.
But if you wanted to use virtual guest,
TuneD ADM profile virtual guest would set virtual guest
as the default. Now, I would like
to configure a tweak for the proc pseudo file system.
So I'm using echo vm.swappiness.
It's 33.
And I'm writing it to etc sysctl.d slash swappiness.conf.
In case you are wondering, what is this doing?
Well, the swappiness parameter determines
what your system is going to do if it's running out of memory.
If you have a value that is close to 0,
then it is going to drop inactive cache.
If you have a value that is close to its maximum, which
is 200, then it will favor moving inactive application
memory to swap.
So here, I've set the value pretty low.
And I write it to the configuration file.
And now, I need to activate it using sysctl minus b etc
sysctl.d swappiness.conf.
And there, we can see vm.swappiness is 33.
If I would use sysctl minus a, first,
a wc minus l just to give you an impression of how many
parameters are available.
1,068.
But if I grab on Swappy, then I can
see that the current value is set to 33.
So now, I want to create my own profile.
So I'm using mkdir etc tune-d profiles with an s, that is.
And I'm calling it my profile.
And then, I'm going to use cat greater than, greater than,
etc tune-d profiles, my profile.
And I'm calling the file tune-d.conf.
That is mandatory.
Smaller than, smaller than EOF, that's
the end of file indicator, meaning
that I'm opening an interactive prompt right now.
Anything I type in this prompt will be written to the file
until it encounters the EOF.
So I'm using sysctl, which is the header that is required.
And then, I'm using vm.swappiness.
And I'm setting it to 66.
And then, I write my changes by using the EOF.
And now, if I would check the contents,
so let's modify this previous command a little bit
so that we can get and verify that the file has
been written correctly.
OK, part two of the demo.
Let me show you what's on the slide before doing the demo
so that you can try it for yourself if you want to.
So I'm using tune-d ADM list.
And tune-d ADM list, without restarting anything,
has picked up my profile.
So that's good.
And now, I'm using tune-d ADM profile, my profile.
And that will activate my profile.
Tune-d ADM list is going to verify that.
On the last line, you can see current active profile
is my profile.
And now, the big question is, what
has happened to this swappiness parameter?
Well, let's check it.
sysctl minus a grab swap is showing that swappiness is 33.
Why is that?
Well, that is because of the setting in etc tune-d,
tune-d main.conf, where we have reapply sysctl is 1.
And reapply sysctl is 1 means that sysctl will always win.
And that is because, in most cases,
sysctl is created by an expert.
And tune-d is created by a local dude.
And the concept and the idea is that the expert should win.
If you don't like that, well, you just
use reapply sysctl, set it to 0, restart your tune-d process,
and tune-d will win.