Skip to content

Commit

Permalink
issue-2137: calculating GarbageBlocksCount for each affected rangeId …
Browse files Browse the repository at this point in the history
…only once
  • Loading branch information
qkrorlqr committed Oct 18, 2024
1 parent 511cbe1 commit 6a82597
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cloud/filestore/libs/storage/tablet/tablet_actor_addblob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class TAddBlobsExecutor
TABLET_VERIFY(!args.MergedBlobs);
TABLET_VERIFY(!args.UnalignedDataParts);

THashSet<ui32> rangeIds;

for (const auto& blob: args.SrcBlobs) {
const auto rangeId = Tablet.GetMixedRangeIndex(blob.Blocks);
auto& stats = AccessCompactionStats(rangeId);
Expand All @@ -324,6 +326,8 @@ class TAddBlobsExecutor
// needed.
stats.BlobsCount = Max(1U, stats.BlobsCount) - 1;
Tablet.DeleteMixedBlocks(db, blob.BlobId, blob.Blocks);

rangeIds.insert(rangeId);
}

THashMap<ui32, ui32> rangeId2AddedBlobsCount;
Expand All @@ -334,6 +338,8 @@ class TAddBlobsExecutor
if (Tablet.WriteMixedBlocks(db, blob.BlobId, blob.Blocks)) {
++rangeId2AddedBlobsCount[rangeId];
}

rangeIds.insert(rangeId);
}

for (const auto& [rangeId, addedBlobsCount]: rangeId2AddedBlobsCount) {
Expand All @@ -350,9 +356,7 @@ class TAddBlobsExecutor
}

// recalculating GarbageBlocksCount for each of the affected ranges
for (const auto& blob: args.SrcBlobs) {
const auto rangeId = Tablet.GetMixedRangeIndex(blob.Blocks);

for (const auto rangeId: rangeIds) {
AccessCompactionStats(rangeId).GarbageBlocksCount =
Tablet.CalculateMixedIndexRangeGarbageBlockCount(rangeId);
}
Expand Down

0 comments on commit 6a82597

Please sign in to comment.