Skip to content

Fix split fast-path to preserve completion scheduler semantics#6911

Open
shlokjain2031 wants to merge 2 commits intoTheHPXProject:masterfrom
shlokjain2031:split_fast_path
Open

Fix split fast-path to preserve completion scheduler semantics#6911
shlokjain2031 wants to merge 2 commits intoTheHPXProject:masterfrom
shlokjain2031:split_fast_path

Conversation

@shlokjain2031
Copy link
Copy Markdown
Contributor

Fixes #6905

Proposed Changes

  • Introduces one replay lambda that is used in both:

    • the fast-path (predecessor already done), and
    • deferred continuations (stored and invoked later).
  • The replay lambda first inspects the stored completion variant to determine which signal will be emitted:

    • set_value
    • set_error
    • set_stopped
  • Before invoking the completion inline, it queries the receiver’s environment for the corresponding completion scheduler.

  • If a valid scheduler is found and it supports schedule(), the completion is dispatched through that scheduler using:

    • schedule(scheduler) to obtain a sender
    • then(...) to attach the inline completion invocation
    • start_detached(...) to launch the scheduled sender
  • If no suitable scheduler is available, the code falls back to invoking the completion inline, preserving the original behavior.

  • This ensures consistent, scheduler-aware behavior in both fast-path and deferred execution paths.

Any background context you want to provide?

Previously, if predecessor_done was true (fast-path), the code directly called set_value, set_error, or set_stopped inline on the downstream receiver. That inline invocation ignored any completion scheduler provided through the receiver’s environment. Ignoring the completion scheduler could break expected execution semantics, since the receiver may require completions to run on a specific scheduler.

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@StellarBot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@hkaiser hkaiser added category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals type: enhancement type: compatibility issue labels Feb 16, 2026
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Feb 16, 2026

@isidorostsa would you have the time to review this PR, please?

@shlokjain2031 shlokjain2031 changed the title Split fast path Fix split fast-path to preserve completion scheduler semantics Feb 16, 2026
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Mar 16, 2026

@isidorostsa ping?

@isidorostsa
Copy link
Copy Markdown
Contributor

Hey @shlokjain2031, thanks for the pr!

We are in the process of deprecating most of hpx's native senders, and replacing the ones where hpx provides an advantage with cpo specializations on the completion scheduler.

Do you think there is a significant advantage of this implementation over the one found in stdexec?

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Mar 21, 2026

@isidorostsa Could you please have a look?

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Mar 21, 2026

@shlokjain2031 Please have a look at the CI failures.

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 8, 2026

@shlokjain2031 ping?

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

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

Labels

category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals type: compatibility issue type: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split fast path ignores receiver’s scheduler leading to mismatched completion thread

4 participants