This is Hacker Public Radio Episode 3,32242Z, the 27th of April 2021. To its show is entitled, Tune System Performance with Dune. It is hosted by Klottu, and is about 23 minutes long, and carries a clean flag. The summary is Introduction to Tune and Tune Adding. This episode of HBR is brought to you by An Anasthost.com. Get 15% discount on all shared hosting with the offer code HBR-15. That's HBR-15. Better web hosting that's AnastonFair at Ananasthost.com. Hey everybody, you're listening to Hacker Public Radio and letting us clap too, and I want to talk about System Performance with Tune D. But first, let's talk about just System Performance quite a while ago now. I've had many laptops 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 prox slash whatever slash whatever slash battery or whatever the ACP slash bat slash whatever. And so I did that and got that more or less working on a reliable basis, and that was good for a while. And then later on, I thought, I wouldn't be neat 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 or real-time permissions or something like that. And so I worked on a 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 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 gone. So it wasn't it wasn't great. And 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 and easy way to be aware of how of how a computer is set for sort of the 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 what a computer appears to be doing is likely to assume what it kind of has to assume some set 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 in to power and generally speaking, like probably at around seven at a 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 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'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 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 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 tune tuning tune tune the performance of something to you any is what I'm trying to say to you in ED 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 feel for what they're they're aiming at but you can use it today on things like well I'm using it on my relaptop you can use it on fedora the boon to devion 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 gonna do well actually let's let's talk first about profiles right so when you're running a computer performances performance right it it just kind of it does what it does but with tune D it can adjust how how many resources and how often the computer is doing all of the different things that it does we can see these these configurations in the directory slash usr slash lib slash tune D and then I'm gonna just do tab a couple of times here to get a list 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 gonna do a less on slash usr slash usr slash lib slash tune D slash power save tab a couple of times so they're just script dot s h and a tune d dot conf so look at the conf first and this is it says main summary equals optimized 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 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 a cis control settings of vm dot laptop underscore mode equals five vm dot dirty underscore right back underscore senty sex equals 1500 kernel dot nmi underscore watchdog equals zero so it's scaling things back scaling things up depending on what things 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 largely it's it's very frequently making adjustments to cis control cis control or cis cuddle or however you want to say it s y s c t l is an application uh that I've done an episode on back episode 287 that is zero to eight seven so this is way way back there uh 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 tuned he 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 tuned 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 if I 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 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 let 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 be 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 tuned 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 and they've got an issue open for that the tuned D team agrees 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 on the roadmap thus far as I can see because I don't see a roadmap 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 tuned 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 uh 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 lib slash tuned D but if you don't want to do that you can also get a list just by doing pseudo tuned tuned D dash ADM list and that very nicely gives you a little bulleted list of of each profile available to you and there are and it describes it too so it's like accelerator dash performance 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 optimize 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's a lot of useful ones there's that power save one that we looked at earlier there's a latency performance and that says optimized for deterministic performance at the cost of increased power consumption you saw that in the config file virtual guest optimized for running inside a virtual guest so in other words that that if you're running a virtual machine that runs tuned 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 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 tuned D 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 uh 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 actually I'm going to make sure that I'm still on balance just to make sure I don't see why I 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 tuned D 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 tuned D 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 to 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 tuned D dash ADM recommend and it 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 plug-ins to tuned D that I didn't install myself it just comes bundled with the distribution and those plug-ins can override the presets or that you have a preset profile so the verification may well never work for me because of these plug-ins and the plug-ins are are there for lots of different reasons there are some for disk usage and so you might you might find that the that tuned 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 tuned D that it's okay so verify it has not been useful for me in other words that's not been something that's been useful for me okay now we're gonna 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 gonna do pseudo tuned D-ADM recommend again and it tells me that balance is 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 the dynamicness of tuned D and versus the what what different tuned D plug-ins pro scribe I don't feel like those two things are quite resolved yet I could do a pseudo e-max slash Etsy slash tuned D slash tuned D dash main dot con and look at the global configuration for tuned D the first option the first configuration option is demon equals one meaning yes we're gonna use the tuned D demon here the second one is dynamic underscore tuning and it is set to zero by default this says dynamically tuned 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 tuned 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 that yes that might be great that might be it might be doing lots of things in the background and I could look at the log in vr in slash vr slash log slash tuned D slash tune D dash log or tune D dot log or something like that I could look there and try to see what's being applied and so on to verify and just 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 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 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 it's one thing the other thing is that the my desktop generally like the profile I want from 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 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 tuned D can't auto detect that right now no I don't I mean I'll probably welcome it when it when it comes round but until then I'm 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 up 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 drives 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 tuned D and maybe you will be too so remember tuned D is the demon tuned D-ADM is the command check it out try it out see if it can serve your power there are a couple of other related applications to like power top to tuned D I think it is where you can you can use a bunch of you use power top to kind of analyze your system for optimal settings and then convert those settings to tuned D 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 tuned D you have heard it this is all I know about it go check it out thanks for listening I'll talk to you next time you've been listening to Hecker Public Radio as Hecker Public Radio.org we are a community podcast network that release the shows every week day Monday for Friday today showed like all our shows was contributed by a 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. Hecker Public Radio was found by the digital.com and the informomicon computer club and is part of the binary revolution at bmf.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 on this otherwise status today's show is released on the creative comments, attribution, share a like, see you to our live streams.