Skip to content

Commit a382b5a

Browse files
committed
YT: Post-commit fixes for throttling time
commit_hash:e23a92102b67714ab31f781cca1068fb9983357a
1 parent 85af4d1 commit a382b5a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

yt/yt/core/rpc/service.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ struct IServiceContext
8282
//! Returns time between request execution start and the moment of reply or cancellation (if it already happened).
8383
virtual std::optional<TDuration> GetExecutionDuration() const = 0;
8484

85-
//! Substract given throttle duration time from request execution time.
85+
//! This duration will be subtracted from the request execution time.
86+
//! Can be called multiple times; these durations are added up.
8687
virtual void RecordThrottling(TDuration throttleDuration) = 0;
8788

8889
//! Returns trace context associated with request.

yt/yt/core/rpc/service_detail.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ class TServiceBase::TServiceContext
635635

636636
void RecordThrottling(TDuration throttleDuration) override
637637
{
638-
ThrottlingTime_ = ThrottlingTime_ ? *ThrottlingTime_ + throttleDuration : throttleDuration;
638+
ThrottlingTime_ = ThrottlingTime_ + throttleDuration;
639639
if (ExecutionTime_) {
640640
*ExecutionTime_ -= throttleDuration;
641641
}
@@ -765,7 +765,7 @@ class TServiceBase::TServiceContext
765765
std::optional<TInstant> RunInstant_;
766766
std::optional<TInstant> ReplyInstant_;
767767
std::optional<TInstant> CancelInstant_;
768-
std::optional<TDuration> ThrottlingTime_;
768+
TDuration ThrottlingTime_;
769769

770770
std::optional<TDuration> ExecutionTime_;
771771
std::optional<TDuration> TotalTime_;
@@ -1055,8 +1055,8 @@ class TServiceBase::TServiceContext
10551055

10561056
ReplyInstant_ = NProfiling::GetInstant();
10571057
ExecutionTime_ = RunInstant_ ? *ReplyInstant_ - *RunInstant_ : TDuration();
1058-
if (RunInstant_ && ThrottlingTime_) {
1059-
*ExecutionTime_ -= *ThrottlingTime_;
1058+
if (RunInstant_) {
1059+
*ExecutionTime_ -= ThrottlingTime_;
10601060
}
10611061
TotalTime_ = *ReplyInstant_ - ArriveInstant_;
10621062

0 commit comments

Comments
 (0)