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

Replace heim with sysfs and dont wake devices #805

Merged
merged 5 commits into from
Sep 16, 2022

Conversation

DianaNites
Copy link
Contributor

@DianaNites DianaNites commented Sep 14, 2022

Description

This commit replaces heim sensor reading with manual sysfs sensor reading, and skips reading sensors for any device that is in ACPI D3cold, instead returning 0.

This has the notable downside of still keeping a device awake, which I hope to solve in a later commit or PR

Another notable potential issue with this PR is that, while heim has its own method for async reading of files, bottom itself does not seem to, and I didnt want to arbitrarily pull in a dependency to do that, so even though get_temperature_data is async, I used the normal sync I/O methods. I justify this by the fact that sysfs is in-memory and presumably shouldnt block for the operations being done here.

Changing this should be relatively easy if need be and a path is decided

To the best of my knowledge, this change has no other user-visible affect, all sensors that appeared before will continue to appear. This sysfs reading is what heim does under the hood anyway, nothing fancy.

Screenshot:

Screenshot_20220914_015509

Issue

#803

Closes: #803

Testing

If relevant, please state how this was tested. All changes must be tested to work: Manually checked that the GPU was not woken up, and that when it was by an external source, bottom started displaying the real sensor values

If this is a code change, please also indicate which platforms were tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts
  • If relevant, new tests were added (don't worry too much about coverage)

This commit replaces heim sensor reading with manual sysfs sensor reading, and skips reading sensors for any device that is in ACPI D3cold

This has the notable downside of still keeping a device awake, which I hope to solve in a later commit
They were referring to files i ultimately decided against using in this implementation, and so were no longer relevant to document.
@DianaNites
Copy link
Contributor Author

DianaNites commented Sep 14, 2022

If/when this is merged I also hope to make another PR that will help with distinguishing which device a sensor is referring to, based on top of this PR

That PR is #807

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2022

Codecov Report

Base: 23.66% // Head: 23.59% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (d86092d) compared to base (e369e12).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #805      +/-   ##
==========================================
- Coverage   23.66%   23.59%   -0.07%     
==========================================
  Files          60       60              
  Lines       13239    13276      +37     
==========================================
  Hits         3133     3133              
- Misses      10106    10143      +37     
Impacted Files Coverage Δ
src/app/data_harvester/temperature/heim.rs 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@DianaNites
Copy link
Contributor Author

DianaNites commented Sep 14, 2022

Some numbers on just how much this change improves things for laptop users like me, my iGPU reports consuming 0.008 watts while browsing the web

the dGPU reports consuming 6 watts while doing nothing in ACPI D0, a massive waste of power that, now, (mostly) wont happen.

For comparison, total system power usage when idle, looking at a web page, is as low as 6 watts. the dGPU being idle doubles total system power usage all by itself

@DianaNites
Copy link
Contributor Author

DianaNites commented Sep 14, 2022

I'm currently stuck on figuring out a good way for bottom to not block power saving. My current thoughts are reading the autosuspend_delay_ms file, but.. then what? Is there anyway to make a specific set of sensors poll at a slower than the others?

autosuspend_delay_ms can be set by userspace and could be anything, so it cant be "trusted" to even be reasonable. I could set it to 5 hours if I wanted. On my system, it defaults to 5 seconds, far too slow a poll rate for most sensors.

If some way can be found to specifically poll some sensors at a different rate, then in combination with checking if the GPU is in use(so that you get useful sensor updates when actually using the dGPU), we can simply wait if its idle, and the device will go to sleep itself, and code in this PR will then keep it asleep, perfectly solving the problem.

if..

At least as a workaround, this PR will actually cause filtered sensors not to be polled, which means a temp_filter config can, in combination with PR #807, exclude specifically the dedicated GPU, while still monitoring the iGPU. I believe the previous code, through heim, unconditionally polled all sensors, so excluding amdgpu wouldn't have worked. confirmed, this doesnt work.

Copy link
Owner

@ClementTsang ClementTsang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes seem fine to me, and I tested it locally on my computer that just has a dGPU just as another check and it seems to work fine there too.

@ClementTsang ClementTsang merged commit c3e4a95 into ClementTsang:master Sep 16, 2022
@ClementTsang
Copy link
Owner

Really thankful for both sending the issue (I had never even considered this as a problem, so that was interesting to look into), and taking the time to submit a PR.

@all-contributors please add @DianaNites for code

@allcontributors
Copy link
Contributor

@ClementTsang

I've put up a pull request to add @DianaNites! 🎉

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.

[Bug]: On machines with Hybrid Graphics, bottom keeps the dedicated GPU awake
3 participants