Skip to content

Add precompiled header support for fc and sysio_chain#255

Open
heifner wants to merge 2 commits intomasterfrom
feature/pch
Open

Add precompiled header support for fc and sysio_chain#255
heifner wants to merge 2 commits intomasterfrom
feature/pch

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented Mar 16, 2026

Summary

  • Adds precompiled header (PCH) support for the two heaviest build targets (fc and sysio_chain), controlled via -DENABLE_PCH=ON (default ON)
  • Includes all frequently used Boost headers (multiprecision, multi_index, asio, beast, iostreams, signals2, etc.), stable STL headers, and widely included fc/chain project headers
  • Replaces boost::range usage with std::ranges/std::find in authority_checker.hpp and parallel_markers.hpp to resolve ADL ambiguity between boost::range::find and std::ranges::find

Benchmark (clean build of fc + sysio_chain, 12-core, clang-18, Debug)

Wall time CPU time
Without PCH 2:54.55 3013.60s
With PCH 1:36.06 1128.80s
Speedup 45% 63%

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.
@heifner heifner requested a review from jglanz March 16, 2026 19:31
Copy link
Copy Markdown
Collaborator

@jglanz jglanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@heifner heifner requested a review from jglanz March 18, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants