Add precompiled header support for fc and sysio_chain#255
Open
Add precompiled header support for fc and sysio_chain#255
Conversation
Introduces PCH for the two heaviest libraries, reducing clean build wall time by ~45% (2m55s → 1m36s). Controlled via -DENABLE_PCH=ON (default ON). PCH includes all frequently used Boost headers (multiprecision, multi_index, asio, beast, iostreams, signals2, etc.), stable STL headers, and the most widely included fc/chain project headers. Replaces boost::range usage with std::ranges/std::find in authority_checker.hpp and parallel_markers.hpp to avoid ADL ambiguity when <ranges> and boost/range are both in scope.
jglanz
requested changes
Mar 17, 2026
Collaborator
jglanz
left a comment
There was a problem hiding this comment.
I'd prefer if the content was under cmake/include/sysio-pch.hpp
I generally don't love PCH's due to staleness and traceability - but given the compilation improvement, as long as its clean, I wont argue too much
cmake/precompiled-headers.cmake
Outdated
Comment on lines
+38
to
+74
| target_precompile_headers(${target} PRIVATE | ||
| # --- C++ standard library --- | ||
| <algorithm> | ||
| <fstream> | ||
| <iostream> | ||
| <limits> | ||
| <memory> | ||
| <ranges> | ||
| <sstream> | ||
| <string> | ||
| <string_view> | ||
| <vector> | ||
|
|
||
| # --- Boost: multiprecision (single heaviest header; used by variant, datastream, raw, int256) --- | ||
| <boost/multiprecision/cpp_int.hpp> | ||
|
|
||
| # --- Boost: multi_index (used by tracked_storage, various indices) --- | ||
| <boost/multi_index_container.hpp> | ||
| <boost/multi_index_container_fwd.hpp> | ||
| <boost/multi_index/ordered_index.hpp> | ||
| <boost/multi_index/hashed_index.hpp> | ||
| <boost/multi_index/member.hpp> | ||
| <boost/multi_index/mem_fun.hpp> | ||
| <boost/multi_index/composite_key.hpp> | ||
| <boost/multi_index/global_fun.hpp> | ||
|
|
||
| # --- Boost: iostreams (used by json.cpp, zlib.cpp, random_access_file) --- | ||
| <boost/iostreams/filtering_stream.hpp> | ||
| <boost/iostreams/device/back_inserter.hpp> | ||
| <boost/iostreams/device/array.hpp> | ||
| <boost/iostreams/device/mapped_file.hpp> | ||
| <boost/iostreams/stream.hpp> | ||
| <boost/iostreams/filter/zlib.hpp> | ||
| <boost/iostreams/categories.hpp> | ||
| <boost/iostreams/pipeline.hpp> | ||
| <boost/iostreams/positioning.hpp> | ||
|
|
Collaborator
There was a problem hiding this comment.
I'd prefer if the content was under cmake/include/sysio-pch.hpp
I generally don't love PCH's due to staleness and traceability
Contributor
Author
There was a problem hiding this comment.
We could limit it to standard and boost if you prefer.
Extract inline header lists from cmake/precompiled-headers.cmake into a shared sysio-pch.hpp file. Both fc and sysio_chain targets now reference the same header; chain-only includes are guarded with __has_include so the fc PCH compilation silently skips them. Benchmark (fc + sysio_chain clean build, 12-core, clang-18, Debug): | Config | Wall | vs Full | |-------------------------------|---------|---------| | Full PCH (STL+Boost+fc+chain) | 1:46 | — | | No sysio/* headers | 2:09 | +21% | | No fc/* or sysio/* headers | 2:24 | +36% | Project headers earn their keep — keeping them in.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fcandsysio_chain), controlled via-DENABLE_PCH=ON(default ON)boost::rangeusage withstd::ranges/std::findinauthority_checker.hppandparallel_markers.hppto resolve ADL ambiguity betweenboost::range::findandstd::ranges::findBenchmark (clean build of fc + sysio_chain, 12-core, clang-18, Debug)