feat: surgical header pruning for lean hpx_main (Godbolt Integration)#7262
feat: surgical header pruning for lean hpx_main (Godbolt Integration)#7262shivansh023023 wants to merge 8 commits into
Conversation
Up to standards ✅🟢 Issues
|
|
Can one of the admins verify this patch? |
| #include <hpx/runtime_configuration/runtime_mode.hpp> | ||
| #include <hpx/runtime_local/detail/runtime_local_fwd.hpp> | ||
| #include <hpx/runtime_local/shutdown_function.hpp> | ||
| #include <hpx/runtime_local/startup_function.hpp> |
There was a problem hiding this comment.
Please do not replace the modules headers with separate one from inside the HPX modules. This will break support for C++20 modules.
| #include <hpx/runtime_local/shutdown_function.hpp> | ||
| #include <hpx/runtime_local/startup_function.hpp> | ||
| #include <hpx/modules/resource_partitioner_fwd.hpp> | ||
| #include <hpx/modules/runtime_local_fwd.hpp> |
There was a problem hiding this comment.
I apologize if I was inconsise. We can't #include anything but the top-level module header files, even indirectly. The changes you made will still break C++20 module compilation. See here for the current results: https://github.com/TheHPXProject/hpx/actions/runs/25761564888/job/75663773512?pr=7262.
02c46ae to
1210e5c
Compare
1210e5c to
7a98352
Compare
|
@hkaiser I have implemented the atomic extraction strategy to resolve the module export and type-safety issues |
9752868 to
59575eb
Compare
| #include <hpx/modules/functional.hpp> | ||
| #include <hpx/modules/init_runtime_local.hpp> | ||
| #include <hpx/modules/program_options.hpp> | ||
| #include <hpx/modules/resource_partitioner.hpp> |
There was a problem hiding this comment.
You will need to keep this #include (to define partitioner_mode)
…px_init.hpp/hpx_init_params.hpp Phase 1 of GSoC Lean Entry header surgery. hpx_init.hpp: - Remove duplicate #include <hpx/modules/resource_partitioner.hpp> (already provided by hpx_init_params.hpp transitively) - Remove duplicate #include <hpx/modules/runtime_configuration.hpp> (already provided by hpx_init_params.hpp transitively) - Replace fat #include <hpx/modules/runtime_local.hpp> (40+ headers, pulls futures/io_service/threading_base/topology) with the lean #include <hpx/runtime_local/detail/runtime_local_fwd.hpp> (only hpx/config.hpp transitive cost) hpx_init_params.hpp: - Replace #include <hpx/modules/resource_partitioner.hpp> with #include <hpx/resource_partitioner/partitioner_fwd.hpp> (sufficient for partitioner_mode enum + partitioner& reference) - Replace #include <hpx/modules/runtime_configuration.hpp> with #include <hpx/runtime_configuration/runtime_configuration_fwd.hpp> (forward decl of hpx::util::runtime_configuration is sufficient here) - Replace #include <hpx/modules/runtime_local.hpp> with #include <hpx/runtime_local/detail/runtime_local_fwd.hpp> - Add #include <hpx/runtime_configuration/runtime_mode.hpp> to satisfy hpx::runtime_mode enum used in struct init_params Estimated reduction: ~25,000-32,000 pre-processed lines (28-38%) from the hpx/hpx_main.hpp include chain. Signed-off-by: Hackathon User <hackathon@example.com> Signed-off-by: Shivansh <singhshivansh023@gmail.com>
…local umbrella Replace fat #include <hpx/modules/init_runtime_local.hpp> umbrella with direct sub-headers: - hpx/init_runtime_local/init_runtime_local.hpp (provides app_name, default_desc, dummy_argc/argv used by hpx::init_params) - hpx/init_runtime_local/macros.hpp (provides HPX_APPLICATION_STRING, only pulls config.hpp + preprocessor.hpp) This bypasses the cmake-generated umbrella re-exporter while preserving all required symbols. The direct sub-header includes are alphabetized per HPX style conventions. Also update copyright year to 2026 (Hartmut Kaiser line). Signed-off-by: Hackathon User <hackathon@example.com> Signed-off-by: Shivansh <singhshivansh023@gmail.com>
…include Phase 1 GSoC Lean Entry header surgery. Replaced #include <hpx/modules/runtime_local.hpp> with forward declarations to hit the 30-40% line reduction target. - Replaced full runtime_local header with detail/runtime_local_fwd.hpp - Moved inline dump_config::operator()() out of the header and into init_runtime_local.cpp so it doesn't require the full hpx::runtime class - Manually forward-declared on_exit and on_abort in the header to break dependency on runtime_local_fwd.hpp - Added hpx/runtime_configuration/runtime_mode.hpp to satisfy hpx::runtime_mode usage Signed-off-by: Hackathon User <hackathon@example.com> Signed-off-by: Shivansh <singhshivansh023@gmail.com>
Remove fat umbrella headers from hpx_init_impl.hpp and hpx_start_impl.hpp that were redundant — all needed symbols already flow in transitively via the include chain we slimmed in previous commits. hpx_init_impl.hpp: - Remove #include <hpx/modules/init_runtime_local.hpp> (already via hpx_init.hpp -> hpx_init_params.hpp -> lean hpx/init_runtime_local/init_runtime_local.hpp) - Remove #include <hpx/modules/runtime_configuration.hpp> (AGAS/distributed factory registry — not used here; HPX_PREFIX comes from macros.hpp pulled by init_runtime_local) - Remove #include <hpx/modules/runtime_local.hpp> (init_helper + dummy_argc/argv already in init_runtime_local.hpp) hpx_start_impl.hpp: - Same three removals for identical reasons hpx_user_main_config.hpp: - Fix copyright year typo: 2055 -> 2025 - Confirmed lean: only config.hpp + <vector> + <string> (no transitives) Signed-off-by: Hackathon User <hackathon@example.com> Signed-off-by: Shivansh <singhshivansh023@gmail.com>
Address maintainer feedback (hkaiser): internal headers from inside the HPX modules must not be used directly as this breaks support for C++20 modules. Restore hpx/modules/ umbrella paths in all three files. init_runtime_local/init_runtime_local.hpp: - Restore #include <hpx/modules/resource_partitioner.hpp> (replaces internal hpx/resource_partitioner/partitioner_fwd.hpp) - Restore #include <hpx/modules/runtime_local.hpp> (replaces 4 internal paths: runtime_local_fwd, runtime_mode, shutdown_function, startup_function) hpx_init_params.hpp: - Restore #include <hpx/modules/init_runtime_local.hpp> - Restore #include <hpx/modules/resource_partitioner.hpp> - Restore #include <hpx/modules/runtime_configuration.hpp> - Restore #include <hpx/modules/runtime_local.hpp> (replaces internal hpx/init_runtime_local/* and hpx/runtime_*/* paths) hpx_init.hpp: - Restore #include <hpx/modules/runtime_local.hpp> (replaces internal hpx/runtime_local/detail/runtime_local_fwd.hpp) Preserved savings from Phase 1 that comply with C++20 module rules: - Removed true duplicates from hpx_init.hpp (resource_partitioner, runtime_configuration which were already in hpx_init_params.hpp) - Removed redundant umbrella copies from hpx_init_impl.hpp / hpx_start_impl.hpp - dump_config::operator()() moved out of header into .cpp (no header change) - Copyright typo fixed: 2055 -> 2025 in hpx_user_main_config.hpp - Copyright year updated: 2023 -> 2026 in hpx_init_params.hpp Signed-off-by: Hackathon User <hackathon@example.com> Signed-off-by: Shivansh <singhshivansh023@gmail.com>
Implement the 'Modular Forward Re-exporter' pattern to satisfy the C++20
module boundary requirement while preserving the lean entry-point surgery.
Created 3 new modular re-exporter headers in hpx/modules/ paths:
[NEW] hpx/modules/runtime_local_fwd.hpp
- Re-exports: detail/runtime_local_fwd.hpp, shutdown_function.hpp,
startup_function.hpp
- Savings vs full umbrella: 38,604 preprocessed lines (23%)
[NEW] hpx/modules/resource_partitioner_fwd.hpp
- Re-exports: partitioner_fwd.hpp
- Marginal savings (partitioner_fwd already pulls threading_base)
[NEW] hpx/modules/runtime_configuration_fwd.hpp
- Re-exports: runtime_configuration_fwd.hpp, runtime_mode.hpp
- Savings vs full umbrella: 139,598 preprocessed lines (84%)
Updated consumers to use modular paths (hpx/modules/*_fwd.hpp):
- init_runtime_local/init_runtime_local.hpp
- hpx_init_params.hpp
- hpx_init.hpp
All includes stay within hpx/modules/ for C++20 module compatibility
per maintainer (hkaiser) feedback.
Signed-off-by: Hackathon User <hackathon@example.com>
Signed-off-by: Shivansh <singhshivansh023@gmail.com>
Address maintainer directive: no including anything but top-level module
header files, even indirectly. Sub-module headers and re-exporter headers
both break C++20 module compilation due to symbol redefinition.
The fix: manual forward declarations for all types that were previously
obtained via sub-module includes.
Deleted re-exporter files (created in previous attempt):
- libs/core/runtime_local/include/hpx/modules/runtime_local_fwd.hpp
- libs/core/resource_partitioner/include/hpx/modules/resource_partitioner_fwd.hpp
- libs/core/runtime_configuration/include/hpx/modules/runtime_configuration_fwd.hpp
init_runtime_local/init_runtime_local.hpp:
- Removed: modules/resource_partitioner_fwd.hpp, modules/runtime_local_fwd.hpp
- Added manual forward declarations:
class runtime;
using startup_function_type = hpx::move_only_function<void()>;
using shutdown_function_type = hpx::move_only_function<void()>;
enum class partitioner_mode : std::int8_t;
class partitioner;
- Moved partitioner_mode default initializer to constructor via
static_cast<partitioner_mode>(0) to avoid needing the full enum
hpx_init_params.hpp:
- Removed: modules/resource_partitioner_fwd.hpp,
modules/runtime_configuration_fwd.hpp, modules/runtime_local_fwd.hpp
- Added manual forward declaration: enum class runtime_mode : std::int8_t;
- Moved runtime_mode and partitioner_mode default initializers to
constructor via static_cast (runtime_mode::default_ = 4,
partitioner_mode::default_ = 0)
- Kept only top-level module headers: modules/functional.hpp,
modules/init_runtime_local.hpp, modules/program_options.hpp
hpx_init.hpp:
- Removed: modules/runtime_local_fwd.hpp (file deleted)
All .cpp files retain full umbrella includes for complete definitions.
Signed-off-by: Hackathon User <hackathon@example.com>
Signed-off-by: Shivansh <singhshivansh023@gmail.com>
…nts, no TBB dep
- Create libs/core/resource_partitioner/include/hpx/modules/resource_partitioner_mode.hpp
A new atomic modular header under the hpx/modules/ path that exposes only
hpx::resource::partitioner_mode without pulling in the full umbrella.
This satisfies Hartmut's 'top-level modular path only' rule while avoiding
the heavy transitive dependencies of the full resource_partitioner umbrella
(partitioner.hpp + partitioner_fwd.hpp -> functional.hpp + threading_base.hpp).
- Create libs/core/resource_partitioner/include/hpx/resource_partitioner/partitioner_mode.hpp
Lightweight atomic internal header: only hpx/config.hpp + <cstdint> + the enum.
Mirrors runtime_mode.hpp. Registered in CMakeLists.txt HEADERS list.
- Create libs/core/runtime_configuration/include/hpx/modules/runtime_mode.hpp
A new atomic modular header under the hpx/modules/ path that exposes only
hpx::runtime_mode without pulling in the full runtime_configuration umbrella.
Registered in runtime_configuration/CMakeLists.txt HEADERS list.
- Refactor partitioner_fwd.hpp to #include partitioner_mode.hpp instead of
duplicating the enum definition, eliminating ODR risk.
- Update init_runtime_local.hpp:
- Include <hpx/modules/resource_partitioner_mode.hpp> (modular atomic path)
and <hpx/modules/runtime_mode.hpp> in place of the previous
forward declarations. Enum constants are now fully defined, not just declared.
- Revert init_params::rp_mode to idiomatic member default initialization
(= ::hpx::resource::partitioner_mode::default_) per original master style.
- Forward-declare only hpx::runtime and hpx::resource::partitioner (classes)
since their full definitions are only needed in .cpp translation units.
- Update hpx_init_params.hpp:
- Use <hpx/modules/resource_partitioner_mode.hpp> and <hpx/modules/runtime_mode.hpp>
(lean) instead of the full <hpx/modules/resource_partitioner.hpp> and
<hpx/modules/runtime_configuration.hpp> umbrellas.
- Idiomatic member default initialization for mode and rp_mode in init_params.
- Alphabetize HPX module includes; remove leftover <cstdint>.
- Fix bitwise operators in partitioner_mode.hpp:
- Restore HPX_CXX_CORE_EXPORT on operator& and as_bool (matches master).
- Add new exported operators: operator|, operator^, operator~ for full
bitwise enum support.
- Restore #include <hpx/modules/runtime_local.hpp> in hpx_init.hpp to
preserve the public API surface (hpx::get_os_thread_count etc).
- Remove TBB linkage (find_library / target_link_libraries) from
libs/CMakeLists.txt as explicitly requested by the maintainer.
No hard dependency on TBB is introduced by this PR.
- Fix macOS build: add missing #include <iostream> to
duplicate_id_registration_1596.cpp (bare cout/endl via using namespace std).
- Copyright dates updated to 2026 on modified/new files.
Signed-off-by: Shivansh <singhshivansh023@gmail.com>
59575eb to
b9acc93
Compare
|
@hkaiser The hpx_main footprint has officially dropped from 400,950 down to 169,505 lines |
|
@shivansh023023 Could you please have an eye on the CIs yourself? We see some compilation problems, still. |
Fixes
This PR addresses the "Entry-Point Tax" and modular ergonomics required for the "Zero-Config" architecture.
Proposed Changes
Surgical Header Pruning: Replaced "fat" umbrella headers—specifically
runtime_local.hpp,resource_partitioner.hpp, andruntime_configuration.hpp—with targeted forward-declaration headers (_fwd.hpp).Implementation Decoupling: Moved the
dump_configimplementation out of the header intolibs/core/init_runtime_local/src/init_runtime_local.cpp, leaving only a leanHPX_CORE_EXPORTdeclaration.Transitive Elimination: Removed approximately 54 transitive header inclusions from the
hpx_main.hppentry-point path.Forward Declaration Gating: Manually added forward declarations for
hpx::detail::on_exit()andhpx::detail::on_abort(int)to decouple the header from intermediate fat umbrellas.Copyright Updates: Verified BSL-1.0 license headers and updated copyright years to 2026 where applicable.
Any background context you want to provide?
The goal of this refactor is to reduce the "Complexity Wall" that hinders library adoption in lightweight, browser-based environments like Compiler Explorer (Godbolt).
Currently, the standard entry point is architecturally coupled with the distributed runtime, pulling in the network stack, AGAS, and parcelports transitively.
By gating these transitives behind forward declarations, we ensure that local-only users no longer pay the "header tax" or "binary bloat" of the distributed runtime.
Quantitative Results
Checklist
Not all points below apply to all pull requests.
#Before