-
Notifications
You must be signed in to change notification settings - Fork 29
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
sysinfo: Add new frequency detection method #701
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #701 +/- ##
==========================================
- Coverage 68.17% 67.03% -1.15%
==========================================
Files 20 21 +1
Lines 2319 2357 +38
==========================================
- Hits 1581 1580 -1
- Misses 738 777 +39 ☔ View full report in Codecov by Sentry. |
Oops, test fails because I forgot to move the proof-of-concept |
I'm not sure if "Draft" PRs in the context of hermit-os are interpreted as "Please don't look at this / review this PR (yet)" or "This needs some extra work before it can be merged" (as I've seen both in the context of OSS projects before). In my case, this PR needs some extra work and could benefit from feedback. I have the following question before finalizing this PR:
This is not urgent or a call for attention - just a clarification of my intentions and why the PR has stalled. I'll work on something else in the meantime :) |
I assume it does. Looks like your approach is fine.
I like the current approach you've taken
I don't see a conflict here.
True. You should create an error outside of the
As written above, this is fine as is |
Apparently, the example of "would it brake on macos-latest" was not a hypothetical - the test would fail in that case, because the frequency value is not OK (see action). This should have been fixed here and perhaps warrants some further investigation before merging: GuillaumeGomez/sysinfo#1023 |
- Add detect_freq_from_sysinfo() Shows a real-time value of the base frequency, similarly to /proc/cpuinfo on Linux. Using sysinfo as an alternative to the CPUID-provided value may be useful for some systems where the CPUID feature is not available. A potential flaw of this implementation is that the frequency is passed once to before the initialization of the kernel and cannot be changed later. If the host system is in "power-saving mode" (e.g. in laptops) and then switches to "performance mode", the application will not have any knowledge of this change. IIRC, Jonathan thinks this is OK for now. - Use sysinfo by default on x86_64 instead of CPUID. Fixes: hermit-os#690
This is a proof-of-concept, there is some more testing necessary and some questions as to how this feature should be implemented: #690
TODOs
aarch64
thing? If yes, do we throw out the CPUID code?)FrequencyDetectionFailed
duplication?I don't think that there's a "serious" case where it would return a zero, so this would technically turn the alternatives (e.g. CPUID) into dead code 99.99% of the time.
Nice-to-haves
sysinfo
crate adds a new dependency onwindows
crates. Perhaps a feature upstream that would remove that dependency would be great, as Windows is not a target.Add detect_freq_from_sysinfo()
Shows a real-time value of the base frequency, similarly to /proc/cpuinfo on Linux.
Using sysinfo as an alternative to the CPUID-provided value may be useful for some systems where the CPUID feature is not available. A potential flaw of this implementation is that the frequency is passed once to before the initialization of the kernel and cannot be changed later.
If the host system is in "power-saving mode" (e.g. in laptops) and then switches to "performance mode", the application will not have any knowledge of this change. IIRC, Jonathan thinks this is OK for now.
Use sysinfo by default on x86_64 instead of CPUID.
Currently for demonstration reasons, we may want to amend this in a later revision.
Fixes: #690