Skip to content

Commit

Permalink
Problem: can't use more parallelism than GOMAXPROCS
Browse files Browse the repository at this point in the history
Solution:
- take the min of GOMAXPROCS and NumCPU
  • Loading branch information
yihuang committed Sep 19, 2024
1 parent b330f22 commit 801b3e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Improvements

* [#]() Change the default parallelism of the block-stm to minimum between GOMAXPROCS and NumCPU

*Sep 13, 2024*

## v1.4.0-rc0
Expand Down
6 changes: 5 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ func New(
sdk.SetAddrCacheEnabled(false)
workers := cast.ToInt(appOpts.Get(srvflags.EVMBlockSTMWorkers))
if workers == 0 {
workers = stdruntime.NumCPU()
workers = maxParallelism()
}
preEstimate := cast.ToBool(appOpts.Get(srvflags.EVMBlockSTMPreEstimate))
logger.Info("block-stm executor enabled", "workers", workers, "pre-estimate", preEstimate)
Expand Down Expand Up @@ -1369,3 +1369,7 @@ func (app *App) Close() error {
app.Logger().Info("Application gracefully shutdown", "error", err)
return err
}

func maxParallelism() int {
return min(stdruntime.GOMAXPROCS(0), stdruntime.NumCPU())
}

0 comments on commit 801b3e5

Please sign in to comment.