Use less goroutines in validator runner (#5328)

* Add buildbuddy BES (#5325)

* Add buildbuddy BES
* Use less goroutines when running validator
* per-role based goroutines
* Merge branch 'master' into validator-issue-4702
This commit is contained in:
Preston Van Loon
2020-04-06 18:34:01 -07:00
committed by GitHub
parent bcebf63cab
commit 33ffa34ea7

View File

@@ -101,24 +101,24 @@ func run(ctx context.Context, v Validator) {
continue
}
for id, roles := range allRoles {
wg.Add(1)
go func(roles []validatorRole, id [48]byte) {
for _, role := range roles {
wg.Add(len(roles))
for _, role := range roles {
go func(role validatorRole, id [48]byte) {
defer wg.Done()
switch role {
case roleAttester:
go v.SubmitAttestation(slotCtx, slot, id)
v.SubmitAttestation(slotCtx, slot, id)
case roleProposer:
go v.ProposeBlock(slotCtx, slot, id)
v.ProposeBlock(slotCtx, slot, id)
case roleAggregator:
go v.SubmitAggregateAndProof(slotCtx, slot, id)
v.SubmitAggregateAndProof(slotCtx, slot, id)
case roleUnknown:
log.WithField("pubKey", fmt.Sprintf("%#x", bytesutil.Trunc(id[:]))).Trace("No active roles, doing nothing")
default:
log.Warnf("Unhandled role %v", role)
}
}
wg.Done()
}(roles, id)
}(role, id)
}
}
// Wait for all processes to complete, then report span complete.
go func() {