Skip to content

Conversation

@pjungkamp
Copy link
Contributor

I've seen that you added NPU monitoring capabilities to Resources and wanted to check out the code. I also looked into PR #431.

I think that the code becomes "simpler" by using dynamic dispatch using Deref on the Gpu and Npu types. This required me to make the GpuImpl and NpuImpl traits object-safe and I had to move the generic read_sysfs_int/read_sysfs_file/read_device_int/read_hwmon_int functions out of the GpuImpl and NpuImpl traits. I consolidated these in a new read_sysfs function in src/utils/mod.rs.

I also refactored some code to cut down on some of the PathBuf and String allocations where not necessary.

While building the code using flatpak-builder I ran into timeouts on dmidecode. I've changed the download URL from the git.savannah.nongnu.org/cgit endpoint to download-mirror.savannah.gnu.org, which should be much faster.

@pjungkamp
Copy link
Contributor Author

You would need to shuffle some things #431 but at least you won't have to worry about all the match statements in utils/npu/mod.rs anymore, those were all consolidated in the Deref implementation.

@nokyan
Copy link
Owner

nokyan commented Mar 31, 2025

Thank you so much! When writing this code, I tried to figure that out but failed, so thanks a lot for fixing it up! :)
I will test it later today or tomorrow.

@nokyan
Copy link
Owner

nokyan commented Apr 1, 2025

Just tested it, works as intended and is really nice code! Thanks again!

@nokyan nokyan merged commit 95fed46 into nokyan:main Apr 1, 2025
1 check passed
@pjungkamp
Copy link
Contributor Author

Awesome! I thought about opening an issue describing the cleanups I imagined, started writing some text, got bored, and wrote the code instead. If you want some code reviews just tag me! 😄

Grüße aus dem Münsterland!

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