2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-02-19 14:14:26 +00:00

Fix SLP asyncio performance issue

SLP asyncio performance spent too much time tied up in futile
processing,
avoid duplicate deferpeers and simplify the loop iteration.
This commit is contained in:
Jarrod Johnson
2024-08-08 17:06:57 -04:00
parent 42e5a556c1
commit e0fa642496

View File

@@ -502,8 +502,14 @@ async def snoop(handler, protocol=None):
srp = await pktq.get()
while srp and len(deferpeers) < 256:
s, rsp, peer = srp
try:
srp = await asyncio.wait_for(pktq.get(), 0.2)
except asyncio.exceptions.TimeoutError:
srp = None
if peer in known_peers:
continue
if peer in deferpeers:
continue
mac = neighutil.get_hwaddr(peer[0])
if not mac:
probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:]
@@ -511,20 +517,10 @@ async def snoop(handler, protocol=None):
s.setblocking(1)
s.sendto(b'\x00', probepeer)
except Exception as e:
try:
srp = await asyncio.wait_for(pktq.get(), 0.2)
except asyncio.exceptions.TimeoutError:
break
continue
deferpeers.append(peer)
continue
await process_peer(newmacs, known_peers, peerbymacaddress, peer)
if len(deferpeers) >= 256:
break
try:
srp = await asyncio.wait_for(pktq.get(), 0.2)
except asyncio.exceptions.TimeoutError:
break
if deferpeers:
await asyncio.sleep(2.2)
for peer in deferpeers: