Skip to content

Commit

Permalink
Use less goroutines in validator runner (prysmaticlabs#5328)
Browse files Browse the repository at this point in the history
* Add buildbuddy BES (prysmaticlabs#5325)

* Add buildbuddy BES
* Use less goroutines when running validator
* per-role based goroutines
* Merge branch 'master' into validator-issue-4702
  • Loading branch information
prestonvanloon authored Apr 7, 2020
1 parent bcebf63 commit 33ffa34
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions validator/client/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 33ffa34

Please sign in to comment.