Skip to content

Commit

Permalink
add StarvingInRowForNotEnoughCpu for tcp sessions (#625)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Kriukov <kruall@ydb.ru>
  • Loading branch information
kruall and Aleksandr Kriukov authored Dec 22, 2023
1 parent 1459018 commit c289f6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ namespace NActors {
}
}

SetEnoughCpu(enoughCpu);
if (enoughCpu) {
SetEnoughCpu(true);
StarvingInRow = 0;
} else {
SetEnoughCpu(++StarvingInRow < StarvingInRowForNotEnoughCpu);
}

// calculate ping time
auto it = std::min_element(PingQ.begin(), PingQ.end());
Expand Down
3 changes: 2 additions & 1 deletion ydb/library/actors/interconnect/interconnect_tcp_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ namespace NActors {

if (!canProducePackets && !canWriteData) {
SetEnoughCpu(true); // we do not starve
StarvingInRow = 0;
break;
} else if (TimeLimit->CheckExceeded()) {
SetEnoughCpu(false);
SetEnoughCpu(++StarvingInRow < StarvingInRowForNotEnoughCpu);
IssueRam(false);
break;
}
Expand Down
7 changes: 7 additions & 0 deletions ydb/library/actors/interconnect/interconnect_tcp_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <unordered_map>

namespace NActors {

static constexpr ui64 StarvingInRowForNotEnoughCpu = 32;

class TSlowPathChecker {
using TTraceCallback = std::function<void(double)>;
TTraceCallback Callback;
Expand Down Expand Up @@ -299,6 +302,8 @@ namespace NActors {
std::array<ui32, 16> InputTrafficArray;
THashMap<ui16, ui32> InputTrafficMap;

ui64 StarvingInRow = 0;

bool CloseInputSessionRequested = false;

void CloseInputSession();
Expand Down Expand Up @@ -634,6 +639,8 @@ namespace NActors {
bool StartHandshakeOnSessionClose = false;

ui64 EqualizeCounter = 0;

ui64 StarvingInRow = 0;
};

class TInterconnectSessionKiller
Expand Down

0 comments on commit c289f6b

Please sign in to comment.