Skip to content

Commit

Permalink
Tune EthScheduler thread pools to avoid to recreate too many threads (h…
Browse files Browse the repository at this point in the history
…yperledger#4529)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored and eum602 committed Nov 3, 2023
1 parent 1817c2b commit 336e974
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Improved RLP processing of zero-length string as 0x80 [#4283](https://github.com/hyperledger/besu/pull/4283) [#4388](https://github.com/hyperledger/besu/issues/4388)
- Increased level of detail in JSON-RPC parameter error log messages [#4510](https://github.com/hyperledger/besu/pull/4510)
- New unstable configuration options to set the maximum time, in milliseconds, a PoS block creation jobs is allowed to run [#4519](https://github.com/hyperledger/besu/pull/4519)
- Tune EthScheduler thread pools to avoid to recreate too many threads [#4529](https://github.com/hyperledger/besu/pull/4529)

### Bug Fixes
- Corrects emission of blockadded events when rewinding during a re-org. Fix for [#4495](https://github.com/hyperledger/besu/issues/4495)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ public EthScheduler(
final MetricsSystem metricsSystem) {
this(
MonitoredExecutors.newFixedThreadPool(
EthScheduler.class.getSimpleName() + "-Workers", syncWorkerCount, metricsSystem),
EthScheduler.class.getSimpleName() + "-Workers", 1, syncWorkerCount, metricsSystem),
MonitoredExecutors.newScheduledThreadPool(
EthScheduler.class.getSimpleName() + "-Timer", 1, metricsSystem),
MonitoredExecutors.newBoundedThreadPool(
EthScheduler.class.getSimpleName() + "-Transactions",
1,
txWorkerCount,
txWorkerQueueSize,
metricsSystem),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@
public class MonitoredExecutors {

public static ExecutorService newFixedThreadPool(
final String name, final int workerCount, final MetricsSystem metricsSystem) {
return newFixedThreadPool(name, 0, workerCount, new LinkedBlockingQueue<>(), metricsSystem);
final String name,
final int minWorkerCount,
final int workerCount,
final MetricsSystem metricsSystem) {
return newFixedThreadPool(
name, minWorkerCount, workerCount, new LinkedBlockingQueue<>(), metricsSystem);
}

public static ExecutorService newBoundedThreadPool(
final String name,
final int workerCount,
final int queueSize,
final MetricsSystem metricsSystem) {
return newBoundedThreadPool(name, 0, workerCount, queueSize, metricsSystem);
return newBoundedThreadPool(name, 1, workerCount, queueSize, metricsSystem);
}

public static ExecutorService newBoundedThreadPool(
Expand Down Expand Up @@ -77,8 +81,8 @@ private static ExecutorService newFixedThreadPool(
new ThreadPoolExecutor(
minWorkerCount,
maxWorkerCount,
0L,
TimeUnit.MILLISECONDS,
60L,
TimeUnit.SECONDS,
workingQueue,
threadFactory,
rejectedExecutionHandler));
Expand Down

0 comments on commit 336e974

Please sign in to comment.