Skip to content

Tell a restarted energy counter from one that wrapped - #519

Open
fvaleye wants to merge 1 commit into
mainfrom
fl/read-the-cumulative-energy-counters
Open

Tell a restarted energy counter from one that wrapped#519
fvaleye wants to merge 1 commit into
mainfrom
fl/read-the-cumulative-energy-counters

Conversation

@fvaleye

@fvaleye fvaleye commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Description

A RAPL counter can move backward when it wraps or when a powercap module reload resets it.
Tracarbon treats both as wraparound.
With the fixture values, a reset converts one 60-second sample from 498 W to 498 W and adds 8.3 Wh, which exporters then convert to carbon.

This change compares the wrap-adjusted delta with the zone's published maximum power over the actual elapsed time. When the delta is higher, Tracarbon skips the sample and uses the current reading as the next baseline. A package reset also skips its child zones for that sample, without borrowing the package limit for the separate DRAM power plane. Published limits are read once per zone. Zones that publish none keep the existing wraparound behavior.

@fvaleye
fvaleye force-pushed the fl/read-the-cumulative-energy-counters branch 17 times, most recently from 6792061 to 15503ff Compare August 31, 2026 12:00
@fvaleye fvaleye changed the title Read the cumulative energy counters Tell a restarted energy counter from one that wrapped Aug 31, 2026
A RAPL counter reads lower than it did before both when it rolls over and when a
module reload restarts it. Correcting either as a roll credits the zone a whole
range it never drew: on the fixture hardware one 60 s interval reports 498 W and
8.3 Wh that never happened, which reaches the exporters as carbon.

The most power a zone can reach tells the two apart. A zone reporting more than
that across the interval was restarted rather than wrapped, and is left out of
that measurement rather than reported. Powercap answers the second constraint
with that maximum and the first with the thermal spec, which a host holding a
turbo or raising its long term limit sustains right past, so the second is asked
first. Neither can be written, so the answer is read once per zone and kept.

A zone nested inside another is bounded by it, so one publishing no maximum of
its own takes the one enclosing it. Without that the dram zone stayed uncorrected
while the package around it was skipped, and dram feeds the same host figure.

This bounds what a restart can invent to the maximum across one interval rather
than removing it. A restart implying a draw the hardware could have reached is
still read as a roll, and a gap long enough to allow a whole range, such as a
resume from a long suspend, allows it again.

The domains are read through one table rather than four accumulators, which also
keeps a usage type totalling below zero from reaching the exporters.
@fvaleye
fvaleye force-pushed the fl/read-the-cumulative-energy-counters branch from 15503ff to 5a97d7f Compare August 31, 2026 12:06
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