Skip to content

Commit

Permalink
optimize starting from upper count 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 15, 2025
1 parent 9029a71 commit 32115b0
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1915,11 +1915,12 @@ impl AggregationUpdateQueue {
let upper_count = get!(task, PersistentUpperCount)
.copied()
.unwrap_or_default() as usize;
if upper_count * follower_count
<= max(
MAX_UPPERS_FOLLOWER_PRODUCT,
aggregation_number.effective as usize,
)
if upper_count <= 1
|| upper_count.saturating_sub(1) * follower_count
<= max(
MAX_UPPERS_FOLLOWER_PRODUCT,
aggregation_number.effective as usize,
)
{
// Doesn't need optimization
return;
Expand Down Expand Up @@ -1969,7 +1970,7 @@ impl AggregationUpdateQueue {
std::cmp::Ordering::Greater => {
// This aggregation number would not conflict
// Is it within the limit?
let product = new_follower_count * new_upper_count * 2;
let product = new_follower_count * new_upper_count.saturating_sub(1) * 2;
if new_follower_count == 0 || product <= new_aggregation_number as usize {
break;
} else if product < n as usize {
Expand Down

0 comments on commit 32115b0

Please sign in to comment.