tune attestation params (#2301)

* a little bit more priority to attestation processing
* better implementation for bytes_to_uint64
This commit is contained in:
Jacek Sieka 2021-02-08 16:13:02 +01:00 committed by GitHub
parent 237453ec45
commit 8a09286423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -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.
#
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.
discard await idleAsync().withTimeout(10.milliseconds)
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..<attestationBatch: # process a few at a time - this is fairly fast
if self[].aggregatesQueue.empty():
break
self[].processAggregate(self[].aggregatesQueue.popFirstNoWait())
@ -532,7 +538,7 @@ proc runQueueProcessingLoop*(self: ref Eth2Processor) {.async.} =
# attestations will be dropped under heavy load on producer side
self[].processAttestation(attestationFut.read())
for i in 0..<7: # process a few at a time - this is fairly fast
for i in 0..<attestationBatch: # process a few at a time - this is fairly fast
if self[].attestationsQueue.empty():
break
self[].processAttestation(self[].attestationsQueue.popFirstNoWait())

View File

@ -86,9 +86,7 @@ func bytes_to_uint64*(data: openArray[byte]): uint64 =
doAssert data.len == 8
# Little-endian data representation
result = 0
for i in countdown(7, 0):
result = result * 256 + data[i]
uint64.fromBytesLE(data)
# Have 1, 4, and 8-byte versions. Spec only defines 8-byte version, but useful
# to check invariants on rest.