Skip to content
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

chore: EXC: Fix potential overflows in priority deviation metric #2440

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

berestovskyy
Copy link
Contributor

@berestovskyy berestovskyy commented Nov 5, 2024

Also, fix potential overflows in other accumulated-priority calculations.

…n` metric

Also, fix potential overflows in other accumulated-priority calculations.
@github-actions github-actions bot added the chore label Nov 5, 2024
@berestovskyy berestovskyy changed the title chore: EXC: Fix potential overflows in `accumulated_priority_deviatio… chore: EXC: Fix potential overflows in priority deviation metric Nov 5, 2024
@@ -408,7 +412,7 @@ impl RoundSchedule {

// Compute the priority of the canisters for this round.
let mut accumulated_priority_invariant = AccumulatedPriority::default();
let mut accumulated_priority_deviation = 0;
let mut accumulated_priority_deviation: i128 = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all metrics end up as f64; and there's absolutely no need for this to be exceedingly precise; I'd just use f64. Then the code would be a lot simpler and there would be no need for saturating this or saturating that.

Comment on lines +439 to +440
accumulated_priority_invariant =
accumulated_priority_invariant.saturating_add(&accumulated_priority);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the saturating_add() may make sense for the variance (where you sum accumulated_priority^2), but we're never going to exceed u64 with realistic numbers of canisters and rounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants