forked from bnb-chain/op-geth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add metrics and do validate and commit concurrently
chore: block tx metrics feat: do BlockBody verification concurrently feat: do the calculation of intermediate root concurrently. feat: commit the MPTs concurrently feat: async update difflayer feat: do state verification concurrently chore: change validate time metrics chore: change execute time metrices fix: add flush mutex for nodebufferlist fix: miner set expected root hash test: set expected root test: change set expected root
- Loading branch information
1 parent
0b1f3ed
commit c69cbf2
Showing
10 changed files
with
583 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package gopool | ||
|
||
import ( | ||
"runtime" | ||
"time" | ||
|
||
"github.com/panjf2000/ants/v2" | ||
) | ||
|
||
var ( | ||
// Init a instance pool when importing ants. | ||
defaultPool, _ = ants.NewPool(ants.DefaultAntsPoolSize, ants.WithExpiryDuration(10*time.Second)) | ||
minNumberPerTask = 5 | ||
) | ||
|
||
// Submit submits a task to pool. | ||
func Submit(task func()) error { | ||
return defaultPool.Submit(task) | ||
} | ||
|
||
// Running returns the number of the currently running goroutines. | ||
func Running() int { | ||
return defaultPool.Running() | ||
} | ||
|
||
// Cap returns the capacity of this default pool. | ||
func Cap() int { | ||
return defaultPool.Cap() | ||
} | ||
|
||
// Free returns the available goroutines to work. | ||
func Free() int { | ||
return defaultPool.Free() | ||
} | ||
|
||
// Release Closes the default pool. | ||
func Release() { | ||
defaultPool.Release() | ||
} | ||
|
||
// Reboot reboots the default pool. | ||
func Reboot() { | ||
defaultPool.Reboot() | ||
} | ||
|
||
func Threads(tasks int) int { | ||
threads := tasks / minNumberPerTask | ||
if threads > runtime.NumCPU() { | ||
threads = runtime.NumCPU() | ||
} else if threads == 0 { | ||
threads = 1 | ||
} | ||
return threads | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.