-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 experimental @spawn
macro to Base.Threads
#32600
Conversation
What does par stand for? |
parallel |
Maybe |
The current docs and naming conventions use "parallel" more in the "distributed" sense, e.g. |
We have a |
What's the thought on the future of creating a threaded for loop? I want to also have a macro that smartly divides the iteration space up into a "smart" number of partr tasks. Will we be able to silently move the Even if we deem changing |
The name |
Ok, or Raises a good question though. |
You mean a version that the runtime is not required to ever execute until the end of a program ? :P I like those. |
Obviously, we should call it |
Frankly, I don't think this would be horrible. |
I kind of like |
Does it make sense to use shell analogy and use |
Actually, yes, |
Really? Are we going to call them "goroutines" also? |
It's feeling to me like we're getting into some fairly ad hoc terminology choices and thinking systematically about the parallels (get it?) between different levels of parallelism here might be helpful:
We might want to think about what the final set of terminology we ideally want would be, even if it involves changing or reclaiming some terms in 2.0. We use |
|
Ok, I know how much you love tables @JeffBezanson, but this feels like it calls for one:
Any other rows I should add? Even if this doesn't inform our decision, it makes me feel better and seems like a good way to communicate to the user what things are called and what they do. |
|
Also I like @vchuravy 's view that this could be |
I updated the upper right corner from "remote The thing that feels a bit out of sync (see?) is that
The problem with keywords is that they imply orthogonality, and it doesn't seem like this is orthogonal at all: it's a scale from sequential (nothing) to concurrent, to parallel/multithreaded, to distributed, which makes me wonder if it wouldn't be ok to just call these:
Of course, that violates our underscore policy, but it seems a bit clearer that these are similar and that they all pair with |
In particular what's concerning about the terms "parallel" (and its abbreviation "par") and "spawn" is that they are too generic: all of these things are parallel in some sense and "spawn" is a term you can use to describe starting any of these units of work. So using parallel or "par" for one and spawn for another just seems arbitrary. Cilk, for example, uses |
I kind of like
Which looks pretty clean and consistent to me. |
On a technical level I totally agree; it's just that |
Eh, it's not beautiful but it doesn't seem all that bad to me. |
|
I still very much like the verbs I don't find it all that odd that |
I think the current distinction between |
The difference being that a I think the big issue we have is that we want to keep backwards-compatibility. Otherwise I would make |
We discussed this on the triage call and brainstormed many possibilities. I'll summarize the front-runners:
EDIT: added Might as well make this a poll (non-binding!): |
|
I think |
Personally I don't understand |
This seems to be the vital question which can be hard to understand and is answered by structured concurrency libraries in other languages. A lot of design discussion on the Trio forum seems to be about the difficulties of robust cancellation. Also, it would be nice not to use up verbs which we could want later for a more structured approach. Having something like |
Then maybe |
I don't consider it harmful. I mean, many people consider dynamic typing harmful... |
How about |
I'm not sure about |
This is probably me being silly on a Friday afternoon, but just for fun, how about Braid (the noun) is a synonym of thread, and braid (the verb) conveys the interlacing of threads (parallel depth first, of course 😂). Which I am assuming this PR supports with the Cheers! |
I like the verbosity in
and not
Hope this makes sense to someone. |
After sleeping on it, I think we are going to go with |
What about I appreciate this has OS and fork/join connotations but it is a nice description of what happens to an otherwise linear path of execution. |
@par
macro to Base.Threads@spawn
macro to Base.Threads
@samuelpowell, it's a good suggestion and was discussed on Thursday's triage call. Although the parallelism model that's implemented is sometimes called fork-join you'll note that every system that implements this model calls the the operation of forking a new unit of work "spawn". |
I understand, thanks @StefanKarpinski |
Would we be able to do non-sticky |
As far as I understood, It would be nice to explicitly warn users about this, both in the docs and with a debug-option (if a Task could be garbage collected after it has been scheduled and before it has run, then it is dead code, most likely due to user error. Afaiu the gc scans the task heap, so this never happens; but theoretically we could use weakrefs in debug builds and warn users when we finalize a non-finished scheduled task; more brutally, we could warn whenever we finalize a finished task that has not been waited on). |
How can that happen? If it's scheduled then there's a reference to it and it won't be finalized.
A bit too brutal for me :) Of course, that has been requested before for tasks that terminated with an error, which makes some sense at least. All this worry about tasks possibly never running is a bit overblown. It's not like we will just randomly decide not to run a task for no reason. As long as you hit some yield points or have an available thread before the process exits, it will run. |
I don't worry about tasks that never run. I worry that users forget to wait on a task, don't see this during testing and encounter bad races in prod. Running a task "whenever, next year is soon enough" is almost never desired by users, and therefore almost surely indicates a bug/race in user code. This will be a really common type of mistake. I am thinking about how we can help users detect such mistakes. One could detect such a condition by having a
It would require a compile option that uses weakrefs in the heaps. But upon reconsideration, the other option (as outllined above) is better, and this was a stupid idea. |
I'll repeat my pitch for tree-structured I/O a la trio. Not for this PR but for the future. |
The code for this is already starting to get around so we might as well add it before things get further out of hand :) Open for bikeshedding.