Added queue drop stats

This commit is contained in:
Mark Qvist 2026-08-18 12:34:18 +02:00
parent 636012bbe5
commit 1a70bd3cd1
No known key found for this signature in database
3 changed files with 27 additions and 12 deletions

View file

@ -1538,6 +1538,11 @@ class Reticulum:
stats["rxqa"] = qsnapshot[1][1]
stats["rxqp"] = qsnapshot[1][2]
stats["rxqil"] = qsnapshot[1][3]
stats["rxqtd"] = qsnapshot[2][0]+qsnapshot[2][1]+qsnapshot[2][2]+qsnapshot[2][3]
stats["rxqdd"] = qsnapshot[2][0]
stats["rxqad"] = qsnapshot[2][1]
stats["rxqpd"] = qsnapshot[2][2]
stats["rxqild"] = qsnapshot[2][3]
stats["tqpressure"] = qsnapshot[0]/tql if qsnapshot[0] else 0
stats["dqpressure"] = qsnapshot[1][0]/dql if qsnapshot[1][0] else 0
stats["aqpressure"] = qsnapshot[1][1]/aql if qsnapshot[1][1] else 0

View file

@ -44,17 +44,20 @@ from .vendor import umsgpack as umsgpack
from RNS.Interfaces.BackboneInterface import BackboneInterface
class InboundQueues:
__slots__ = ("_cond", "_queues", "_sizes")
__slots__ = ("_cond", "_queues", "_sizes", "_dropped")
def __init__(self, sizes):
self._cond = Condition()
self._queues = [deque() for _ in sizes]
self._sizes = sizes
self._cond = Condition()
self._queues = [deque() for _ in sizes]
self._sizes = sizes
self._dropped = [0 for _ in sizes]
def put(self, traffic_class, item, block=False, timeout=None):
with self._cond:
q = self._queues[traffic_class]
if len(q) >= self._sizes[traffic_class]: raise Full
if len(q) >= self._sizes[traffic_class]:
self._dropped[traffic_class] += 1
raise Full
q.append(item)
# For single drainer, notify() suffices, but will
# need to move this to notify_all for the future
@ -81,8 +84,10 @@ class InboundQueues:
# Consistent-time, single-instant height snapshot.
def snapshot(self):
with self._cond: heights = tuple(len(q) for q in self._queues)
return (sum(heights), heights)
with self._cond:
heights = tuple(len(q) for q in self._queues)
dropped = tuple(d for d in self._dropped)
return (sum(heights), heights, dropped)
class Transport:
"""

View file

@ -673,11 +673,16 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
print(f"\n Totals : {txstat}\n {rxstat}")
if queue_stats:
tqpress = f"{round(stats['tqpressure']*100.0, 1)}% total, {stats['rxqt']} pkts"
dqpress = f"{round(stats['dqpressure']*100.0, 1)}% data, {stats['rxqd']} pkts"
aqpress = f"{round(stats['dqpressure']*100.0, 1)}% announce, {stats['rxqa']} pkts"
pqpress = f"{round(stats['dqpressure']*100.0, 1)}% path request, {stats['rxqp']} pkts"
ilpress = f"{round(stats['ilqpressure']*100.0, 1)}% ingress limiter, {stats['rxqil']} pkts"
tqdp = f", {stats['rxqtd']} dropped" if stats['rxqtd'] else ""
dqdp = f", {stats['rxqdd']} dropped" if stats['rxqdd'] else ""
aqdp = f", {stats['rxqad']} dropped" if stats['rxqad'] else ""
pqdp = f", {stats['rxqpd']} dropped" if stats['rxqpd'] else ""
ilqdp = f", {stats['rxqild']} dropped" if stats['rxqild'] else ""
tqpress = f"{round(stats['tqpressure']*100.0, 1)}% total, {stats['rxqt']} pkts{tqdp}"
dqpress = f"{round(stats['dqpressure']*100.0, 1)}% data, {stats['rxqd']} pkts{dqdp}"
aqpress = f"{round(stats['dqpressure']*100.0, 1)}% announce, {stats['rxqa']} pkts{aqdp}"
pqpress = f"{round(stats['dqpressure']*100.0, 1)}% path request, {stats['rxqp']} pkts{pqdp}"
ilpress = f"{round(stats['ilqpressure']*100.0, 1)}% ingress limiter, {stats['rxqil']} pkts{ilqdp}"
print(f"\n Qu. Pressure : {tqpress}")
print(f" {dqpress}")