Skip to content

Commit e55f43a

Browse files
vasil-pashovVasil Pashov
and
Vasil Pashov
authored
Improve full build time by 30% by adding PCH (#1764)
#### Reference Issues/PRs **Reduce full build time by 30%** on Windows CI and local builds (windows and linux) Add pre-compiled headers for the following targets: * arcticdb_core_object * arcticdb_python * test_unit_arcticdb * arcticdb_rapidcheck_tests Currently does not work on Linux CI because the compilers are old and incompatible with how CMake handles PCHs. PCH is off by default and can be enabled via CMake cache variable #### What does this implement or fix? #### Any other comments? #### Checklist <details> <summary> Checklist for code changes... </summary> - [ ] Have you updated the relevant docstrings, documentation and copyright notice? - [ ] Is this contribution tested against [all ArcticDB's features](../docs/mkdocs/docs/technical/contributing.md)? - [ ] Do all exceptions introduced raise appropriate [error messages](https://docs.arcticdb.io/error_messages/)? - [ ] Are API changes highlighted in the PR description? - [ ] Is the PR labelled as enhancement or bug so it appears in autogenerated release notes? </details> <!-- Thanks for contributing a Pull Request to ArcticDB! Please ensure you have taken a look at: - ArcticDB's Code of Conduct: https://github.com/man-group/ArcticDB/blob/master/CODE_OF_CONDUCT.md - ArcticDB's Contribution Licensing: https://github.com/man-group/ArcticDB/blob/master/docs/mkdocs/docs/technical/contributing.md#contribution-licensing --> --------- Co-authored-by: Vasil Pashov <[email protected]>
1 parent 8794adf commit e55f43a

File tree

3 files changed

+157
-1
lines changed

3 files changed

+157
-1
lines changed

cpp/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enable_testing()
1616

1717
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1818
set(ARCTICDB_MSVC_OMIT_RUNTIME_CHECKS OFF CACHE BOOL "")
19+
set(ARCTICDB_USE_PCH OFF CACHE BOOL "Whether to use precompiled headers")
1920
option(
2021
ARCTICDB_USING_CONDA
2122
"Whether ArcticDB's build system relies on conda for resolving its dependencies."

cpp/CMakePresets.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
"name": "windows",
6262
"hidden": true,
6363
"generator": "Ninja",
64-
"environment": {"cmakepreset_expected_host_system": "Windows"}
64+
"environment": { "cmakepreset_expected_host_system": "Windows" },
65+
"cacheVariables": {
66+
"ARCTICDB_USE_PCH": "ON"
67+
}
6568
},
6669
{
6770
"name": "windows-cl-debug",

cpp/arcticdb/CMakeLists.txt

+152
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,126 @@ set(arcticdb_srcs
507507

508508
add_library(arcticdb_core_object OBJECT ${arcticdb_srcs})
509509

510+
if(${ARCTICDB_USE_PCH})
511+
message(STATUS "Using precompiled headers for target arcticdb_core_object")
512+
set(BASE_PCH
513+
# STL
514+
<memory>
515+
<cstdint>
516+
<unordered_map>
517+
<vector>
518+
<stdexcept>
519+
<string>
520+
<array>
521+
<variant>
522+
<optional>
523+
<type_traits>
524+
<cstddef>
525+
<climits>
526+
<mutex>
527+
<string_view>
528+
<chrono>
529+
<atomic>
530+
<limits>
531+
<cstdlib>
532+
<utility>
533+
<iomanip>
534+
<sstream>
535+
<ctime>
536+
<map>
537+
<unordered_set>
538+
<iostream>
539+
<cassert>
540+
<functional>
541+
<list>
542+
<random>
543+
<fstream>
544+
<any>
545+
<cstdio>
546+
<algorithm>
547+
<queue>
548+
<exception>
549+
<deque>
550+
<ranges>
551+
<shared_mutex>
552+
<set>
553+
<thread>
554+
<filesystem>
555+
<typeinfo>
556+
<concepts>
557+
<numeric>
558+
559+
# Boost
560+
<boost/iterator_adaptors.hpp>
561+
<boost/circular_buffer.hpp>
562+
<boost/core/noncopyable.hpp>
563+
<boost/algorithm/string.hpp>
564+
<boost/container/small_vector.hpp>
565+
<boost/iterator/iterator_facade.hpp>
566+
<boost/noncopyable.hpp>
567+
568+
# Python
569+
# TODO: Won't be needed when we move all python conde to handlers outside of the core
570+
<Python.h>
571+
<pybind11/stl.h>
572+
<pybind11/pybind11.h>
573+
<pybind11/numpy.h>
574+
575+
# Proto
576+
<google/protobuf/io/zero_copy_stream_impl.h>
577+
<google/protobuf/text_format.h>
578+
<google/protobuf/any.pb.h>
579+
<google/protobuf/any.h>
580+
<google/protobuf/util/message_differencer.h>
581+
<google/protobuf/arena.h>
582+
583+
# Proto generated
584+
<descriptors.pb.h>
585+
<storage.pb.h>
586+
<lmdb_storage.pb.h>
587+
<mapped_file_storage.pb.h>
588+
<encoding.pb.h>
589+
<in_memory_storage.pb.h>
590+
<mongo_storage.pb.h>
591+
<s3_storage.pb.h>
592+
<utils.pb.h>
593+
<config.pb.h>
594+
<azure_storage.pb.h>
595+
<nfs_backed_storage.pb.h>
596+
597+
# Folly
598+
<folly/Function.h>
599+
<folly/hash/Hash.h>
600+
<folly/Range.h>
601+
<folly/container/Enumerate.h>
602+
<folly/Poly.h>
603+
<folly/ScopeGuard.h>
604+
<folly/portability/Time.h>
605+
<folly/gen/Base.h>
606+
607+
608+
# FMT
609+
<fmt/core.h>
610+
<fmt/format.h>
611+
<fmt/compile.h>
612+
<fmt/std.h>
613+
614+
# SPD Log
615+
<spdlog/spdlog.h>
616+
617+
# Bit Magic
618+
<bitmagic/bm.h>
619+
<bitmagic/bmserial.h>
620+
621+
# Misc
622+
<ankerl/unordered_dense.h>
623+
<third_party/recycle/src/recycle/shared_pool.hpp>
624+
<xxhash.h>
625+
<pcre.h>
626+
)
627+
target_precompile_headers(arcticdb_core_object PRIVATE ${BASE_PCH})
628+
endif()
629+
510630
if (WIN32)
511631
target_compile_options(
512632
arcticdb_core_object
@@ -650,6 +770,18 @@ set(arcticdb_python_srcs
650770

651771
add_library(arcticdb_python STATIC ${arcticdb_python_srcs})
652772

773+
if(${ARCTICDB_USE_PCH})
774+
message(STATUS "Using precompiled headers for target arcticdb_python")
775+
target_precompile_headers(
776+
arcticdb_python
777+
PRIVATE
778+
<Python.h>
779+
<pybind11/stl.h>
780+
<pybind11/pybind11.h>
781+
<pybind11/numpy.h>
782+
)
783+
endif()
784+
653785
target_link_libraries(arcticdb_python
654786
PUBLIC
655787
arcticdb_core_static
@@ -977,4 +1109,24 @@ if(${TEST})
9771109
endif()
9781110

9791111
gtest_discover_tests(arcticdb_rapidcheck_tests PROPERTIES DISCOVERY_TIMEOUT 60)
1112+
1113+
if(${ARCTICDB_USE_PCH})
1114+
message(STATUS "Using precompiled headers for target test_unit_arcticdb")
1115+
target_precompile_headers(
1116+
test_unit_arcticdb
1117+
PRIVATE
1118+
# GTest
1119+
<gtest/gtest.h>
1120+
<gtest/gtest_prod.h>
1121+
${BASE_PCH}
1122+
)
1123+
message(STATUS "Using precompiled headers for target target_precompile_headers")
1124+
target_precompile_headers(
1125+
arcticdb_rapidcheck_tests
1126+
PRIVATE
1127+
<rapidcheck/state.h>
1128+
<rapidcheck.h>
1129+
${BASE_PCH}
1130+
)
1131+
endif()
9801132
endif()

0 commit comments

Comments
 (0)