Skip to content

don't instantiate the operations below fork_join's walk state - #2563

Merged
ericniebler merged 2 commits into
NVIDIA:mainfrom
ericniebler:fork-join-walk-state
Nov 27, 2026
Merged

ericniebler merged 2 commits into
NVIDIA:mainfrom
ericniebler:fork-join-walk-state

Conversation

@ericniebler

Copy link
Copy Markdown
Collaborator

fork_join's state holds the operations of its child and of the forked when_all, and its __get_state deduces its return type, so the facade's walk instantiated __get_state's body, which connected the child and the closures' senders to archetypes. this declares the state's type with __state_type and gives a walk's state placeholders, as #2560 and #2562 do for ignore_all_values, let and sequence. the new helper classes are keyed by bools only, and the code that runs is unchanged.

this is based on #2562, whose __state_type hook it uses, so it shows #2562's commit until that merges. the fork_join change is the last commit.

test_fork_join.cpp vs #2562, clang 22 -O3: 14.8 s / 840 MB -> 12.3 s / 694 MB; with extra type checking 21.8 s / 1212 MB -> 14.3 s / 814 MB. its gcc 15 debug object is 19% smaller (.text unchanged).

tested locally: test_fork_join passes with clang 22 and builds with gcc 15 -Werror. fork_join still rejects a child whose results can't be decay-copied, with the same diagnostic. no other test includes fork_join.hpp. not run locally: the full cmake suite, clang 16, nvc++, cuda.

🤖 Generated with Claude Code

ericniebler and others added 2 commits November 27, 2026 13:19
… state

NVIDIA#2560 (6bf5045) made ignore_all_values' state report, for any receiver archetype, that
making it cannot throw. But algorithms ask exactly that, with archetype receivers, when they
decide whether connecting a sender can throw: sequence for the senders after the first, and
let for the sender that its function returns. So, for example,
sequence(just(), ignore_all_values(s)) lost its set_error(exception_ptr) completion when
subscribing s can throw.

The walk asked only because it named the state's type as decltype(__get_state(...)), which
needs __get_state's exception specification. Now an algorithm can declare the type with a
__state_type alias, which the facade uses when present (MAINTAINERS.md lists the new hook).
ignore_all_values, let and sequence declare it, and ignore_all_values' noexcept clause is
what it was before NVIDIA#2560. A new test checks the completions above.

let's state also named the operations of its child and of the senders that its function
returns in __variants, which the storage of the child's results instantiates, so the walk
still computed them. They have their own class now, which only the state's operations name.

And __walking is now a consteval function and __walking_receiver a concept: as a static
constexpr member and a variable template, GCC emitted symbols for them, with long names.

test_merge_each_threaded.cpp (clang 22 -O3): 925 fewer template instantiations than on main.
GCC 15 Debug objects of ten sequence and let tests: 1.5% larger in total than on main
(test_merge 10.6%), since the noexcept answers that NVIDIA#2560 skipped are computed again; still
24% smaller than before NVIDIA#2560.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fork_join's state holds the operations of its child and of the forked when_all, and its
__get_state's return type is deduced. So the facade's walk, which needs only the state's
type, instantiated __get_state's body, which checked that the child and the closures'
senders can be connected to archetypes, and connected them.

Now fork_join declares its state's type with __state_type (see NVIDIA#2562), and a state whose
receiver is an archetype holds placeholders (__walk_op) for the operations, does not check
whether they can be connected, and connects nothing. The new helper classes are keyed by
bools only, and the code that runs is unchanged, so GCC's debug information does not grow.

test_fork_join.cpp (clang 22 -O3): 14.8 s / 840 MB -> 12.3 s / 694 MB, and with extra type
checking 21.8 s / 1212 MB -> 14.3 s / 814 MB. Its GCC 15 Debug object is 19% smaller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ericniebler
ericniebler merged commit 006a7b6 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