Skip to content

Commit

Permalink
slow request thresholds now depend on request size
Browse files Browse the repository at this point in the history
  • Loading branch information
qkrorlqr committed Dec 4, 2023
1 parent 854e911 commit 808e0e6
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 85 deletions.
1 change: 1 addition & 0 deletions cloud/storage/core/libs/common/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace NProbeParam {
constexpr const char* MediaKind = "mediaKind";
constexpr const char* RequestExecutionTime = "requestExecutionTime";
constexpr const char* RequestType = "requestType";
constexpr const char* RequestSize = "requestSize";

} // namespace NProbeParam

Expand Down
30 changes: 19 additions & 11 deletions cloud/storage/core/libs/diagnostics/trace_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <util/datetime/cputimer.h>
#include <util/generic/hash.h>
#include <util/generic/size_literals.h>
#include <util/generic/string.h>
#include <util/stream/str.h>

Expand Down Expand Up @@ -338,15 +339,13 @@ class TSlowRequestsFilter final

auto mediaKind = mediaKindParam->Get<NProto::EStorageMediaKind>();

TDuration srt;
const auto* requestSizeParam = FindParam(tl.Items.front(), RequestSize);

if (RequestThresholds) {
srt = Max(GetThresholdByRequestType(
mediaKind,
RequestThresholds,
requestTypeParam
), srt);
}
auto srt = GetThresholdByRequestType(
mediaKind,
RequestThresholds,
requestTypeParam,
requestSizeParam);

const auto* executionTimeParam = FindParam(
tl.Items.back(), RequestExecutionTime);
Expand Down Expand Up @@ -646,13 +645,16 @@ NLWTrace::TQuery ProbabilisticQuery(

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

TRequestThresholds ConvertRequestThresholds(const TProtoRequestThresholds& value)
TRequestThresholds ConvertRequestThresholds(
const TProtoRequestThresholds& value)
{
TRequestThresholds requestThresholds;
for (const auto& threshold: value) {
TLWTraceThreshold requestThreshold;
requestThreshold.Default = TDuration::MilliSeconds(
threshold.GetDefault());
requestThreshold.PerSizeUnit = TDuration::MilliSeconds(
threshold.GetPerSizeUnit());
for (const auto& [rType, typeThresh]: threshold.GetByRequestType()) {
requestThreshold.ByRequestType[rType] = \
TDuration::MilliSeconds(typeThresh);
Expand All @@ -665,14 +667,15 @@ TRequestThresholds ConvertRequestThresholds(const TProtoRequestThresholds& value
}

void OutRequestThresholds(
IOutputStream& out,
IOutputStream& out,
const NCloud::TRequestThresholds& value)
{
for (const auto& [mediaKind, tr]: value) {
NCloud::NProto::TLWTraceThreshold protoTr;
protoTr.SetMediaKind(
static_cast<NCloud::NProto::EStorageMediaKind>(mediaKind));
protoTr.SetDefault(tr.Default.MilliSeconds());
protoTr.SetPerSizeUnit(tr.PerSizeUnit.MilliSeconds());
auto& protoByRequestType = *protoTr.MutableByRequestType();
for (const auto& [requestType, duration]: tr.ByRequestType) {
protoByRequestType[requestType] = duration.MilliSeconds();
Expand All @@ -684,7 +687,8 @@ IOutputStream& out,
TDuration GetThresholdByRequestType(
const NProto::EStorageMediaKind mediaKind,
const TRequestThresholds& requestThresholds,
const NLWTrace::TParam* requestTypeParam)
const NLWTrace::TParam* requestTypeParam,
const NLWTrace::TParam* requestSizeParam)
{
TDuration srt;
auto mediaKindThresholdsIt = requestThresholds.find(mediaKind);
Expand All @@ -704,6 +708,10 @@ TDuration GetThresholdByRequestType(
srt = Max(srt, threshold->second);
}
}
if (requestSizeParam) {
auto requestSize = requestSizeParam->Get<ui64>();
srt += mediaKindThresholds.PerSizeUnit * requestSize / 1_KB;
}
}
return srt;
}
Expand Down
7 changes: 5 additions & 2 deletions cloud/storage/core/libs/diagnostics/trace_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace NCloud {
struct TLWTraceThreshold
{
TDuration Default;
TDuration PerSizeUnit;
THashMap<TString, TDuration> ByRequestType;
};

Expand All @@ -39,7 +40,8 @@ using TRequestThresholds =
using TProtoRequestThresholds =
google::protobuf::RepeatedPtrField<NCloud::NProto::TLWTraceThreshold>;

TRequestThresholds ConvertRequestThresholds(const TProtoRequestThresholds& value);
TRequestThresholds ConvertRequestThresholds(
const TProtoRequestThresholds& value);

void OutRequestThresholds(
IOutputStream& out,
Expand Down Expand Up @@ -114,6 +116,7 @@ bool ReaderIdMatch(const TString& traceType, const TString& readerId);
TDuration GetThresholdByRequestType(
const NProto::EStorageMediaKind mediaKind,
const TRequestThresholds& requestThresholds,
const NLWTrace::TParam* requestTypeParam);
const NLWTrace::TParam* requestTypeParam,
const NLWTrace::TParam* requestSizeParam);

} // namespace NCloud
Loading

0 comments on commit 808e0e6

Please sign in to comment.