Skip to content
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

Add support for configuring/overriding "Energy Performance Preference (EPP)" #619

Merged
merged 4 commits into from
Dec 29, 2023

Conversation

murbot
Copy link
Contributor

@murbot murbot commented Dec 17, 2023

These changes add support for configuring the energy performance preference value to be used when on charger and battery, via the auto-cpufreq config file. I've updated the readme and example config with examples.

README.md Outdated Show resolved Hide resolved
@AdnanHodzic AdnanHodzic changed the title Added support for configuring/overriding energy performance preferenc… Added support for configuring/overriding energy performance preference Dec 20, 2023
@AdnanHodzic AdnanHodzic changed the title Added support for configuring/overriding energy performance preference Add support for configuring/overriding "energy_performance_preference" Dec 20, 2023
@AdnanHodzic AdnanHodzic changed the title Add support for configuring/overriding "energy_performance_preference" Add support for configuring/overriding "Energy Performance Preference (EPP)" Dec 20, 2023
@AdnanHodzic
Copy link
Owner

I love what's happening here, and instead of having it as "improvement" I want to have this as one of the features for next release. I could already merge it as it is, but I have another small request/suggestion which would make it perfect.

Could you as part of this PR, make it visible as part of output what value is used, i.e Energy Performance Preference (EPP) in use: balance_performance. It could be added under CPU frequency scaling section, ideally under i.e: Average temp. of all cores field. Think it would be of great value to have this.

What do you think, would this be possible from your side?

@murbot
Copy link
Contributor Author

murbot commented Dec 21, 2023

I'm glad that you like the additions, @AdnanHodzic ! I see your suggestion is already present under --stats (CLI) as well as in the GUI. They both have the following line:

Setting to use: "power" EPP

Do you have another change in mind?

@AdnanHodzic
Copy link
Owner

AdnanHodzic commented Dec 21, 2023

Setting to use: "power" EPP

Do you have another change in mind?

Yes, this line could be re-used for this purpose. Reason why I mentioned it is because I used to see this line. Now with latest change I don't see anything being displayed as part of it.

This is what --stats looks like with change on your branch, even after using config file (same thing in GUI of course) and explicitly defining EPP override.

------------------------------------------------------------------------------

Linux distro: Ubuntu 23.10 Mantic Minotaur
Linux kernel: 6.5.0-14-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate

------------------------------ Current CPU stats ------------------------------

CPU max frequency: 1800 MHz
CPU min frequency: 400 MHz

Core	Usage	Temperature	Frequency
CPU0      4.0%        35 °C      1800 MHz
CPU1      3.0%        36 °C      1800 MHz
CPU2      2.0%        34 °C       400 MHz
CPU3     11.2%        36 °C      1800 MHz
CPU4      6.9%        35 °C      1800 MHz
CPU5     25.7%        36 °C      1800 MHz
CPU6      5.9%        34 °C      1800 MHz
CPU7      7.1%        36 °C      1801 MHz

CPU fan speed: 0 RPM

---------------------------- CPU frequency scaling ----------------------------

Battery is: charging

Setting to use: "performance" governor

Total CPU usage: 2.9 %
Total system load: 0.92
Average temp. of all cores: 35.25 °C 

High CPU load (load average: 0.92, 1.86, 2.08)
setting turbo boost: on

-------------------------------------------------------------------------------

Also on this topic, let's make small changes to config file, so in front of # EPP: see available preferences by running lines it says # EPP: see available preferences by running

@murbot
Copy link
Contributor Author

murbot commented Dec 22, 2023

@AdnanHodzic - I assume you're not seeing the EPP output because the following condition evaluates to false. Note, that this condition was in the code prior to my additions. In short, it is not shown because you're on an Intel processor, whereas I'm on AMD.

    if (
        Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists()
        and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False
    ):

I pushed a new commit adding the "EPP: " to the config file comments.

@AdnanHodzic
Copy link
Owner

I pushed a new commit adding the "EPP: " to the config file comments.

👍

Note, that this condition was in the code prior to my additions.

I'm aware, it's just now that I realized now I'm no longer seeing it.

I assume you're not seeing the EPP output because the following condition evaluates to false.
In short, it is not shown because you're on an Intel processor, whereas I'm on AMD.

if (
    Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists()
    and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False
):

Indeed /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost will return 0 in my case.

Then let's do this, since by default "EPP" line will come as enabled (not commented) in config file. Where in this case, EPP is not showing up, let's extend the code to something like:

if (
    os.path.exists("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference")
    and not os.path.exists("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost")
):
    value = int(
        os.popen("cat /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").read()
    )
    if value == 0:
        print("(EPP) in use: dynamic boost is disabled")
    else:
        print("(EPP) in use: {epp}")
else:
    print("(EPP) in use: Dynamic boost is not supported")

Feel free to amend code block, it's just the first thing I could think of.

@murbot
Copy link
Contributor Author

murbot commented Dec 29, 2023

@AdnanHodzic , I've added a message to be printed when EPP is not applicable:

else: print('Not setting EPP (not supported by system)')

@AdnanHodzic AdnanHodzic merged commit fe29620 into AdnanHodzic:master Dec 29, 2023
@AdnanHodzic
Copy link
Owner

LGTM, thank you for your contribution, you will be credited for your work as part of future release.

@murbot
Copy link
Contributor Author

murbot commented Dec 30, 2023 via email

shadeyg56 pushed a commit to shadeyg56/auto-cpufreq that referenced this pull request Feb 12, 2024
… (EPP)" (AdnanHodzic#619)

* Added support for configuring/overriding energy performance preference (EPP)

* Corrected path to print available energy performance preferences in docs

* Added "EPP" wording to config examples

* Added message when EPP is not supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants