Skip to content

[Freestanding] Only run tasks when they are awaited up on in task-to-thread model #60860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 1, 2022

Conversation

rokhinip
Copy link
Contributor

@rokhinip rokhinip commented Aug 30, 2022

In the task-to-thread model, there are no threading mechanisms by which work could be offloaded onto another thread. When creating structured concurrency tasks however, we know that they will be awaited upon by the calling parent task which can therefore execute the child task at the point of await.

Rdar: rdar://92347604

@rokhinip
Copy link
Contributor Author

@swift-ci please test

@rokhinip
Copy link
Contributor Author

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okey AFAICS, though the naming of this mode is very weird sounding, any better ideas? The "task to thread" doesn't really mean anything when one reads it hm. "to" what, it is not that a task is mapped "to" a thread after all, so it sounds even misleading somewhat. Is it perhaps "run tasks inline" mode, that's what it does after all 🤔

// our state
_swift_task_setCurrent(oldTask);
queueHead = fragment->waitQueue.load(std::memory_order_acquire);
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense 👍

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. A few little things. I agree with @ktoso that the name is confusing. Not sure what would be better though.

@rokhinip rokhinip force-pushed the rokhinip/92347604-run-task-upon-await branch from 18e8919 to a606892 Compare September 1, 2022 17:11
@rokhinip
Copy link
Contributor Author

rokhinip commented Sep 1, 2022

@swift-ci please test

@rokhinip
Copy link
Contributor Author

rokhinip commented Sep 1, 2022

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@rokhinip rokhinip requested review from ktoso and mikeash September 1, 2022 21:36
@rokhinip rokhinip merged commit 76e7cb1 into main Sep 1, 2022
@rokhinip rokhinip deleted the rokhinip/92347604-run-task-upon-await branch September 1, 2022 22:18
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.

3 participants