Skip to content

Commit

Permalink
[Filestore] add information about backpressure to the monpage (#1966)
Browse files Browse the repository at this point in the history
  • Loading branch information
debnatkh authored Sep 11, 2024
1 parent ea883f6 commit e3acdeb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 15 deletions.
17 changes: 16 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,17 @@ TThresholds TIndexTabletActor::BuildBackpressureThresholds() const
};
}

TIndexTabletState::TBackpressureValues
TIndexTabletActor::GetBackpressureValues() const
{
return {
GetFreshBlocksCount() * GetBlockSize(),
GetFreshBytesCount(),
GetRangeToCompact().Score,
GetRangeToCleanup().Score,
};
}

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

void TIndexTabletActor::ResetThrottlingPolicy()
Expand Down Expand Up @@ -340,7 +351,11 @@ NProto::TError TIndexTabletActor::ValidateWriteRequest(
}

TString message;
if (!IsWriteAllowed(BuildBackpressureThresholds(), &message)) {
if (!IsWriteAllowed(
BuildBackpressureThresholds(),
GetBackpressureValues(),
&message))
{
EnqueueFlushIfNeeded(ctx);
EnqueueBlobIndexOpIfNeeded(ctx);

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 @@ -406,6 +406,7 @@ class TIndexTabletActor final
const NProto::TSessionEvent& event);

TBackpressureThresholds BuildBackpressureThresholds() const;
TBackpressureValues GetBackpressureValues() const;

void ResetThrottlingPolicy();

Expand Down
38 changes: 38 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor_monitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,44 @@ void TIndexTabletActor::HandleHttpInfo_Default(
TAG(TH3) { out << "CompactionMap"; }
DumpCompactionMap(out, TabletID(), GetCompactionMapStats(topSize));

const auto backpressureThresholds = BuildBackpressureThresholds();
const auto backpressureValues = GetBackpressureValues();
TString message;
bool isWriteAllowed = IsWriteAllowed(
backpressureThresholds,
backpressureValues,
&message);
TAG(TH3) { out << "Backpressure"; }
if (!isWriteAllowed) {
out << "<div class='alert alert-danger'>" << "Write not allowed: " << message << "</div>";
} else {
out << "<div class='alert'>Write allowed</div>";
}

TABLE_CLASS("table table-bordered") {
TABLEHEAD() {
TABLER() {
TABLEH() { out << "Name"; }
TABLEH() { out << "Value"; }
TABLEH() { out << "Threshold"; }
}
}
#define DUMP_BACKPRESSURE_FIELD(name) \
TABLER() { \
TABLED() { out << #name; } \
TABLED() { out << backpressureValues.name; } \
TABLED() { out << backpressureThresholds.name; } \
} \
// DUMP_BACKPRESSURE_FIELD

DUMP_BACKPRESSURE_FIELD(Flush);
DUMP_BACKPRESSURE_FIELD(FlushBytes);
DUMP_BACKPRESSURE_FIELD(CompactionScore);
DUMP_BACKPRESSURE_FIELD(CleanupScore);

#undef DUMP_BACKPRESSURE_FIELD
}

#define DUMP_INFO_FIELD(info, name) \
TABLER() { \
TABLED() { out << #name; } \
Expand Down
3 changes: 3 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,11 @@ FILESTORE_DUPCACHE_REQUESTS(FILESTORE_DECLARE_DUPCACHE)
}
};

using TBackpressureValues = TBackpressureThresholds;

bool IsWriteAllowed(
const TBackpressureThresholds& thresholds,
const TBackpressureValues& values,
TString* message) const;

//
Expand Down
24 changes: 10 additions & 14 deletions cloud/filestore/libs/storage/tablet/tablet_state_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,31 +262,27 @@ bool TIndexTabletState::HasActiveTruncateOp(ui64 nodeId) const

bool TIndexTabletState::IsWriteAllowed(
const TIndexTabletState::TBackpressureThresholds& thresholds,
const TIndexTabletState::TBackpressureValues& values,
TString* message) const
{
const auto freshBlocksDataSize = GetFreshBlocksCount() * GetBlockSize();

if (freshBlocksDataSize >= thresholds.Flush) {
*message = TStringBuilder() << "freshBlocksDataSize: "
<< freshBlocksDataSize;
if (values.Flush >= thresholds.Flush) {
*message = TStringBuilder() << "freshBlocksDataSize: " << values.Flush;
return false;
}

const auto freshBytesCount = GetFreshBytesCount();
if (freshBytesCount >= thresholds.FlushBytes) {
*message = TStringBuilder() << "freshBytesCount: " << freshBytesCount;
if (values.FlushBytes >= thresholds.FlushBytes) {
*message = TStringBuilder() << "freshBytesCount: " << values.FlushBytes;
return false;
}

const auto compactionScore = GetRangeToCompact().Score;
if (compactionScore >= thresholds.CompactionScore) {
*message = TStringBuilder() << "compactionScore: " << compactionScore;
if (values.CompactionScore >= thresholds.CompactionScore) {
*message = TStringBuilder()
<< "compactionScore: " << values.CompactionScore;
return false;
}

const auto cleanupScore = GetRangeToCleanup().Score;
if (cleanupScore >= thresholds.CleanupScore) {
*message = TStringBuilder() << "cleanupScore: " << cleanupScore;
if (values.CleanupScore >= thresholds.CleanupScore) {
*message = TStringBuilder() << "cleanupScore: " << values.CleanupScore;
return false;
}

Expand Down

0 comments on commit e3acdeb

Please sign in to comment.