Merge pull request #1054 from notlesh/message-queue-stats-2020-01-17

Include outbound message queue stats in dumpState API response
pull/1058/head
Jeff 4 years ago committed by GitHub
commit 493213717f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -89,7 +89,14 @@ namespace llarp
util::StatusObject
OutboundMessageHandler::ExtractStatus() const
{
util::StatusObject status{};
util::StatusObject status{"queueStats",
{{"queued", m_queueStats.queued},
{"dropped", m_queueStats.dropped},
{"sent", m_queueStats.sent},
{"queueWatermark", m_queueStats.queueWatermark},
{"perTickMax", m_queueStats.perTickMax},
{"numTicks", m_queueStats.numTicks}}};
return status;
}
@ -201,6 +208,7 @@ namespace llarp
{
const llarp_buffer_t buf(msg.first);
auto callback = msg.second;
m_queueStats.sent++;
return _linkManager->SendTo(
remote, buf, [=](ILinkSession::DeliveryStatus status) {
if(status == ILinkSession::DeliveryStatus::eDeliverySuccess)
@ -234,8 +242,17 @@ namespace llarp
if(outboundQueue.tryPushBack(std::move(entry))
!= llarp::thread::QueueReturn::Success)
{
m_queueStats.dropped++;
DoCallback(callback_copy, SendStatus::Congestion);
}
else
{
m_queueStats.queued++;
uint32_t queueSize = outboundQueue.size();
m_queueStats.queueWatermark =
std::max(queueSize, m_queueStats.queueWatermark);
}
return true;
}
@ -259,6 +276,7 @@ namespace llarp
MessageQueue &path_queue = itr_pair.first->second;
if(path_queue.size() >= MAX_PATH_QUEUE_SIZE)
{
m_queueStats.dropped++;
path_queue.pop(); // head drop
}
path_queue.push(std::move(entry));
@ -286,6 +304,8 @@ namespace llarp
void
OutboundMessageHandler::SendRoundRobin()
{
m_queueStats.numTicks++;
// send non-routing messages first priority
auto &non_routing_mq = outboundMessageQueues[zeroID];
while(not non_routing_mq.empty())
@ -349,6 +369,9 @@ namespace llarp
break;
}
}
m_queueStats.perTickMax =
std::max((uint32_t)sent_count, m_queueStats.perTickMax);
}
void

@ -54,6 +54,17 @@ namespace llarp
RouterID router;
};
struct MessageQueueStats
{
uint64_t queued = 0;
uint64_t dropped = 0;
uint64_t sent = 0;
uint32_t queueWatermark = 0;
uint32_t perTickMax = 0;
uint32_t numTicks = 0;
};
using MessageQueue = std::queue< MessageQueueEntry >;
void
@ -128,6 +139,8 @@ namespace llarp
// paths cannot have pathid "0", so it can be used as the "pathid"
// for non-traffic (control) messages, so they can be prioritized.
static const PathID_t zeroID;
MessageQueueStats m_queueStats;
};
} // namespace llarp

@ -78,7 +78,8 @@ namespace llarp
{"dht", _dht->impl->ExtractStatus()},
{"services", _hiddenServiceContext.ExtractStatus()},
{"exit", _exitContext.ExtractStatus()},
{"links", _linkManager.ExtractStatus()}};
{"links", _linkManager.ExtractStatus()},
{"outboundMessages", _outboundMessageHandler.ExtractStatus()}};
}
else
{

Loading…
Cancel
Save