fix(vGPUmonitor): skip exited process slots in v1 spec metric aggregations - #2314
Conversation
|
Welcome @Nakshatra480! It looks like this is your first PR to Project-HAMi/HAMi 🎉 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughNVIDIA v0 and v1 monitor aggregations now exclude inactive process slots. Tests cover all affected metrics, active-slot fixtures, inactive slots, and invalid process counts. ChangesNVIDIA process aggregation updates
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c7e23e0 to
a9e8cb8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
v0/spec.go has same bug, as we see no status check and no activeprocs clamp either dead proc slots still summed into totals. |
Both v0 (old 1197897-byte cache) and v1 aggregation functions iterated activeProcs() without checking p.status, so slots whose CUDA process had already exited were still included in memory and utilization totals. Add a p.status == 0 guard inside every loop in both specs so only live process slots contribute to the reported metrics. Signed-off-by: Nakshatra Sharma <nakshatra.sharma3012@gmail.com>
a9e8cb8 to
43067d5
Compare
|
I fixed it in v0 as well. I added the same status == 0 check to all 6 functions there too. Can you take another look when you get a chance? |
|
/assign |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, Nakshatra480 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@archlitchi thanks for merging |
Summary
The six per-device metric accessors in
pkg/monitor/nvidia/v1/spec.go(DeviceMemoryContextSize,DeviceMemoryModuleSize,DeviceMemoryBufferSize,DeviceMemoryOffset,DeviceMemoryTotal,DeviceSmUtil) were iterating overprocs[:procnum]without checkingp.status, so slots belonging to processes that had already exited were still included in the sum.When a CUDA process exits, libvgpu sets
status = 0on its slot but does not immediately zero out the memory fields. This meant the monitor was reporting inflated memory and utilization values until the slot got reused by the next process.Added a
procBound()helper that clampsprocnumto[0, len(procs)]before slicing, sinceprocnumcomes directly from the mmap'd shared-memory region and a corrupt value would otherwise cause a slice-bounds panic.Each aggregation function now skips slots where
p.status == 0, so only live process slots contribute to the reported metrics.Updated existing tests to set
status: 1on active slots, and added regression cases covering dead-slot exclusion, negativeprocnum, and oversizedprocnumfor all six functions.Which issue(s) this PR fixes:
Fixes #2310
Special notes for your reviewer:
The analogous v0 bug (iterating all 1024 slots with no
procnumbound at all) is tracked separately in #2281. This PR only touches the v1 layout.Does this PR introduce a user-facing change?
Yes —
hami_vgpu_memory_used_bytesand related vGPUmonitor gauges will no longer be inflated after a CUDA process exits inside a container.Summary by CodeRabbit
Bug Fixes
Tests