Skip to content

skip transform_sender's steps when neither transforms the sender - #2550

Merged
ericniebler merged 3 commits into
NVIDIA:mainfrom
ericniebler:transform-sender-fast-path
Nov 27, 2026
Merged

ericniebler merged 3 commits into
NVIDIA:mainfrom
ericniebler:transform-sender-fast-path

Conversation

@ericniebler

Copy link
Copy Markdown
Collaborator

transform_sender(sndr, env) composes a step for the completing domain and a step for the starting domain, and each step computes its result with consteval functions and variables of its own, for every sender and environment that gets connected. usually neither step does anything: neither domain has a transformation for the sender, and its tag has none either. then transform_sender now returns the sender as it is, without composing the steps (__leaves_alone, from each step's own test). the result is unchanged: a reference to the sender, noexcept.

the composition was named in a default template argument of the other overload, and default template arguments are substituted before constraints are checked, so it's now named in that overload's return type. (clang 16 substitutes the return type first anyway, so it doesn't save anything there.)

clang 22, frontend only, on test_merge_each_threaded.cpp: with STDEXEC_ENABLE_EXTRA_TYPE_CHECKING, peak memory 5.9 GB → 5.3 GB (-11%) and 10% fewer types; without, 2.6 GB → 2.4 GB (-9%).

🤖 Generated with Claude Code

ericniebler and others added 3 commits November 26, 2026 15:55
`transform_sender(sndr, env)` composes two steps, one for the domain where
the sender completes and one for the domain where its operation starts, and
each step computes its result with consteval functions and variables of its
own, for each sender and environment. For most senders neither step does
anything: neither domain has a transformation for the sender, and its tag has
none either. In that case `transform_sender` now returns the sender as it is,
without composing the steps (`__leaves_alone`, from each step's own test). The
result is the same as before: a reference to the sender.

The composition was named in a default template argument of the other
overload, and default template arguments are substituted before constraints
are checked, so it is now named in that overload's return type instead.

Clang 22, frontend only, on test_merge_each_threaded.cpp: with
STDEXEC_ENABLE_EXTRA_TYPE_CHECKING, peak memory goes from 5.9 GB to 5.3 GB
(-11%), with 10% fewer types; without it, from 2.6 GB to 2.4 GB (-9%).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`__leaves_alone` named `__has_tag_transform_sender` in an `&&`, but a concept-id
is checked when the initializer is instantiated, even where `&&` skips it. For
a sender that a domain transforms, such as exec::ensure_started under nvexec's
stream_domain, that checked the tag's default transformation, whose deduced
return type instantiates exec's generic, host-only shared receiver. Clang CUDA
then reported it referenced from the device. Before, the check ran only on
senders that a transformation had returned.

`__leaves_alone` is now a consteval function that names the concept only when
the domain's transformation isn't taken.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…a test

With the transform_sender fast path inlined into connect, GCC 12 at -O3 warns
that connect's copy of the receiver's std::stop_token (in the environment it
passes to transform_sender) can free the shared stop state before the
receiver is moved. The receiver's own reference keeps the state alive, so it
is a false positive. Scope the suppression to the two std::stop_token tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ericniebler
ericniebler merged commit 360f19c into NVIDIA:main Nov 27, 2026
41 checks passed
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.

1 participant