From 8a092864231202efb7b605122ef2de9789290782 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 8 Feb 2021 16:13:02 +0100 Subject: [PATCH] tune attestation params (#2301) * a little bit more priority to attestation processing * better implementation for bytes_to_uint64 --- beacon_chain/eth2_processor.nim | 22 ++++++++++++++-------- beacon_chain/spec/helpers.nim | 4 +--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/beacon_chain/eth2_processor.nim b/beacon_chain/eth2_processor.nim index 0aa5d99f6..7a14ccf7b 100644 --- a/beacon_chain/eth2_processor.nim +++ b/beacon_chain/eth2_processor.nim @@ -500,12 +500,18 @@ proc runQueueProcessingLoop*(self: ref Eth2Processor) {.async.} = # we run both networking and CPU-heavy things like block processing # on the same thread, we need to make sure that there is steady progress # on the networking side or we get long lockups that lead to timeouts. - # - # We cap waiting for an idle slot in case there's a lot of network traffic - # taking up all CPU - we don't want to _completely_ stop processing blocks - # in this case (attestations will get dropped) - doing so also allows us - # to benefit from more batching / larger network reads when under load. - discard await idleAsync().withTimeout(10.milliseconds) + const + # We cap waiting for an idle slot in case there's a lot of network traffic + # taking up all CPU - we don't want to _completely_ stop processing blocks + # in this case (attestations will get dropped) - doing so also allows us + # to benefit from more batching / larger network reads when under load. + idleTimeout = 10.milliseconds + + # Attestation processing is fairly quick and therefore done in batches to + # avoid some of the `Future` overhead + attestationBatch = 16 + + discard await idleAsync().withTimeout(idleTimeout) # Avoid one more `await` when there's work to do if not (blockFut.finished or aggregateFut.finished or attestationFut.finished): @@ -522,7 +528,7 @@ proc runQueueProcessingLoop*(self: ref Eth2Processor) {.async.} = elif aggregateFut.finished: # aggregates will be dropped under heavy load on producer side self[].processAggregate(aggregateFut.read()) - for i in 0..<7: # process a few at a time - this is fairly fast + for i in 0..