mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-01 18:49:15 +01:00
38fd85c676http: replace WorkQueue and threads handling for ThreadPool (furszy)c323f882edfuzz: add test case for threadpool (TheCharlatan)c528dd5f8cutil: introduce general purpose thread pool (furszy)6354b4fd7ftests: log node JSON-RPC errors during test setup (furszy)45930a7941http-server: guard against crashes from unhandled exceptions (furszy) Pull request description: This has been a recent discovery; the general thread pool class created for #26966, cleanly integrates into the HTTP server. It simplifies init, shutdown and requests execution logic. Replacing code that was never unit tested for code that is properly unit and fuzz tested. Although our functional test framework extensively uses this RPC interface (that’s how we’ve been ensuring its correct behavior so far - which is not the best). This clearly separates the responsibilities: The HTTP server now focuses solely on receiving and dispatching requests, while ThreadPool handles concurrency, queuing, and execution. This will also allows us to experiment with further performance improvements at the task queuing and execution level, such as a lock-free structure or task prioritization or any other implementation detail like coroutines in the future, without having to deal with HTTP code that lives on a different layer. Note: The rationale behind introducing the ThreadPool first is to be able to easily cherry-pick it across different working paths. Some of the ones that are benefited from it are #26966 for the parallelization of the indexes initial sync, #31132 for the parallelization of the inputs fetching procedure, #32061 for the libevent replacement, the kernel API #30595 (https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2413702370) to avoid blocking validation among others use cases not publicly available. Note 2: I could have created a wrapper around the existing code and replaced the `WorkQueue` in a subsequent commit, but it didn’t seem worth the extra commits and review effort. The `ThreadPool` implements essentially the same functionality in a more modern and cleaner way. ACKs for top commit: Eunovo: ReACK38fd85c676sedited: Re-ACK38fd85c676pinheadmz: ACK38fd85c676Tree-SHA512: a0330e54ed504330ca874c42d4e318a909f548b2fb9ac46db8badf5935b9eec47dc4ed503d1b6f98574418e3473420ea45f60498be05545c4325cfa89dcca689