Skip to content
Snippets Groups Projects
Commit 92a7b15b authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-244: Dont compute queue fill every second. Just compute on demand.

parent 3b971291
No related branches found
No related tags found
1 merge request!56L2SS-244: Expose the SSTs in MPs
......@@ -59,7 +59,7 @@ class SST(hardware_device):
# number of UDP packets that were processed
nof_packets_processed_R = attribute_wrapper(comms_annotation={"type": "sst", "parameter": "nof_packets"}, datatype=numpy.uint64)
# queue fill percentage, as reported by the consumer
queue_fill_percentage_R = attribute_wrapper(comms_annotation={"type": "sst", "parameter": "queue_fill_percentage"}, datatype=numpy.float32)
queue_fill_percentage_R = attribute(dtype = numpy.float32, access = AttrWriteType.READ, fget = lambda self: numpy.float32(self.sst_client.queue_fill_percentage()))
# number of invalid (non-SST) packets received
nof_invalid_packets_R = attribute_wrapper(comms_annotation={"type": "sst", "parameter": "nof_invalid_packets"}, datatype=numpy.uint64)
......
......@@ -45,6 +45,13 @@ class sst_client(CommClient):
fault_func()
return
def queue_fill_percentage(self):
try:
return 100 * self.queue.qsize() / self.queue.maxsize if self.queue.maxsize else 0
except NotImplementedError:
# some platforms don't have qsize(), nothing we can do here
return 0
def connect(self):
"""
Function used to connect to the client.
......@@ -217,7 +224,6 @@ class SST_collector(Thread):
self.parameters = {
"nof_packets": numpy.uint64(0),
"queue_fill_percentage": numpy.float32(self.queue_fill_percentage()),
# Packet count for packets that could not be parsed as SSTs
"nof_invalid_packets": numpy.uint64(0),
......@@ -237,13 +243,6 @@ class SST_collector(Thread):
super().__init__()
self.start()
def queue_fill_percentage(self):
try:
return 100 * self.queue.qsize() / self.queue.maxsize if self.queue.maxsize else 0
except NotImplementedError:
# some platforms don't have qsize(), nothing we can do here
return 0
def run(self):
logging.info("Starting SST thread")
......@@ -277,7 +276,6 @@ class SST_collector(Thread):
def process_packet(self, packet):
self.parameters["nof_packets"] += numpy.uint64(1)
self.parameters["queue_fill_percentage"] = queue_fill_percentage()
try:
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment