From fbceebc30fc4c867f25c13607b529fb688546e3c Mon Sep 17 00:00:00 2001 From: John Gates Date: Wed, 1 Mar 2023 09:25:11 -0800 Subject: [PATCH 1/2] Changed the StreamBuffer wait. --- src/wbase/SendChannelShared.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wbase/SendChannelShared.cc b/src/wbase/SendChannelShared.cc index 664fe68a6..57ae30035 100644 --- a/src/wbase/SendChannelShared.cc +++ b/src/wbase/SendChannelShared.cc @@ -249,7 +249,17 @@ bool SendChannelShared::_sendBuf(lock_guard const& streamLock, xrdsvc::St return false; } else { LOGS(_log, LOG_LVL_INFO, "_sendbuf wait start " << note); - streamBuf->waitForDoneWithThis(); // Block until this buffer has been sent. + // Only wait if this is really the last message to finish transmitting for this SendChannelShared. + // Note: If this does speed up transmission of data to the czar then it is probably worth it to + // add code to wait if more than X buffers are in use at the same time, which will likely + // make a big performance crater, but better than crashing due to out of memory. + // It may be best to reduce the number of threads per scheduler to 1 until it clears up instead + // of waiting for every send. + // If this doesn't improve transmission performance, just change it back to waiting all of the + // time. + if (last) { + streamBuf->waitForDoneWithThis(); // Block until this buffer has been sent. + } } return sent; } From 044f308bc4d3bfe7c27b0e519d9eb7464b900fbd Mon Sep 17 00:00:00 2001 From: John Gates Date: Tue, 7 Mar 2023 09:41:55 -0800 Subject: [PATCH 2/2] Changed comment. --- src/wbase/SendChannelShared.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wbase/SendChannelShared.cc b/src/wbase/SendChannelShared.cc index 57ae30035..728b8f0d1 100644 --- a/src/wbase/SendChannelShared.cc +++ b/src/wbase/SendChannelShared.cc @@ -187,6 +187,8 @@ bool SendChannelShared::_transmit(bool erred, Task::Ptr const& task) { auto sz = _transmitQueue.size(); // Is this really the last message for this SharedSendChannel? + // _lastRecvd means no more data will be added to the queue and + // if the queue size is zero, then `thisTransmit` is really the last one. bool reallyLast = (_lastRecvd && sz == 0); TransmitData::Ptr nextTr; @@ -248,7 +250,6 @@ bool SendChannelShared::_sendBuf(lock_guard const& streamLock, xrdsvc::St LOGS(_log, LOG_LVL_ERROR, "Failed to transmit " << note << "!"); return false; } else { - LOGS(_log, LOG_LVL_INFO, "_sendbuf wait start " << note); // Only wait if this is really the last message to finish transmitting for this SendChannelShared. // Note: If this does speed up transmission of data to the czar then it is probably worth it to // add code to wait if more than X buffers are in use at the same time, which will likely @@ -258,6 +259,7 @@ bool SendChannelShared::_sendBuf(lock_guard const& streamLock, xrdsvc::St // If this doesn't improve transmission performance, just change it back to waiting all of the // time. if (last) { + LOGS(_log, LOG_LVL_INFO, "_sendbuf wait start " << note); streamBuf->waitForDoneWithThis(); // Block until this buffer has been sent. } }