-
-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified fixed cpu usage percentage #99
Conversation
…hould be enabled when one thread reach 100%
Wait a bit please, I've detected that on charging state could be improved aswell. I'll do another pr in a few minutes. |
The commit has joined to previous PR. |
No worries, take your time, I'll thoroughly look into this in the morning. |
@AdnanHodzic I checked this PR: |
@Red-Eyed how many threads can handle your CPU? is your laptop in charging state? If there are only 4 is normal, but if the CPU can handle more than 4 CPUs is normal that the CPU load doesn't reach 25% (at least on an AMD Ryzen 3700U, because I haven't tested with an Intel CPU). In new portable AMD CPUs with more than 4C/8T, with an only 25% usage the problem will more noticeable. |
Hello @rrodriguez81
Updated
Discharging |
Hello @Red-Eyed :) , Not sure if because the CPU model, but in my case it didn't launch turbo. I used the stress tool for generate a 100% load: sudo stress --cpu 1 --timeout 120 |
Just tried |
BTW, are you able to switch to turbo anyway? |
@Red-Eyed with my modified version works fine, with original version the turbo doesn't get activated unless I use two threads, for example: |
@AdnanHodzic it seems that this PR should use this |
Yeah, it seems that I got what u are trying to say... |
@AdnanHodzic if psutil.cpu_percent(percpu=False) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True)), 100):
turbo(True) My apologise, @rrodriguez81 this is your PR. Try the above code snippet |
I can also confirm it works as expected on Intel. I.e
Are you saying to replace (current) i.e:
with:
and same result will be achieved? |
@AdnanHodzic actually, could you please remind me at what conditions turbo should be enabled? |
@AdnanHodzic , this is just for launch turbo faster when the power supply is connected. @Red-Eyed don't worry, all constructive ideas are welcomed :) . |
@Red-Eyed I think that there is a problem with you piece of code, it returns this error: |
Yep, just a typo if psutil.cpu_percent(percpu=False) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True)), 100):
turbo(True) |
Before this PR (and I think those values were good and we should keep them): power-save/battery:
performance:
And I quite like what @rrodriguez81 did, as it's very simple yet powerful solution. But I'm also interested in outcome of:
I'm thinking that maybe we should make turbo more "trigger happy" when in performance mode, i.e:
Although this might be too aggressive.
No worries, I deleted my commented in meantime since I figured what you did :) |
@Red-Eyed your solution works aswell, not sure why but it takes a few seconds to launch turbo. @AdnanHodzic regarding your idea about performance mode, if you set a static value, could be difficult to trigger turbo with CPUs with more than 8 threads. For example: For 8 threads CPUS: 100 / 8 = the turbo is triggered with 12.5 CPU load, but if there is a Ryzen 4800H, with 8 cores and 16 threads, 100 / 16 , 100% CPU usage of one thread is 6,25% total of total CPU load. Not sure if I'm explaining correctly (English is not my native language) |
That's why I proposed that code snippet that is not hardcoded to num of threads |
Agreed, having it hard coded is terrible. If it's fine with you @rrodriguez81 let's go with @Red-Eyed eye proposal as it's very clear what's happening. But since this your PR I'd like you to commit these changes, let's just figure out this first:
|
@AdnanHodzic @Red-Eyed not sure why, but with 100 / CPUS the turbo get triggered faster than with @Red-Eyed ' s provided solution. With my solution the turbo is triggered instantly, and with @Red-Eyed sometimes takes a few seconds (3 or 4 seconds not too much). Maybe because the isclose() is an approximation or only needs an higher value. But I'm agree using @Red-Eyed if is more clear for the code. |
Maybe if psutil.cpu_percent(percpu=False) >= 25.0 or max(psutil.cpu_percent(percpu=True)) > 99:
turbo(True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems fine.
@Red-Eyed the same problem, it trigger turbo slower than the 100 / CPUS solution. It takes to me a few seconds aswell. |
imho, i don't think that a few seconds is a problem.. |
so it seems that |
A few seconds modifying a core speed to 2.3Ghz o 3.7Ghz for example, could be the duration of the process that get the 100% of a CPU thread. The more dynamic the turbo is launched, the more agile is the notebook. |
Also seems fine on Intel.
This is also fine as I also want to switch so snap using latest Python and Ubuntu 20.04 as base in near future which might also fix things + one of the future psutil lib updates might also address this. Either way, thank you both and especially to @rrodriguez81 for your first contribution 🥳 |
Just wonder are you sure that switching turbo with high frequency is energy efficient or healthy idk? |
interesting, which version of |
@Red-Eyed I think that in the actual stable version, it tries to launch turbo as soon as is needed, but it didn't have in mind all kinds or CPUs. But if you think that is a good idea to delay it a bit to be more power efficent is ok for me aswell. The psutil version I'm using is the same as yours, I'm using latest Linux Manjaro distro. @AdnanHodzic thanks to you and all the project contributors, projects like this makes LInux better :) . |
Before I merge this with
On performance will trigger turbo in a 1 or less, which is good.
On performance it can take up to >= 5 seconds to trigger turbo, this is expected now right? |
I found one more parameter |
No this makes it worse, as turbo boost is too "trigger happy", it's almost on all the time in both performance and powersave for me. Let's leave it as it is for now and then we can improve it later on. Merging ... |
Okay |
* A fixed value of 25% CPU Load is not correct for enabling turbo, it should be enabled when one thread reach 100% * A fixed turbo on chargin state * Improved 1 thread CPU 100% load detection solution Co-authored-by: Roberto Rodríguez <rrodriguez@datiobd.com>
* A fixed value of 25% CPU Load is not correct for enabling turbo, it should be enabled when one thread reach 100% * A fixed turbo on chargin state * Improved 1 thread CPU 100% load detection solution Co-authored-by: Roberto Rodríguez <rrodriguez@datiobd.com>
Turbo should be enabled when one thread reach 100% of usage, in original version there was a fixed value of 25%, but this only works when there're 4 threads, in CPUs with more threads
Reference: #98