Skip to content
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

Add a concurrency example using a massive number of spawns #1429

Open
wants to merge 5 commits into
base: bulk_spawn
Choose a base branch
from

Conversation

lucteo
Copy link
Contributor

@lucteo lucteo commented Apr 5, 2024

This example is a test with a massive amount of spawns.

We implement this with our 3 spawn types:

  • strict concurrency spawn (non-movable future)
  • weak concurrency spawn (movable future)
  • bulk spawn

Except the bulk spawn implementation we get better results than the corresponding Go code.

@kyouko-taiga kyouko-taiga changed the title Add skynet example Add a concurrency example using a massive number of spawns Apr 21, 2024
Copy link
Contributor

@kyouko-taiga kyouko-taiga left a comment

Choose a reason for hiding this comment

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

LGTM

var results = Array<Int>(count: div, initialized_with: fun (_ i: Int) { 0 })
let sub_size = size / div
let p = mutable_pointer[to: &results]
spawn_(count: div, action: fun[sink let q = p.copy(), sink let n = num.copy(), sink let s = sub_size.copy(), sink let d = div.copy()] (index: Int) -> Void {
Copy link
Collaborator

@dabrahams dabrahams Apr 29, 2024

Choose a reason for hiding this comment

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

These lines are getting pretty long and even if they are less than 100 columns there's so much going on in the capture that it is hard to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Lucian mentioned that he thinks that's a problem with Hylo's current design of captures. The issue is that he needs independent lambdas and so there is currently no real alternative, since implicit captures create let/inout accesses.

I guess one solution would be to declare the environment as a possibly typealiased tuple and then there would be only one capture, but that's only shifting verbosity around.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not asking for anything fancy; just line breaks

return num.copy()
} else {
let sub_size = size / div
let f1 = spawn_(fun[sink let n = num.copy(), sink let s = sub_size.copy(), sink let d = div.copy()] () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto long lines

var i = 0
while i != div {
let cur_num = num + i * sub_size
let f = escaping_spawn_(fun[sink let n = cur_num.copy(), sink let s = sub_size.copy(), sink let d = div.copy()] () -> Int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

so long!

@dabrahams
Copy link
Collaborator

@lucteo let's try to move open PRs forward and get them merged, or close them please.

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