Skip to content

Commit

Permalink
dont move non-actualized buckets in rating scale (ydb-platform#9628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored and rekby committed Sep 24, 2024
1 parent 43550e8 commit bc8b293
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -939,13 +939,14 @@ class TPortionsBucket: public TMoveOnly {
dest.MoveNextBorderTo(*this);
}

void Actualize(const TInstant currentInstant) {
[[nodiscard]] bool Actualize(const TInstant currentInstant) {
if (currentInstant < NextActualizeInstant) {
return;
return false;
}
auto gChartsThis = StartModificationGuard();
NextActualizeInstant = Others.Actualize(currentInstant);
RebuildOptimizedFeature(currentInstant);
return true;
}

void SplitOthersWith(TPortionsBucket& dest) {
Expand Down Expand Up @@ -984,7 +985,11 @@ class TPortionBuckets {
}

void RemoveBucketFromRating(const std::shared_ptr<TPortionsBucket>& bucket) {
auto it = BucketsByWeight.find(bucket->GetLastWeight());
return RemoveBucketFromRating(bucket, bucket->GetLastWeight());
}

void RemoveBucketFromRating(const std::shared_ptr<TPortionsBucket>& bucket, const i64 rating) {
auto it = BucketsByWeight.find(rating);
AFL_VERIFY(it != BucketsByWeight.end());
AFL_VERIFY(it->second.erase(bucket.get()));
if (it->second.empty()) {
Expand Down Expand Up @@ -1068,9 +1073,7 @@ class TPortionBuckets {
if (BucketsByWeight.empty()) {
return false;
}
if (BucketsByWeight.rbegin()->second.empty()) {
return false;
}
AFL_VERIFY(BucketsByWeight.rbegin()->second.size());
const TPortionsBucket* bucketForOptimization = *BucketsByWeight.rbegin()->second.begin();
return bucketForOptimization->IsLocked(dataLocksManager);
}
Expand All @@ -1087,12 +1090,14 @@ class TPortionBuckets {

void Actualize(const TInstant currentInstant) {
RemoveBucketFromRating(LeftBucket);
LeftBucket->Actualize(currentInstant);
Y_UNUSED(LeftBucket->Actualize(currentInstant));
AddBucketToRating(LeftBucket);
for (auto&& i : Buckets) {
RemoveBucketFromRating(i.second);
i.second->Actualize(currentInstant);
AddBucketToRating(i.second);
const i64 rating = i.second->GetWeight();
if (i.second->Actualize(currentInstant)) {
RemoveBucketFromRating(i.second, rating);
AddBucketToRating(i.second);
}
}
}

Expand Down

0 comments on commit bc8b293

Please sign in to comment.