Skip to content

Allow opting out of the runtime downcast assertion - #2477

Open
ryazwinski wants to merge 1 commit into
NVIDIA:mainfrom
ryazwinski:claw-stdexec-downcast-assert
Open

ryazwinski wants to merge 1 commit into
NVIDIA:mainfrom
ryazwinski:claw-stdexec-downcast-assert

Conversation

@ryazwinski

Copy link
Copy Markdown

The runtime assertion in __polymorphic_downcast calls dynamic_cast before returning the static_cast. It is frequently reached by OpenBMC PLDM's type-erased scheduler and sender when polling sensors. On an ARM BMC, the runtime type checks are a measurable cost even when the types are correct.

The default is unchanged. An embedding build may define STDEXEC_DISABLE_POLYMORPHIC_DOWNCAST_ASSERT consistently for code sharing these inline definitions. It then loses this diagnostic, but keeps the compile-time constraints and every other assertion. This option does not make a downcast valid when the caller violates the existing type invariant.

A two-mode ARM compile fixture checked that the default instantiation retains the runtime cast, the opt-in instantiation does not, and an unrelated assertion remains present in both. A Yosemite 4 lab A/B/A with polling unchanged reproduced the CPU improvement, and the full image passed an eight-slot discovery and sensor freshness smoke test.

The runtime downcast check is useful for catching bad type-erasure
invariants, but it can dominate CPU time in a hot asynchronous path.
For example, OpenBMC's PLDM sensor loop awaits a request per reading,
and the erased scheduler and sender exercise this helper on every
round trip.

Keep the check enabled by default. Let a consumer consistently define
STDEXEC_DISABLE_POLYMORPHIC_DOWNCAST_ASSERT for a build that needs to
opt out of this one check. Preserve the existing static cast,
compile-time constraints, and all other assertions.
@copy-pr-bot

copy-pr-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericniebler

Copy link
Copy Markdown
Collaborator

isn't the dynamic_cast removed when compiling in release mode?

@ryazwinski

Copy link
Copy Markdown
Author

yea it would be.. not sure why it's enabled in Openbmc/pldmd.. lemme do some digging.. will circle back.

This branch has not been deployed

No deployments
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