use shuffled round robin between output queues

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-03-01 14:37:49 +01:00
parent f7d53fa4ca
commit f3f44552e9
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E

View File

@ -291,10 +291,8 @@ class Validator:
reality of libp2p implementations where topics between two nodes are
multiplexed over the same transport.
"""
progress = True
while (progress):
progress = False
def activeSendQueues():
queues = []
# collect and shuffle
for rID, neighs in self.rowNeighbors.items():
@ -307,14 +305,29 @@ class Validator:
if (neigh.sendQueue):
queues.append((1, cID, neigh))
for dim, lineID, neigh in shuffled(queues, self.shuffleQueues):
if dim == 0:
self.checkSendSegmentToNeigh(lineID, neigh.sendQueue.popleft(), neigh)
else:
self.checkSendSegmentToNeigh(neigh.sendQueue.popleft(), lineID, neigh)
progress = True
if self.statsTxInSlot >= 1:
return
return queues
progress = True
while (progress):
if hasattr(self, 'activeSendQueues'):
progress = False
for dim, lineID, neigh in self.activeSendQueues:
if dim == 0:
self.checkSendSegmentToNeigh(lineID, neigh.sendQueue.popleft(), neigh)
else:
self.checkSendSegmentToNeigh(neigh.sendQueue.popleft(), lineID, neigh)
progress = True
if self.statsTxInSlot >= 1:
return
self.activeSendQueues = activeSendQueues()
if self.activeSendQueues:
self.activeSendQueues = shuffled(activeSendQueues(), self.shuffleQueues)
else:
return
def runSegmentShuffleScheduler(self):
""" Schedule chunks for sending.