Disable only advertiseQueue.put

when listBlocks isn't called by advertiseQueueLoop, we have 0% of CPU usage. so
1) idle node burns cpu exclusively inside advertiseQueueLoop
2) idle node memleaks exclusively via advertiseQueue.put
This commit is contained in:
Bulat-Ziganshin 2022-09-08 06:04:20 +03:00
parent 38ffb990e8
commit 84536744d4

View File

@ -76,9 +76,11 @@ proc discoveryQueueLoop(b: DiscoveryEngine) {.async.} =
await sleepAsync(b.discoveryLoopSleep)
proc advertiseQueueLoop*(b: DiscoveryEngine) {.async.} =
var x=0
proc onBlock(cid: Cid) {.async.} =
try:
await b.advertiseQueue.put(cid)
#await b.advertiseQueue.put(cid)
x = x+1
except CancelledError as exc:
trace "Cancelling block listing"
raise exc
@ -87,6 +89,7 @@ proc advertiseQueueLoop*(b: DiscoveryEngine) {.async.} =
while b.discEngineRunning:
discard await b.localStore.listBlocks(onBlock)
if x==42: echo x
trace "About to sleep advertise loop", sleep = b.advertiseLoopSleep
await sleepAsync(b.advertiseLoopSleep)