Skip to content

pcp-tools: correct None handling and CPU utilization - #2691

Open
orasagar wants to merge 1 commit into
performancecopilot:mainfrom
orasagar:pcp_tools_bug_fix
Open

pcp-tools: correct None handling and CPU utilization#2691
orasagar wants to merge 1 commit into
performancecopilot:mainfrom
orasagar:pcp_tools_bug_fix

Conversation

@orasagar

Copy link
Copy Markdown
Contributor

Handle None values safely in mpstat printers instead of calling replace() on None. Fix per-CPU utilization scaling so aggregate CPU values are divided by the total CPU count only when reporting the aggregate.

Update interrupt usage tests to use the new computation context and explicit interrupt report type.fix(mpstat): correct None handling and CPU utilization

Handle None values safely in mpstat printers instead of calling replace() on None. Fix per-CPU utilization scaling so aggregate CPU values are divided by the total CPU count only when reporting the aggregate.

Update interrupt usage tests to use the new computation context and explicit interrupt report type.

Handle None values safely in mpstat printers instead of calling replace()
on None. Fix per-CPU utilization scaling so aggregate CPU values are
divided by the total CPU count only when reporting the aggregate.

Update interrupt usage tests to use the new computation context and
explicit interrupt report type.fix(mpstat): correct None handling and CPU utilization

Handle None values safely in mpstat printers instead of calling replace()
on None. Fix per-CPU utilization scaling so aggregate CPU values are
divided by the total CPU count only when reporting the aggregate.

Update interrupt usage tests to use the new computation context and
explicit interrupt report type.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cc49711-2a3a-4b6c-b032-f9fb0039b7ad

📥 Commits

Reviewing files that changed from the base of the PR and between b136970 and 3e4bfd2.

📒 Files selected for processing (11)
  • src/pcp/mpstat/pcp-mpstat.py
  • src/pcp/mpstat/test/interrupt_usage_reporter_test.py
  • src/pcp/mpstat/test/interrupt_usage_test.py
  • src/pcp/mpstat/test/none_handler_printer_decorator_test.py
  • src/pcp/mpstat/test/soft_interrupt_usage_test.py
  • src/pcp/pidstat/pcp-pidstat.py
  • src/pcp/pidstat/test/none_handler_printer_decorator_test.py
  • src/pcp/ps/pcp-ps.py
  • src/pcp/ps/test/none_handler_printer_decorator_test.py
  • src/pcp/ps/test/process_state_util_reporter_test.py
  • src/pcp/ps/test/process_statusutil_test.py

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of unavailable metric values by displaying ? instead of producing errors.
    • Corrected aggregate CPU utilization calculations while preserving per-CPU results.
    • Updated process status output for unavailable values.
  • Tests

    • Added coverage for unavailable-value display and updated monitoring behavior tests.
    • Modernized test mocking and aligned test setup with current reporting behavior.

Walkthrough

The changes make printer classes convert direct None values to ?. They correct aggregate CPU normalization in mpstat. They update mpstat and ps tests for revised constructors, contexts, report types, mocks, and process fixtures.

Changes

Metric tool updates

Layer / File(s) Summary
None output handling
src/pcp/mpstat/pcp-mpstat.py, src/pcp/mpstat/test/none_handler_printer_decorator_test.py, src/pcp/pidstat/pcp-pidstat.py, src/pcp/pidstat/test/none_handler_printer_decorator_test.py, src/pcp/ps/pcp-ps.py, src/pcp/ps/test/none_handler_printer_decorator_test.py
Printer classes convert direct None values to ?. Tests verify the forwarded output.
mpstat metric and interrupt test alignment
src/pcp/mpstat/pcp-mpstat.py, src/pcp/mpstat/test/interrupt_usage_test.py, src/pcp/mpstat/test/interrupt_usage_reporter_test.py, src/pcp/mpstat/test/soft_interrupt_usage_test.py
Aggregate CPU normalization now applies when the instance is None. Interrupt tests use InterruptComputationContext, the report type, and updated soft-interrupt fixtures.
ps process test alignment
src/pcp/ps/test/process_state_util_reporter_test.py, src/pcp/ps/test/process_statusutil_test.py
Tests use standard-library mocks, expanded process fixtures, and the revised ProcessStatusUtil constructor. The function-state expectation changes from N/A to -.

Poem

I’m a rabbit who checks each sign,
Turning None to ? in line.
CPUs gather in the proper place,
Tests follow each changed interface.
Clean mocks hop across the run,
Metrics print for everyone.

Merge Risk: ⚪ Minimal · up to 3e4bf

The change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately covers safe None handling, CPU utilization scaling, and interrupt test updates.
Title check ✅ Passed The title clearly summarizes the main changes: correcting None handling and CPU utilization in pcp-tools.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant