Repository navigation
don't instantiate the operations below fork_join's walk state - #2563
Merged
Merged
Conversation
… 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>
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.
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