Missing includes are problematic, because:
- Upcoming releases of a C++ standard library implementation often minimize their internal header dependencies. For example,
_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
(https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html). This can lead to compile failures, which are easy to fix for developers, but may not be for users. For example, commit 138f8671569f7ebb8c84e9d80c44cddeda9e3845 had to add missing includes to accommodate GCC 15 (and the commit had to be backported). - A Bitcoin Core developer removing a feature from a module and wanting to drop the now unused includes may not be able to do so without touching other unrelated files, because those files rely on the transitive includes.
Moreover, missing or extraneous includes are problematic, because they may be confusing the code reader as to what the real dependencies are.
Finally, extraneous includes may slow down the build.
Fix all issues in bench
, by applying the rule include-what-you-use (iwyu).
Follow-up pull requests will handle the other places.