Optimize build: Reduce compiler memory usage by introducing TypeList (Part 2) (backport #953) - #968
Open
mergify[bot] wants to merge 1 commit into
Open
Optimize build: Reduce compiler memory usage by introducing TypeList (Part 2) (backport #953)#968mergify[bot] wants to merge 1 commit into
mergify[bot] wants to merge 1 commit into
Conversation
Contributor
Author
|
Cherry-pick of cc44170 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Merged
12 tasks
azeey
force-pushed
the
mergify/bp/gz-physics7/pr-953
branch
from
May 1, 2026 17:10
487735f to
56ba9c1
Compare
Contributor
|
Can I get a review on this since I fixed conflicts? |
iche033
approved these changes
May 1, 2026
…(Part 2) (#953) * Optimize build: Reduce compiler memory usage by introducing TypeList (Part 2) (#917) * Replace custom void_t with std::void_t Replaced the legacy custom implementation of `void_t` in `TemplateHelpers.hh` with `std::void_t` from `<type_traits>`, fulfilling the existing TODO to migrate to standard C++17 metaprogramming types. * Optimize InspectFeatures with C++17 fold expressions Replaced the recursive template traversal in `InspectFeatures` with flat C++17 fold expressions over the `FeatureTuple`. This significantly reduces compile-time template instantiation depth and improves runtime performance for feature verification. Generated-By: Gemini 3.0 Pro Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> * Optimize compiler memory by introducing TypeList This commit introduces a lightweight `TypeList` to replace `std::tuple` for intermediate template metaprogramming operations (filtering, flattening, and deduping feature lists). By using `TypeList` and C++17 fold expressions instead of recursive `std::tuple` instantiations, we drastically reduce compiler memory consumption (Max RSS) and build times. The public API retains `std::tuple` for backward compatibility, but internal operations are fully modernized. * Tuple -> TypeList everywhere a TypeList expected rather than std::tuple * Refactor intermediate metaprogramming to use TypeList instead of std::tuple This change completes the transition from `std::tuple` to `TypeList` for intermediate feature and entity metaprogramming operations. Utilizing `TypeList` for internal metadata containers avoids the significant compiler memory overhead associated with instantiating `std::tuple` and its associated logic. The `FeatureList` API boundaries retain `std::tuple` to ensure backward compatibility, but internal operations like `CombineLists`, `ExtractFeatures`, and entity downcast verification now rely solely on `TypeList`. The helper structs `ToTuple` and `TupleToTypeList` have also been moved to the `detail` namespace to prevent global namespace pollution. Generated-By: Gemini 3.0 Pro Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> (cherry picked from commit 1c4f296) * Restore backward compatibility for UpcastIdentifiers Reverted UpcastIdentifiers from TypeList to std::tuple in public macros to maintain source compatibility. Added support for std::tuple to TypeListContainsBase to handle both types. Generated-By: Gemini 3.0 Pro Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> --------- Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> Co-authored-by: Addisu Z. Taddese <addisuzt@intrinsic.ai> Co-authored-by: Jose Luis Rivero <jrivero@honurobotics.com>
luca-della-vedova
force-pushed
the
mergify/bp/gz-physics7/pr-953
branch
from
July 1, 2026 07:05
56ba9c1 to
12f411b
Compare
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.
🎉 New feature
Needs #916
Summary
This commit introduces a lightweight
TypeListto replacestd::tuplefor intermediate template metaprogramming operations (filtering, flattening, and deduping feature lists).By using
TypeListand C++17 fold expressions instead of recursivestd::tupleinstantiations, we drastically reduce compiler memory consumption (Max RSS) and build times. The public API retainsstd::tuplefor backward compatibility, but internal operations are fully modernized.Using GNU time, I measured a 33% peak RSS memory reduction on macOS and 68.9% reduction on Linux 🎉 (inside a VM with no swap).
Test it
Compare against
mainby building the code while measuring memory consumptionResults from Linux test
Before this change:
After this PR:
Checklist
codecheckpassed (See contributing)Generated-By: Gemini 3.0 Pro
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.
This is an automatic backport of pull request #917 done by Mergify.
This is an automatic backport of pull request #953 done by Mergify.