Episode: 3322
Title: HPR3322: Tune system performance with tuned
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3322/hpr3322.mp3
Transcribed: 2025-10-24 20:48:05

---

This is Hacker Public Radio Episode 33242z, the 27th of April 2021.
Today's show is entitled, Tune System Performance with Tune.
It is hosted by Clot 2 and is about 23 minutes long and carries a clean flag.
The summary is, Introduction to Tune and Tune Addin.
This episode of HPR is brought to you by archive.org.
Support universal access to all knowledge by heading over to archive.org forward slash donate.
Hey everybody, you're listening to Hacker Public Radio, my name is Clot 2 and I want to talk about
system performance with Tune D. But first, let's talk about just system performance.
Um, quite a while ago now, I had a laptop and I actually I think I've had many laptops in my
in my life and quite a while ago now I had at least one laptop that I have in my mind,
whereby I wanted to get an alert of a low battery sooner than when I was getting the alert or
something like that. There was something about monitoring power consumption or something.
And so I sat down and wrote a little shell script that would fire off every now and again to
essentially probe slash proc slash whatever slash whatever slash whatever slash battery or whatever
the AKP slash that slash whatever. And so I did that and got that more or less working on a
reliable basis. And that that was good for a while. And then later on, I thought, well,
wouldn't wouldn't be neat if if I detected that the battery was in a discharging state,
I could then tell it to do something different. You know, I don't remember what it was. I think it
was something about audio audio or real-time permissions or something like that. And so I I worked
on the little shell script to catch the battery state and then to adjust accordingly and so on.
I don't know that I ever got it really working well. And and that shell script is long gone now
that it was it was not even good enough for me to transfer to, you know, whatever replacement laptop
I ended up with. So after that one was was gone. So it wasn't it wasn't great. And but in the
back of my head, I've always kind of meant to kind of go back to that sort of not that project
specifically, but sort of to that issue of really just having an awareness. An easy way to be
aware of how of how a computer is set for sort of the for its for its idle running state
with the with the desire to know that I could quickly make adjustments to especially a laptop
based on what I want to be doing with it. And the trick there is I think that any automated
detection of of what a computer appears to be doing is likely to assume what it kind of has
to assume some set of of parameters that you want set. And and sort of the the problem is that
we're humans and we're not always rational. We always we don't always make sense. So for
instance, maybe I am on battery power. So the assumption would probably be by a computer that
it should scale down. It should it should limit certain activities and kind of use use fewer
resources than when it is using wind plugged into power. And generally speaking, like probably
at a seven out of 10 times, that's a logical and safe assumption to make. And yet one one out of
those 10 times, I'm doing something I'm playing a game or I'm making music. And I need that performance
to be way up there as if though it was plugged into power. And it doesn't matter that I'm on battery
power. I just I want to be able to use my four hour battery, let's say at a rate of, you know,
of I want to use all that power within one hour because I want really, really great performance.
And I don't care how that affects my battery life. Whereas other times, maybe I'm just typing
away and not really doing a whole lot that's that that's intensive. And so I would want it to
scale down and to conserve as much battery power as possible. So that's always been kind of something
that I've I've wanted to have access to turns out that there is a project now that is working
towards making that I don't want to say making it possible because obviously it's possible. But yeah,
it's making it easy to making it something that that a human can interact with reliably and
easily. Now the project it's not it it isn't exactly where I think where I imagine it will
it will eventually be. And certainly if you look at their bug reporting their their bug tickets,
their issues on their project, you'll you'll see that I think that they are they are headed.
They have a trajectory to some really, really exciting things. And they're just not they're not
quite there yet. But it's still a very, very useful little project. It is called tune D. That's
like tune demon. And that that's tune, not tune, but tune D. It's like tuned, tuning, tune,
tune the performance of something. T-U-N-E is what I'm trying to say. T-U-N-E-D demon. And there's
a command to the tune D demon or the tune demon, which is tune D dash ADM as in admin. So first let's
talk a little bit about well, let's talk about where to find tune D at all. Online you can find
it at tune D dash project dot org. It's simple enough. It's development takes place on GitHub. And
well, I don't know if it takes place there, but that's where the repository is anyway. And there are
issues there so you can kind of get in a field for what they're they're aiming at. But you can use
it today on things like well, I'm using it on my rail laptop. You can use it on Fedora Ubuntu
Debian. Any any distribution sort of with a progressive stance of of including fancy new commands
in with with all the rest of of what they give you. So on on this laptop here, I'm going to do
well actually let's let's talk first about profiles, right? So when you're running a computer
performances performance, right? It just kind of it does what it does. But with tune D,
it can adjust how much how many resources and how often the computer is doing all of the different
things that it does. We can see these configurations in the directory slash usr slash lib slash tune D.
And then I'm going to just do a tab a couple of times here to get a list and there I've got things
with names like Accelerator dash performance balanced desktop HPC dash compute latency dash
performance network dash latency and so on. Oh, here's a good one to power save. You can kind of
guess what that might be. In fact, maybe let's look at that one. So I'm going to do a less on slash
users slash usr slash lib slash tune D slash power save. Tab a couple of times so they're just
script.sh and a tune D dot conf. So we'll look at the conf first and this is it says main summary
equals optimize for low power consumption. That's what I figured and it sets some some properties
here and there. Governor equals on demand power save energy underscore perf underscore bias equals
power save video radion power underscore rate power save and so on. So it's got a couple of of
properties that kind of reading them. You kind of get an idea for what they do and then in one
section, there's a cis control section where they're setting cis control setting. So VM dot laptop
underscore mode equals five VM dot dirty underscore right back underscore senti sex equals 1500 kernel
dot in my underscore watchdog equals zero. So it's scaling things back scaling things up depending on
what it thinks it needs to do in order to conserve power. And you'll find that that is the case
with a couple of different um different profiles is that it it it largely it's it's very frequently
making adjustments to cis control cis control or cis cuddle or however you want to say at sys ctl
is an application uh that I've done an episode on back episode 287 that is 0287. So this is way
way back there. It's not a very good episode but you can certainly listen to it and and discover
that such a command exists and this interacts with that. This is an automated way to interact with
that. There's also a script in this power save directory which sort of brute forces a kind of demon
behavior or some new functions I guess to start for instance uh usb auto suspend and enable wifi
power saving settings and other things like that that I guess um tomb d doesn't have direct access to
but it does load the script when it when it loads the power save profile and you can take a look at a
bunch of these profiles and kind of get a feel for them and you might want to do that eventually
because you could at some point actually write your own you can always write your own profiles and
then load them with with tomb d um yeah and you'll you'll see like I say just a bunch of quite
quite frequently a profile like I'm looking here at latency dash performance um it's according to
it is a uh optimized for deterministic performance at the cost of increased power consumption and
this one is almost almost entirely cis control settings just ramping a bunch of stuff up so yeah
you can kind of get an idea for for what that is now obviously again you could you could do this
all yourself you could shell script this yourself or something such that if I switch over to battery
power for instance then set these cis control values to to such and such uh if I'm no longer on
battery power then do that now you wouldn't do that just by probing proc act be that zero or whatever
it is to look at your battery consumption you would you or you could actually read you dev events
and I think I've done an episode on you dev as well on hacker public radio maybe not me see you
dev no maybe I've never done an episode on you dev well it's crazy that's really silly um I'll
have to do that sometime so um it reads you dev events so the things that your kernel is detecting or
you're well yeah your kernel is detecting um they get written out into sort of a message stream uh
with which you can see with you dev dash ADM and you could act upon those you dev events now that
ought to be built into tune d and people think that it should be and in fact have an issue at least
at the time of this recording which is sometime in 2021 uh and they've got an issue open for that
the tune d team agrees and and and that that may very well be something that they they aim to do
eventually I don't I don't know it's not under road map as far as I can see because I don't see a
road map but um it is that's not out of the question that's something that that eventually may well
happen but um that's it's not something that you can do right now like I can sit here and unplug
my laptop from the power and plug it back in and the profile will be exactly the same well how would
I even know glad I asked pseudo tune d dash ADM active type in my super secret password and it says
current active profile is balanced so I'm my laptop currently is plugged in to power and it is
the current active profile is the balanced profile now I can see a list of all the profiles of course
just by looking in list you slash usr slash live slash tune d but if you don't want to do that you can
also get a list just by doing pseudo tuned tune d dash ADM list and that very nicely gives you a
little bulleted list of of each profile available to you and there and it describes it too so it's
like accelerator dash performance it says throughput performance based timing with disabled higher
latency stop states not a very useful one I don't think but balanced general non specialized
tuned profile okay that description isn't great either desktop optimized for the desktop use case
okay well a lot of them are kind of self-explanatory from the name I guess and if you want a more
verbose explanation then definitely look at those wonderfully written descriptions there's a bunch
of them there there's a lot of useful ones there's that power save one that we looked at earlier
there's latency performance and that says optimize for deterministic performance at the cost
of increased power consumption we saw that in the config file virtual guest optimize for running
inside a virtual guest so in other words that that if you're running a virtual machine that runs
tune d you could you could put that to virtual guest now if if you're if you're thinking about the
computer running those guests in other words you're you're thinking about the host the virtual host
you might switch to virtual dash host okay so list lists the profiles that are available active
shows you what you are running currently if you want to switch to a different profile the command is
pseudo tune the dash ADM profile and then the name of the profile and these are all just strings
there's no options here these are just strings that I'm typing in so pseudo tuned dash ADM okay well
there's a dash profile but not dash dash profiles just profiles the sub command and then let's do
power save actually first I'm going to unplug the computer from the power and now I'm going to do
well actually I'm going to make sure that I'm still on balance just to make sure I don't see why
it wouldn't be I am okay profile power save takes just a moment to do that it does it and now if
I do active again it looks like I am on the power save profile now of course if I plug this computer
back in then it will still be on power save mode pseudo tune deep active and it sells me I'm still
on power save so then I could just do pseudo tuned dash ADM profile balanced and now active again
and it tells me that it's balanced and that's honestly kind of all there is two tuned to
tuned the dash ADM there's the list there's the active there's the profile there are two others
there's verify and recommend and these are a little bit tricky oh and there's off just turn it
off tell tell it not to use a profile but I'm not going to do that um these are a little bit tricky
verify and recommend so recommend I guess is interesting because it it sort of tells you what it
thinks you should be running which in this case is pseudo tune D dash ADM recommend and it tells
tells me balanced well that's what I'm on so that works out now if I do a verify it's it's going to
look at what you know the optimal performance would be versus what I have set and tell me whether
there's a problem and in this case it says verification failed current system settings differ
from the preset profile now the problem the reason this is tricky is because there are plugins
to tune D uh that I didn't install myself it just comes bundled with this the with the distribution
and those plugins oh can override the presets or the yeah the preset profile so the verification may
well never work for me because of these plugins and the plugins are are there for lots of different
reasons there are some for disk usage and so you might you might find that the that tune D
thinks that you should have I don't know a read ahead value of one thing but because you're using
an SSD drive maybe it's a completely different thing so the the failure in verification
I have found and as far as I understand from reading the docs is okay but then again I don't know
the best way to tell tune D that it's okay so verify has not been useful for me in other words
that's not been something that's been useful for me okay now we're going to try unplugging the
laptop knowing now that technically power save would probably be the most useful profile for me
I'm on battery so I'm going to do pseudo tune D-ADM recommend again and it tells me that balanced
as the best is the recommended value again so I'm I'm not finding recommend and verify terribly
helpful so far but then again as I've said the the the dynamicness of tune D versus the what
what different tune D plugins proscribe I don't feel like those two things are quite resolved yet
I could do a pseudo emax slash Etsy slash tune D slash tune D dash main dot con and look at the
global configuration for tune D the first option the first configuration option is demon equals
one meaning yes we're going to use the tune D demon here the second one is dynamic underscore
tuning and it is set to zero by default it says dynamically tune devices if disabled only static
tuning will be used so you would probably think that if we set that to one and saved it and then
probably probably reloaded tune D then we would sort of force the system to start doing things
dynamically and so on but in fact that's just not like like that yes that might be great that might
be it might be doing lots of things in the background then and I could look at the log in
var in slash var slash log slash tune D slash tune D dash log or tune D dot log or something like
I could look there and try to see what's being applied and so on to verify and compare and contrast
dynamic versus static point is though that it is not so far reaching as to do things like
detect whether the battery has suddenly become the sole power source or or or that well I guess
that's really the main thing in this case for even either recommend or just for for dynamically
switching over to power save mode so in other words this isn't as automated as it probably
could be but then on the other hand it's kind of nice that it isn't I mean it is something that
you have to remember to do if you unplug your laptop and you want to switch over to a power save
profile then you kind of have to you'd have to think to yourself okay well I have to do that now
and then we're kind of back to me sitting at a computer saying okay well how can I auto detect
that I've switched over to power and I need to probe that value and then once I probe that value
oh it's one o'clock and then once I probe that value let's issue a tune D dash ADM command
accordingly and so that's a little bit clunky still but having access to all of these settings
in an easy single command is pretty useful I don't know necessarily that I would use it on my
desktop because well first of all my desktop doesn't have it one thing the other thing is that
that my desktop generally like the profile I want for my desktop is to be at full power all the time
I never want I never want to conserve resources on my desktop I have lots of RAM I have a CPU that
I don't feel like I'm ever using as much as I want to be I want everything to be parallel hitting
all of my cores all at the time so I don't see myself necessarily requiring any kind of profile
switching on a desktop but on the laptops surely there's there's a definite desire to to have
a little bit of flexibility there but as I've said that flexibility isn't always as binary as
am I plugged into power or am I on battery power though that's a good start but in real life it would
never be sufficient and so I would end up going in there and auto adjusting anyway so do I really
care that my that that Tundee can't auto detect that right now no I don't I mean I'll probably
welcome it when it when it comes around but until then I'm quite happy to auto auto switch and I
really quite appreciate the fact that I don't have to go through and set a bunch of cis control
values and a bunch of other system variables and such myself I just think it's really nice that
someone else has figured all that stuff out for me someone who understands a lot more about say
hard drive behavior between spinning discs and SSD and so on I'm glad for them to have figured that
out and I'm happy to use Tundee and maybe you will be too so remember Tundee is the demon Tundee
dash ADM is the command check it out try it out see if it conserves your power there are a
couple of other related applications to like power top to Tundee I think it is where you can
you can use a bunch of you can use power top to kind of analyze your system for optimal settings
and then convert those settings to Tundee and that's really useful and you can find out more
about power top on my show can you world order at can you world order info you can find power top
being discussed in episode 379 I talk all about power top so check that out and there's also a
really good power top presentation that I will link to in these show notes I also link to that
to that presentation in the new world order show notes so either way you should take a look at
that so this has been an episode about Tundee you have heard it this all I know about it go check
it out thanks for listening I'll talk to you next time
you've been listening to hecka public radio at hecka public radio dot org we are a community
podcast network that releases shows every weekday Monday through Friday today's show like all our
shows was contributed by an hbr listener like yourself if you ever thought of recording a podcast
and click on our contributing to find out how easy it really is hecka public radio was found
by the digital dog pound and the infonomican computer club and it's part of the binary revolution
at binwreff.com if you have comments on today's show please email the host directly leave a comment
on the website or record a follow up episode yourself unless otherwise status today's show is
released on the creative comments attribution share a light 3.0 license
