Live data from Hacker News

Asynchrony is not concurrency

kristoff.it

181–190 of 228 posts

Re: Asynchrony is not concurrency

#181
post #172

I think it's a great idea to not have to have two libraries - so its a "tick" from me for any idea that permits it. The thing that bothers me in general about asynchronous code is how you test it so that you know with some confidence that if it passes the tests today you have replicated all the scenarios/orderings that might happen in production. You have this same problem with threads of course and I've always found…

We plan to have in Zig a testing `Io` implementation that will potentially use fuzzing to stress test your code under a concurrent execution model.

That said, I think a key insight is that we expect most of the library code out there to not do any calls to `io.async` or `io.asyncConcurrent`. Most database libraries for example don't need any of this and will still contain simple synchronous code. But then that code will be able to be used by application developers to express asynchrony at a higher level:

   io.async(writeToDb)
   io.async(doOtherThing)
Which makes things way less error prone and simpler to understand than having async/await sprinkled all over the place.

Re: Asynchrony is not concurrency

#182

That’s word games. If I launch 2 network requests from my async JavaScript and both are in flight then that’s concurrent. Definition from Oxford Dictionary adjective 1. existing, happening, or done at the same time. "there are three concurrent art fairs around the city"

> If I launch 2 network requests from my async JavaScript and both are in flight then that’s concurrent.

That's because JS conflates the two. The async keyword in JavaScript queues things for the event loop which is running in a different thread, and progress will be made on them even if they are never awaited. In Rust, for example, nothing will happen unless those Futures are awaited.

Re: Asynchrony is not concurrency

#183
I do not see these definitions as quite right:

>Asynchrony: the possibility for tasks to run out of order and still be correct.

I like this. Great addition and yes it was missing.

>Concurrency: the ability of a system to progress multiple tasks at a time, be it via parallelism or task switching.

I would say here, be it multiprocessing or task switching.

>Parallelism: the ability of a system to execute more than one task simultaneously at the physical level.

This is technically multiprocessing as expressed above.

So, what is the difference between parallelism and concurrency?

Parallel tasks are like shaders. It is the same task, running many instances at the same time at the physical layer.

GPU devices are capable of parallel computing, for example.

Concurrent tasks are different tasks running at the same time at the physical layer. Often, the data is different too. Say a sprite engine running at the same time as a video display driver on the physical layer.

The shaders can all be running the same code but are processing different data elements, say each pixel having a position and is part of a larger rendering.

A GPU is a massively parallel multiprocessor.

A Threadripper is a massive Concurrent multiprocessor. It can also perform as a modest parallel multiprocessor.

The difference lies in what the various compute units can do and what they are actually doing.

Put another way, a 10ghz single core CPU is not a multiprocessor. It performs sequential computing and it can task switch to handle the same task load as a lower clock rate multiprocessor would handle.

A 10ghz multi core CPU is a concurrent multiprocessor, but is not a GPU. It could run shaders on par with a lower clock GPU. BUT a lower clock GPU cannot run a variety of tasks in the same way.

Re: Asynchrony is not concurrency

#185
post #172

I think it's a great idea to not have to have two libraries - so its a "tick" from me for any idea that permits it. The thing that bothers me in general about asynchronous code is how you test it so that you know with some confidence that if it passes the tests today you have replicated all the scenarios/orderings that might happen in production. You have this same problem with threads of course and I've always found…

We plan to have in Zig a testing `Io` implementation that will potentially use fuzzing to stress test your code under a concurrent execution model. That said, I think a key insight is that we expect most of the library code out there to not do any calls to `io.async` or `io.asyncConcurrent`. Most database libraries for example don't need any of this and will still contain simple synchronous code. But then that code w…

More powerful than a “fuzzing” test io would be a deterministic test io. I.e., one you can tick forward the various concurrent branches deterministically to prove that various races are safely handled. This makes it possible to capture all those “what if thread A executes this line first then B is executed” etc. Something that is missing in most concurrent frameworks.

Re: Asynchrony is not concurrency

#186

I do not see these definitions as quite right: >Asynchrony: the possibility for tasks to run out of order and still be correct. I like this. Great addition and yes it was missing. >Concurrency: the ability of a system to progress multiple tasks at a time, be it via parallelism or task switching. I would say here, be it multiprocessing or task switching. >Parallelism: the ability of a system to execute more than one t…

> Parallel tasks are like shaders. It is the same task, running many instances at the same time at the physical layer.

That’s single instruction multiple data which I would argue is an orthogonal concern. A better example of parallelism would be FPGAs. All of the gates are switching all at the same time* and you have to actually figure out how to synchronize the whole lot to get anything useful out of them.

* PLL notwithstanding

Re: Asynchrony is not concurrency

#187

Earlier quoted context omitted.

How is that any better to have await? Any resources I might consult on this?

Well, consider the difference between a().then(() => b()) .then(() => c()) Compared to await a() await b() await c() Even for this simple case I think it's much clearer. Then look at a more complex case: for( i=0; i Now try re-writing this with then() and see the difference.

For the first one, it really feels like only a matter of how you break lines. Sure there is also the matter of anonymous function syntax, but

The latter is more fair, here is a possible solution:

  const gen = (function* () {
    for (let i = 0; i  !next.done && next.value.then(() => run(gen.next()));
  run(gen.next());
Or something similar using reduce. But in both cases, it illustrates the point, I guess.

But if we are at point we can introduce new keywords/syntax in the language, it would just as well possible to come with something like

  a.chain(b, c)
In case you need to pass parameters

  a.chain([b, p1, p2], c)
And for the latter case

  const indexes = (function* () {
    for (let i = 0; i 

Re: Asynchrony is not concurrency

#188
post #149
post #91

Earlier quoted context omitted.

And I repeat, if you think effects from unpredictable I/O completion order constitute equivalent debugging thought landscapes to hardware-parallel races, I can only laugh. Yes yes, in theory they're the same. That's the joke.

You're not reporting yourself, though, since you didn't make it clear at all in your initial comment you were talking about hardware. The previous comment you made only mentioned "parallel data races" in a conversation about software ecosystems, where both of those terms are regularly used to describe things that occur. You're laughing about dunking on people who you've run up to in the middle of a football field; no…

The term "hardware-parallel" was to clarify that I'm talking about genuine parallelism. SMP bugs are 100% software problems solved with software techniques. You learn about them in software courses in school. They're just much harder than getting your async rig to work.

Re: Asynchrony is not concurrency

#189
post #48
post #39

Earlier quoted context omitted.

Yeah concurrency is not parallelism. https://go.dev/blog/waza-talk

That is compatible with my statement: Not all concurrency is parallelism, but all parallelism is concurrency.

SIMD is parallel execution with no concurrency.

Re: Asynchrony is not concurrency

#190

I do not see these definitions as quite right: >Asynchrony: the possibility for tasks to run out of order and still be correct. I like this. Great addition and yes it was missing. >Concurrency: the ability of a system to progress multiple tasks at a time, be it via parallelism or task switching. I would say here, be it multiprocessing or task switching. >Parallelism: the ability of a system to execute more than one t…

> Parallel tasks are like shaders. It is the same task, running many instances at the same time at the physical layer. That’s single instruction multiple data which I would argue is an orthogonal concern. A better example of parallelism would be FPGAs. All of the gates are switching all at the same time* and you have to actually figure out how to synchronize the whole lot to get anything useful out of them. * PLL not…

Yes, SIMD is a form of parallel computing. But that is not the only form. A shader is one, and the difference is lots of instructions and lots of data. It is just the same instructions executing in all the instances.

Concurrent would be many tasks running at the same time with each task containing different jnstructions on either the same data, or different data.

Post reply on HN