Skip to content

fix: deduplicate mirrored Linux RAPL counters - #1276

Open
lntutor wants to merge 2 commits into
mlco2:masterfrom
lntutor:fix-linux-rapl-mirrored-counters-1274
Open

fix: deduplicate mirrored Linux RAPL counters#1276
lntutor wants to merge 2 commits into
mlco2:masterfrom
lntutor:fix-linux-rapl-mirrored-counters-1274

Conversation

@lntutor

@lntutor lntutor commented Jul 26, 2026

Copy link
Copy Markdown

Description

Drop mirrored nonzero Linux RAPL package counters at monitoring startup while preserving distinct package counters, zero counters, and DRAM domains. The documentation explains the multi-die mirrored-counter behavior.

Related Issue

Fixes #1274

Motivation and Context

Some Linux multi-die systems expose mirrored package-energy counters. Counting each mirror separately overstates CPU energy consumption, while indiscriminate deduplication could incorrectly remove distinct or zero-valued counters.

How Has This Been Tested?

  • uv run pytest tests/test_rapl_mmio_scanning.py -q
  • uv run pytest tests/test_cpu.py tests/test_rapl_mmio_scanning.py tests/test_rapl_parameters.py -q
  • uv run ruff check codecarbon/core/cpu.py tests/test_rapl_mmio_scanning.py
  • uv run ruff format --check codecarbon/core/cpu.py tests/test_rapl_mmio_scanning.py
  • git diff --check

Screenshots (if appropriate):

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

AI Usage Disclosure

  • 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
  • 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
  • ⭐ AI-assisted. Car analogy : you drive the car, AI help you find your way.
  • ♻️ No AI used. Car analogy : you drive the car.

OpenAI Codex assisted with implementation, tests, and documentation preparation. I personally reviewed and tested every submitted line, understand the implementation, and can explain and maintain it.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@lntutor
lntutor requested a review from a team as a code owner July 26, 2026 12:29
@SaboniAmine

Copy link
Copy Markdown
Member

Thanks for your contribution, that seems great!
Letting @benoit-cty validate the dedup mechanism, as he worked on the windows side.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.79%. Comparing base (663db8f) to head (3a116e8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1276      +/-   ##
==========================================
+ Coverage   89.70%   89.79%   +0.09%     
==========================================
  Files          48       48              
  Lines        4778     4791      +13     
==========================================
+ Hits         4286     4302      +16     
+ Misses        492      489       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit-cty

Copy link
Copy Markdown
Contributor

Hello, you have created more than 20 repository today, I suspect you are an OpenClaw agent. I'm not against AI contribution, but a human must be accountable and willing to contribute to our project.

Please respect the PR submission template.

We will merge EMI PR in a few days then look back at this PR.

@lntutor

lntutor commented Jul 31, 2026

Copy link
Copy Markdown
Author

Updated the PR description to the complete repository template, including the required 🟠 AI-generated disclosure. I personally reviewed and tested every submitted line, understand the implementation, and can explain and support it through review and after merge.

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.

Linux RAPL over-counts CPU power on multi-die CPUs (port the Windows EMI fix)

3 participants