Skip to content

Commit

Permalink
issue-1795: LargeDeletionMarkers backpressure - some fixes and cleanup (
Browse files Browse the repository at this point in the history
  • Loading branch information
qkrorlqr authored Sep 28, 2024
1 parent 5daeba1 commit 4059152
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 29 deletions.
28 changes: 24 additions & 4 deletions cloud/filestore/libs/storage/tablet/tablet_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,19 @@ TCleanupInfo TIndexTabletActor::GetCleanupInfo() const
avgCleanupScore >= Config->GetCleanupThresholdAverage();
bool isPriority = false;

if (auto priorityRange = NextPriorityRangeForCleanup()) {
cleanupRangeId = priorityRange->RangeId;
cleanupScore = Max<ui32>();
isPriority = true;
TString dummy;
// if we are close to our write backpressure thresholds, it's better to
// clean up normal deletion markers first in order not to freeze write
// requests
//
// large deletion marker cleanup is a slower process and having too many
// large deletion markers affects a much smaller percentage of workloads
if (!IsCloseToBackpressureThresholds(&dummy)) {
if (auto priorityRange = NextPriorityRangeForCleanup()) {
cleanupRangeId = priorityRange->RangeId;
cleanupScore = Max<ui32>();
isPriority = true;
}
}

return {
Expand All @@ -532,6 +541,17 @@ TCleanupInfo TIndexTabletActor::GetCleanupInfo() const
|| isPriority};
}

bool TIndexTabletActor::IsCloseToBackpressureThresholds(TString* message) const
{
auto bpThresholds = BuildBackpressureThresholds();
const double scale =
Config->GetBackpressurePercentageForFairBlobIndexOpsPriority()
/ 100.;
bpThresholds.CompactionScore *= scale;
bpThresholds.CleanupScore *= scale;
return !IsWriteAllowed(bpThresholds, GetBackpressureValues(), message);
}

////////////////////////////////////////////////////////////////////////////////

void TIndexTabletActor::HandleWakeup(
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ class TIndexTabletActor final
ui32 ScaleCompactionThreshold(ui32 t) const;
TCompactionInfo GetCompactionInfo() const;
TCleanupInfo GetCleanupInfo() const;
bool IsCloseToBackpressureThresholds(TString* message) const;

void HandleWakeup(
const NActors::TEvents::TEvWakeup::TPtr& ev,
Expand Down
3 changes: 2 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_actor_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void TIndexTabletActor::HandleCleanup(
return;
}

auto response = std::make_unique<TEvIndexTabletPrivate::TEvCleanupResponse>(error);
auto response =
std::make_unique<TEvIndexTabletPrivate::TEvCleanupResponse>(error);
NCloud::Reply(ctx, *ev, std::move(response));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,8 @@ void TIndexTabletActor::EnqueueBlobIndexOpIfNeeded(const TActorContext& ctx)

if (IsBlobIndexOpsQueueEmpty()) {
auto blobIndexOpsPriority = Config->GetBlobIndexOpsPriority();
auto bpThresholds = BuildBackpressureThresholds();
const double scale =
Config->GetBackpressurePercentageForFairBlobIndexOpsPriority()
/ 100.;
bpThresholds.CompactionScore *= scale;
bpThresholds.CleanupScore *= scale;
TString message;
if (!IsWriteAllowed(bpThresholds, GetBackpressureValues(), &message)) {
if (IsCloseToBackpressureThresholds(&message)) {
// if we are close to our backpressure thresholds, we should fall
// back to fair scheduling so that all operations show some progress
blobIndexOpsPriority = NProto::BIOP_FAIR;
Expand Down
10 changes: 3 additions & 7 deletions cloud/filestore/libs/storage/tablet/tablet_actor_truncate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,13 @@ void TIndexTabletActor::ExecuteTx_TruncateRange(
return RebootTabletOnCommitOverflow(ctx, "TruncateRange");
}

auto e = TruncateRange(db, args.NodeId, commitId, args.Range);
if (HasError(e)) {
args.Error = std::move(e);
return;
}

AddRange(
args.NodeId,
args.Range.Offset,
args.Range.Length,
args.ProfileLogRequest);

args.Error = TruncateRange(db, args.NodeId, commitId, args.Range);
}

void TIndexTabletActor::CompleteTx_TruncateRange(
Expand All @@ -338,7 +334,7 @@ void TIndexTabletActor::CompleteTx_TruncateRange(
std::move(args.ProfileLogRequest),
ctx.Now(),
GetFileSystemId(),
{},
args.Error,
ProfileLog);

LOG_DEBUG(ctx, TFileStoreComponents::TABLET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ void TIndexTabletActor::ExecuteTx_ZeroRange(
TTransactionContext& tx,
TTxIndexTablet::TZeroRange& args)
{
Y_UNUSED(ctx);

TIndexTabletDatabase db(tx.DB);

ui64 commitId = GenerateCommitId();
Expand All @@ -96,7 +94,7 @@ void TIndexTabletActor::CompleteTx_ZeroRange(
std::move(args.ProfileLogRequest),
ctx.Now(),
GetFileSystemId(),
{},
args.Error,
ProfileLog);

LOG_DEBUG(ctx, TFileStoreComponents::TABLET,
Expand Down
14 changes: 7 additions & 7 deletions cloud/filestore/libs/storage/tablet/tablet_state_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,6 @@ NProto::TError TIndexTabletState::DeleteRange(
{
const ui64 deletedBlockCount = range.AlignedBlockCount();
if (deletedBlockCount) {
MarkFreshBlocksDeleted(
db,
nodeId,
commitId,
range.FirstAlignedBlock(),
deletedBlockCount);

const bool useLargeDeletionMarkers = LargeDeletionMarkersEnabled
&& deletedBlockCount >= LargeDeletionMarkersThreshold;
if (useLargeDeletionMarkers) {
Expand Down Expand Up @@ -230,6 +223,13 @@ NProto::TError TIndexTabletState::DeleteRange(
blocksCount);
});
}

MarkFreshBlocksDeleted(
db,
nodeId,
commitId,
range.FirstAlignedBlock(),
deletedBlockCount);
}

WriteFreshBytesDeletionMarker(
Expand Down

0 comments on commit 4059152

Please sign in to comment.