Skip to content

Comments

GPUMeter code refactor & macOS support#1620

Merged
BenBE merged 8 commits intohtop-dev:mainfrom
Explorer09:gpu-meter-darwin
May 9, 2025
Merged

GPUMeter code refactor & macOS support#1620
BenBE merged 8 commits intohtop-dev:mainfrom
Explorer09:gpu-meter-darwin

Conversation

@Explorer09
Copy link
Contributor

This is my attempt of refactoring the GPU meter code in order to support multiple platforms.
This branch includes #1618 which fixes a bug I discovered during the refactor process.
I adapted @aestriplex 's code in #1606 in the last commit of this branch. Yes I made the meter working in both bar and graph modes. (I don't want to take full credit for the last commit. If permitted, I wish to change the last commit so that @aestriplex is listed as the main author and I as a co-author.)

@aestriplex
Copy link
Contributor

Thank you @Explorer09. For what concerns the last commit, it's fine for me

@BenBE
Copy link
Member

BenBE commented Feb 24, 2025

@Explorer09 You can re-attribute commit authorship using

git commit --author=aestriplex --amend

and add the appropriate Co-authored-by: attribution lines at the end of the commit message.

HTH.

@BenBE BenBE added enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues MacOS 🍏 MacOS / Darwin related issues labels Feb 24, 2025
@BenBE BenBE added this to the 3.4.1 milestone Feb 24, 2025
@BenBE
Copy link
Member

BenBE commented Feb 24, 2025

@Explorer09 Does this PR (partially) superseed #1606 by @aestriplex?

@Explorer09
Copy link
Contributor Author

Explorer09 commented Feb 24, 2025

@BenBE Yes, this supersedes #1606 entirely. But this won't close the #1597 issue as this only implements half of the feature (no GPU time in process table yet).

@Explorer09 Explorer09 force-pushed the gpu-meter-darwin branch 2 times, most recently from 5bfc4e2 to 8658531 Compare March 8, 2025 08:39
@BenBE BenBE modified the milestones: 3.4.1, 3.5.0 Mar 12, 2025
Explorer09 and others added 8 commits April 18, 2025 03:26
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
GPUMeter_updateValues() used a locally cached "residue time" variable
for computing the percentage of the "GPU residue" usage. The "residue"
percentages of subsequent GPUMeter instances could be 0 due to the
cached "residue time" off-sync with the time data from the LinuxMachine
instance.

Rewrite the logic of the function so that all computed GPU percentage
values are cached, and the cache updated only when there's increment on
host->monotonicMs.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This makes GPUMeter code portable, that is, allow other platforms to
support GPU meter.

Co-authored-by: Matteo Nicoli <matteo.nicoli001@gmail.com>
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This slightly reduces code size.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
GPUMeter now allows placeholder values for GPU usage and "time
differences". For platforms that do not support GPU, the GPU usage
percentage may display as "N/A", and for platforms that cannot retrieve
precise GPU time, the "GPU time differences" may be hidden from text
mode display.

Co-authored-by: Matteo Nicoli <matteo.nicoli001@gmail.com>
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
The GPUMeter code is now platform independent.

Co-authored-by: Matteo Nicoli <matteo.nicoli001@gmail.com>
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Co-authored-by: Kang-Che Sung <explorer09@gmail.com>
Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

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

LGTM.

@BenBE BenBE merged commit 030f801 into htop-dev:main May 9, 2025
19 checks passed
@Explorer09 Explorer09 deleted the gpu-meter-darwin branch May 9, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues MacOS 🍏 MacOS / Darwin related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants