Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions cloud/blockstore/libs/client_rdma/rdma_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,25 @@ struct IRequestHandler: public NRdma::TNullContext
////////////////////////////////////////////////////////////////////////////////

template <typename TResponse>
void ProcessPostponeTime(
void ProcessThrottleTime(
const TCallContextPtr& callContext,
TResponse& localResponse)
{
NProto::TThrottlerInfo& throttler =
*localResponse.MutableHeaders()->MutableThrottler();
const ui64 throttlerDelay =
Max(localResponse.GetDeprecatedThrottlerDelay(),
localResponse.GetHeaders().GetThrottler().GetDelay());
Max(localResponse.GetDeprecatedThrottlerDelay(), throttler.GetDelay());
callContext->AddTime(
EProcessingStage::Postponed,
TDuration::MicroSeconds(throttlerDelay));
localResponse.SetDeprecatedThrottlerDelay(0);
localResponse.MutableHeaders()->MutableThrottler()->SetDelay(0);
throttler.SetDelay(0);
callContext->SetPossiblePostponeDuration(TDuration::Zero());

callContext->AddTime(
EProcessingStage::Shaping,
TDuration::MicroSeconds(throttler.GetShapingDelay()));
throttler.SetShapingDelay(0);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -181,7 +187,7 @@ class TReadBlocksHandler final
responseMsg.MutableHeaders()->ClearTrace();
}

ProcessPostponeTime(CallContext, localResponse);
ProcessThrottleTime(CallContext, localResponse);

Response.SetValue(std::move(localResponse));
}
Expand Down Expand Up @@ -316,7 +322,7 @@ class TWriteBlocksHandler final
responseMsg.MutableHeaders()->ClearTrace();
}

ProcessPostponeTime(CallContext, responseMsg);
ProcessThrottleTime(CallContext, responseMsg);

Response.SetValue(std::move(responseMsg));
}
Expand Down Expand Up @@ -418,7 +424,7 @@ class TZeroBlocksHandler final
responseMsg.MutableHeaders()->ClearTrace();
responseMsg.ClearDeprecatedTrace();

ProcessPostponeTime(CallContext, responseMsg);
ProcessThrottleTime(CallContext, responseMsg);

Response.SetValue(std::move(responseMsg));
}
Expand Down
4 changes: 4 additions & 0 deletions cloud/blockstore/libs/service_rdma/rdma_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void FillResponse(const TCallContextPtr& callContext, TResponse& response)
callContext->Time(EProcessingStage::Postponed).MicroSeconds();
response.SetDeprecatedThrottlerDelay(postponeTime);
response.MutableHeaders()->MutableThrottler()->SetDelay(postponeTime);

const ui64 shapingTime =
callContext->Time(EProcessingStage::Shaping).MicroSeconds();
response.MutableHeaders()->MutableThrottler()->SetShapingDelay(shapingTime);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 9 additions & 2 deletions cloud/blockstore/libs/storage/service/volume_client_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,22 @@ void TVolumeClientActor::HandleResponse(
THasGetDeprecatedThrottlerDelay<TProtoType>::value);

if constexpr (RequiresThrottling<TMethod>) {
NProto::TThrottlerInfo& throttler =
*msg->Record.MutableHeaders()->MutableThrottler();
const ui64 throttlerDelay =
Max(msg->Record.GetDeprecatedThrottlerDelay(),
msg->Record.GetHeaders().GetThrottler().GetDelay());
throttler.GetDelay());
it->second.CallContext->AddTime(
EProcessingStage::Postponed,
TDuration::MicroSeconds(throttlerDelay));
msg->Record.SetDeprecatedThrottlerDelay(0);
msg->Record.MutableHeaders()->MutableThrottler()->SetDelay(0);
throttler.SetDelay(0);
it->second.CallContext->SetPossiblePostponeDuration(TDuration::Zero());

it->second.CallContext->AddTime(
EProcessingStage::Shaping,
TDuration::MicroSeconds(throttler.GetShapingDelay()));
throttler.SetShapingDelay(0);
}

LWTRACK(
Expand Down
13 changes: 10 additions & 3 deletions cloud/blockstore/libs/storage/volume/volume_actor_forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ namespace {
Y_HAS_MEMBER(SetDeprecatedThrottlerDelay);

template <typename TMethod>
void StoreThrottlerDelay(typename TMethod::TResponse& response, TDuration delay)
void StoreThrottlerDelay(
typename TMethod::TResponse& response,
TDuration delay,
TDuration shapingDelay)
{
using TProtoType = decltype(TMethod::TResponse::Record);
static_assert(
Expand All @@ -41,6 +44,8 @@ void StoreThrottlerDelay(typename TMethod::TResponse& response, TDuration delay)
response.Record.SetDeprecatedThrottlerDelay(delay.MicroSeconds());
response.Record.MutableHeaders()->MutableThrottler()->SetDelay(
delay.MicroSeconds());
response.Record.MutableHeaders()->MutableThrottler()->SetShapingDelay(
shapingDelay.MicroSeconds());
}
}

Expand All @@ -59,7 +64,8 @@ void RejectVolumeRequest(

StoreThrottlerDelay<TMethod>(
*response,
callContext.Time(EProcessingStage::Postponed));
callContext.Time(EProcessingStage::Postponed),
callContext.Time(EProcessingStage::Shaping));

NCloud::Send(ctx, caller, std::move(response), callerCookie);
}
Expand Down Expand Up @@ -321,7 +327,8 @@ void TVolumeActor::FillResponse(

StoreThrottlerDelay<TMethod>(
response,
callContext.Time(EProcessingStage::Postponed));
callContext.Time(EProcessingStage::Postponed),
callContext.Time(EProcessingStage::Shaping));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 9 additions & 2 deletions cloud/blockstore/libs/storage/volume_proxy/volume_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,15 +826,22 @@ void TVolumeProxyActor::HandleResponse(
THasGetDeprecatedThrottlerDelay<TProtoType>::value ==
RequiresThrottling<TMethod>);
if constexpr (RequiresThrottling<TMethod>) {
NProto::TThrottlerInfo& throttler =
*msg->Record.MutableHeaders()->MutableThrottler();
const ui64 throttlerDelay =
Max(msg->Record.GetDeprecatedThrottlerDelay(),
msg->Record.GetHeaders().GetThrottler().GetDelay());
throttler.GetDelay());
it->second.CallContext->AddTime(
EProcessingStage::Postponed,
TDuration::MicroSeconds(throttlerDelay));
msg->Record.SetDeprecatedThrottlerDelay(0);
msg->Record.MutableHeaders()->MutableThrottler()->SetDelay(0);
throttler.SetDelay(0);
it->second.CallContext->SetPossiblePostponeDuration(TDuration::Zero());

it->second.CallContext->AddTime(
EProcessingStage::Shaping,
TDuration::MicroSeconds(throttler.GetShapingDelay()));
throttler.SetShapingDelay(0);
}

LWTRACK(
Expand Down
3 changes: 2 additions & 1 deletion cloud/storage/core/libs/common/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ TRequestTime TCallContextBase::CalcRequestTime(ui64 nowCycles) const

const auto postponeDuration = Time(EProcessingStage::Postponed);
const auto backoffTime = Time(EProcessingStage::Backoff);
const auto shapingTime = Time(EProcessingStage::Shaping);

auto responseSentCycles = GetResponseSentCycles();
auto responseDuration = CyclesToDurationSafe(
(responseSentCycles ? responseSentCycles : nowCycles) - startCycles);

requestTime.ExecutionTime = responseDuration - postponeDuration -
backoffTime - GetPossiblePostponeDuration();
backoffTime - shapingTime - GetPossiblePostponeDuration();

return requestTime;
}
Expand Down
6 changes: 4 additions & 2 deletions cloud/storage/core/libs/common/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ enum class EProcessingStage
{
Postponed,
Backoff,
Last
Shaping,

Last = Shaping,
};

struct TRequestTime
Expand All @@ -33,7 +35,7 @@ struct TCallContextBase
: public TThrRefBase
{
private:
TAtomic Stage2Time[static_cast<int>(EProcessingStage::Last)] = {};
TAtomic Stage2Time[static_cast<int>(EProcessingStage::Last) + 1] = {};
TAtomic RequestStartedCycles = 0;
TAtomic ResponseSentCycles = 0;
TAtomic PossiblePostponeMicroSeconds = 0;
Expand Down
3 changes: 3 additions & 0 deletions cloud/storage/core/protos/throttler.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ message TThrottlerInfo
{
// Time spent by a request in the throttler queue in us.
uint64 Delay = 1;

// Time spent by a request in the shaping queue in us.
uint64 ShapingDelay = 2;
}
Loading