-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add max_energy_range_uj to deal with RAPL wraparound #323
Conversation
We probably should write a test to verify the delta functionality with mock rollover readings but this should be better than returning 0. |
df5dc3b
to
8302892
Compare
Thank you very much for this investigation ! If we understand well:
So if it goes to zero while codecarbon is running, we have the negative value problem. With your patch codecarbon will add May I suggest to refactor your code like this ? if self.last_energy > energy:
logger.debug(
f"In RAPLFile : Current energy value ({energy}) is lower than previous value ({self.last_energy}). Assuming wrap-around! Source file : {self.path}"
)
energy = energy + self.max_energy_reading
self.power = self.power.from_energies_and_delay(
energy, self.last_energy, duration
)
self.energy_delta = energy - self.last_energy
self.last_energy = energy
return |
23fd735
to
acd6de0
Compare
I've followed your refactor but I have added a new_last_energy variable to it so that it works correctly the next time we call delta(duration). I assume we are accumulating the delta values across calls? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks!
This corrects the previous patch we made on this and we have learnt something.
Thanks for your contribution!
3bcf0ec
to
efb4fbf
Compare
When we detect a negative delta from RAPL energy usage then assume we have wrapped around and add max_energy_range_uj to it. According to Intel docs this should happen about every 60 secs under a heavy load. Fixes mlco2#322
Thanks, you're right for |
When we detect a negative delta from RAPL energy usage then assume we have wrapped around and add max_energy_range_uj to it. According to Intel docs this should happen about every 60 secs under a heavy load. Fixes #322