Skip to content

Optimize build: Simplify and cleanup ComposePlugin and DeterminePlugin (Part 3)#918

Open
azeey wants to merge 4 commits into
mainfrom
azeey/speedup_compose_plugin
Open

Optimize build: Simplify and cleanup ComposePlugin and DeterminePlugin (Part 3)#918
azeey wants to merge 4 commits into
mainfrom
azeey/speedup_compose_plugin

Conversation

@azeey
Copy link
Copy Markdown
Contributor

@azeey azeey commented Mar 25, 2026

🎉 New feature

Needs:

Summary

This PR simplifies the feature aggregation logic by replacing the binary-tree ComposePlugin, CheckRequirements, and IterateList mechanisms with a simple tail-recursive ComposePluginFromList.

In addition, because ExtractAPI already computes a flat TypeList of unique base classes, we can feed those directly into ComposePluginFromList to construct the linear inheritance chain of SpecializedPlugins required by gz-plugin without the need for complex std::is_void_v branching.

This completely removes the need for GetNext, IterateList, and Aggregate.

Test it

Compare against main by building the code while measuring memory consumption

/usr/bin/time -v make gz-physics-dartsim-plugin

I get similar results as in #917, with slightly less memory consumption. The point of this PR is to simplify and clean up the code.

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the feature
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

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-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

azeey added 4 commits March 24, 2026 23:19
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.

Generated-By: Gemini 3.0 Pro
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
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>
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.

Generated-By: Gemini 3.0 Pro
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
…st walk

This commit drastically simplifies the feature aggregation logic by replacing
the legacy binary-tree `ComposePlugin`, `CheckRequirements`, and `IterateList`
mechanisms with a simple tail-recursive `ComposePluginFromList`.

Because `ExtractAPI` already computes a flat `TypeList` of unique base
classes, we can feed those directly into `ComposePluginFromList` to construct
the linear inheritance chain of `SpecializedPlugin`s required by `gz-plugin`
without the need for complex `std::is_void_v` branching.

This completely removes the need for `GetNext`, `IterateList`, and
`Aggregate`. Added documentation explaining the linear inheritance chain.

Generated-By: Gemini 3.0 Pro
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Mar 25, 2026
@azeey azeey mentioned this pull request Mar 25, 2026
11 tasks
Base automatically changed from azeey/speedup_typelist_core to main April 20, 2026 19:34
@caguero
Copy link
Copy Markdown
Contributor

caguero commented May 11, 2026

@azeey , there are some conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants