-
Notifications
You must be signed in to change notification settings - Fork 59
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
base: bulk_spawn
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()] () { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so long!
@lucteo let's try to move open PRs forward and get them merged, or close them please. |
This example is a test with a massive amount of spawns.
We implement this with our 3 spawn types:
Except the bulk spawn implementation we get better results than the corresponding Go code.