From d5574ace2d557fa26013251d3a7a8e97769da5ce Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Mon, 17 Jun 2024 18:15:55 +0100 Subject: [PATCH] HPCC-31627 Remove legacy central node delay Some very old redundant code that was not being hit until the HPCC-18382 changes were introduced caused random delays when sockets were connecting in Thor. This was spuriously seen when SORT was connecting merge streams, introducing significant delays overall. Signed-off-by: Jake Smith --- system/jlib/jsocket.cpp | 28 ++-------------------------- system/jlib/jsocket.hpp | 3 --- thorlcr/slave/thslavemain.cpp | 1 - 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/system/jlib/jsocket.cpp b/system/jlib/jsocket.cpp index 962d328364b..9f4bb2d6b72 100644 --- a/system/jlib/jsocket.cpp +++ b/system/jlib/jsocket.cpp @@ -353,9 +353,6 @@ struct xfd_set { __fd_mask fds_bits[XFD_SETSIZE / __NFDBITS]; }; // define our o #define T_SOCKET int #define SEND_FLAGS (MSG_NOSIGNAL) #endif -#ifdef CENTRAL_NODE_RANDOM_DELAY -static SocketEndpointArray CentralNodeArray; -#endif enum SOCKETMODE { sm_tcp_server, sm_tcp, sm_udp_server, sm_udp, sm_multicast_server, sm_multicast}; #define BADSOCKERR(err) ((err==JSE_BADF)||(err==JSE_NOTSOCK)) @@ -1538,20 +1535,8 @@ void CSocket::connect_wait(unsigned timems) bool exit = false; int err; unsigned refuseddelay = 1; - while (!exit) { -#ifdef CENTRAL_NODE_RANDOM_DELAY - ForEachItemIn(cn,CentralNodeArray) { - const SocketEndpoint &ep=CentralNodeArray.item(cn); - if (ep.ipequals(targetip)) { - unsigned sleeptime = getRandom() % 1000; - StringBuffer s; - ep.getHostText(s); - DBGLOG("Connection to central node %s - sleeping %d milliseconds", s.str(), sleeptime); - Sleep(sleeptime); - break; - } - } -#endif + while (!exit) + { unsigned remaining; exit = tm.timedout(&remaining); bool blockselect = exit; // if last time round block @@ -6189,15 +6174,6 @@ ISocketBufferReader *createSocketBufferReader(const char *trc) } -extern jlib_decl void markNodeCentral(SocketEndpoint &ep) -{ -#ifdef CENTRAL_NODE_RANDOM_DELAY - CriticalBlock block(CSocket::crit); - CentralNodeArray.append(ep); -#endif -} - - static CSocket *prepareSocket(unsigned idx,const SocketEndpoint &ep, ISocketConnectNotify &inotify) { Owned sock = new CSocket(ep,sm_tcp,NULL); diff --git a/system/jlib/jsocket.hpp b/system/jlib/jsocket.hpp index 6587e9410ff..83c01639ef6 100644 --- a/system/jlib/jsocket.hpp +++ b/system/jlib/jsocket.hpp @@ -72,7 +72,6 @@ enum JSOCKET_ERROR_CODES { #ifndef _WIN32 #define BLOCK_POLLED_SINGLE_CONNECTS // NB this is much slower in windows -#define CENTRAL_NODE_RANDOM_DELAY #else #define USERECVSEM // to singlethread BF_SYNC_TRANSFER_PUSH #endif @@ -633,8 +632,6 @@ interface ISocketBufferReader: extends IInterface extern jlib_decl ISocketBufferReader *createSocketBufferReader(const char *trc=NULL); -extern jlib_decl void markNodeCentral(SocketEndpoint &ep); // random delay for linux - interface ISocketConnectNotify { public: diff --git a/thorlcr/slave/thslavemain.cpp b/thorlcr/slave/thslavemain.cpp index 2f0c496a8cf..17bea9fb450 100644 --- a/thorlcr/slave/thslavemain.cpp +++ b/thorlcr/slave/thslavemain.cpp @@ -434,7 +434,6 @@ int main( int argc, const char *argv[] ) SocketEndpoint masterEp(master); localHostToNIC(masterEp); setMasterPortBase(masterEp.port); - markNodeCentral(masterEp); if (RegisterSelf(masterEp)) {