hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
266 stars 119 forks source link

Platform ForJoinPool should use async mode #13967

Closed OlegMazurov closed 2 weeks ago

OlegMazurov commented 2 weeks ago

Problem

ForkJoinPool.java:

asyncMode if true, establishes local first-in-first-out scheduling mode for forked tasks that are never joined. This mode may be more appropriate than default locally stack-based mode in applications in which worker threads only process event-style asynchronous tasks.

The platform pool is currently created by DefaultExecutorFactory.createForkJoinPool() with asyncMode = false. Newly forked tasks are executed by pool threads first and execution of already scheduled tasks may get delayed. This maybe the reason why some components with light tasks create backlog large enough to trigger back-pressure.

We should try switching to asyncMode = true, which fits platform's mode of execution (FIFO instead of LIFO), and evaluate its effect.

Solution

Create the platform ForkJoinPool with asyncMode = true.

Alternatives

No response