Earlier quoted context omitted.
As with most things in Erlang; if it's important, you must make it explicit. Implicit ordering works in your fork-join example with only a single fork, but if you require an ordering, you must be explicit about passing information through to enforce the ordering you need. If you instead did fork { sort a } fork { sort b } a' = join b' = join you would have the same problem as in Erlang. or you could have actor C sort…
> you would have the same problem as in Erlang Ah but that's not how fork-join works - you fork multiple jobs, and then you must join them all at the same time - you can't join just one. You have to do something like (a, b) = join
The Problem with Threads (2006) [pdf]
51–56 of 56 posts
Re: The Problem with Threads (2006) [pdf]
#52Earlier quoted context omitted.
> you would have the same problem as in Erlang Ah but that's not how fork-join works - you fork multiple jobs, and then you must join them all at the same time - you can't join just one. You have to do something like (a, b) = join
If you have to join all the the jobs at the same time (which is pretty inflexible), how is the ordering of the results determined? My exposure to this model was in the perl threads module (and the forks module which offers the same api with os forking instead), where you join on a specific thread id, so you can easily enforce ordering by first joining a, and then joining b; I assumed a join with no parameters would j…
The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. You get the results in the same order as the jobs you created. The order can't vary.
Think about a diamond shape - one job create two more jobs, and then they both send their results to the original job which cannot continue until all child jobs are finished.
> because that seems like the most useful/basic interface
Yes useful and basic, but the problem is it makes it easy to cause race conditions, which is where this thread started! You think you'll get some some thread being ready first so you write code assuming that without even thinking about it, and then once in a trillion you actually get the other result first. Yes, it's a programmer bug, but the point is because it's non-deterministic they may not notice until the one time it actually matters and someone dies.
Re: The Problem with Threads (2006) [pdf]
#53Earlier quoted context omitted.
If you have to join all the the jobs at the same time (which is pretty inflexible), how is the ordering of the results determined? My exposure to this model was in the perl threads module (and the forks module which offers the same api with os forking instead), where you join on a specific thread id, so you can easily enforce ordering by first joining a, and then joining b; I assumed a join with no parameters would j…
> If you have to join all the the jobs at the same time (which is pretty inflexible), how is the ordering of the results determined? The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. You get the results in the same order as the jobs you created. The order can't vary. Think about a diamond shape - one job create two more jobs, and then they both se…
> The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish.
Yes, that's the model.
> You get the results in the same order as the jobs you created.
No, you don't get the results in the same order. Jobs still finish in random order and store results before synchronization happens. Synchronization happens on join after that. And instead of relying on order you specify exactly from where you are getting the result of each individual job. So, if you have to specify that, why do you need an order then? Oh, you don't need it and you don't get to have it. It's not Erlang, where you can actually have a deterministic order and can wait for messages in any order you want, while it will reorder them for you.
Re: The Problem with Threads (2006) [pdf]
#54Earlier quoted context omitted.
> If you have to join all the the jobs at the same time (which is pretty inflexible), how is the ordering of the results determined? The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. You get the results in the same order as the jobs you created. The order can't vary. Think about a diamond shape - one job create two more jobs, and then they both se…
Fork-join is not really a concurrency model, I don't understand why you are trying to push it in every message. But if you insist to treat it like a concurrency model.. > The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. Yes, that's the model. > You get the results in the same order as the jobs you created. No, you don't get the results in the sam…
You and I just don't see to be on the same page about what fork-join is, so we probably aren't going to agree on this.
> It's not Erlang, where you can actually have a deterministic order
Can, but my point is you can also not have a deterministic order, which is how Erlang programs can end up being racy, which is the problem with them if you are trying to solve the original problems of threads.
Re: The Problem with Threads (2006) [pdf]
#55Earlier quoted context omitted.
Fork-join is not really a concurrency model, I don't understand why you are trying to push it in every message. But if you insist to treat it like a concurrency model.. > The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. Yes, that's the model. > You get the results in the same order as the jobs you created. No, you don't get the results in the sam…
> No, you don't get the results in the same order. You and I just don't see to be on the same page about what fork-join is, so we probably aren't going to agree on this. > It's not Erlang, where you can actually have a deterministic order Can, but my point is you can also not have a deterministic order, which is how Erlang programs can end up being racy, which is the problem with them if you are trying to solve the o…
These kind of techniques are key to using parallelism to reduce latency. Always having to wait for everyone to finish at each step makes for a lot of waiting.
Re: The Problem with Threads (2006) [pdf]
#56Earlier quoted context omitted.
Fork-join is not really a concurrency model, I don't understand why you are trying to push it in every message. But if you insist to treat it like a concurrency model.. > The model is that you can start a sequence of jobs to run in parallel, and then you have to wait for them all to finish. Yes, that's the model. > You get the results in the same order as the jobs you created. No, you don't get the results in the sam…
> No, you don't get the results in the same order. You and I just don't see to be on the same page about what fork-join is, so we probably aren't going to agree on this. > It's not Erlang, where you can actually have a deterministic order Can, but my point is you can also not have a deterministic order, which is how Erlang programs can end up being racy, which is the problem with them if you are trying to solve the o…
And lack of order of messages is still not a race condition.