Live data from Hacker News

Asynchronous IO: the next billion-dollar mistake?

yorickpeterse.com

71–80 of 165 posts

Re: Asynchronous IO: the next billion-dollar mistake?

#71
post #54
post #47

Earlier quoted context omitted.

> certain I/O operations are just inherently asynchronous. That's technically not true. The fact that its inherently async is an implementation detail. You either have blocking sync or non-blocking async. the implementation could be synchronous if the blocking didn't cause overhead and that was the proposed idea here - at least as far as I interpreted it.

No, the hardware is frequently inherently asynchronous. You write some memory and then the hardware consumes the prepared data asynchronously, in parallel, until it informs you in some manner that the operation is complete (usually either a asynchronous interrupt, or asynchronous write to a location you are polling). You can do whatever you want after preparing the data without waiting for completion. That is a inher…

Hardware is even-driven not asynchronous (the event-driven paradigm is an asynchronous paradigm, but I assume here you mean asynchronous as in async/await)

Re: Asynchronous IO: the next billion-dollar mistake?

#73
> "Not only would this offer an easier mental model for developers..."

Translation: "I find async i/o confusing and all developers are like me".

This argument has been going on for over 20 years at this point. There are some people who think having pools of threads polling is a natural way of thinking about IO. They keep waiting for the day this becomes an efficient way to do IO.

Re: Asynchronous IO: the next billion-dollar mistake?

#74

Isn’t that parallel universe actually the Erlang BEAM?

Or Go. Or Java' virtual threads.

It must happen at the language level; When it comes to execution context knowledge: what context to compile out (stackless), or what context to serialize to the heap (stackful). Programming language will always know much more about the program than the OS.

If I'm not mistaken in Erlang the programmer will provide the exact context to serialize : the actor.

Re: Asynchronous IO: the next billion-dollar mistake?

#75
What if the author’s proposed solution is the billion dollar mistake?

IMO the best programming paradigms are when the abstractions are close to the hardware.

Instead of pretending to have unlimited cores, what if as part of the runtime of we are given the exactly one thread per core. As the programmer we are responsible for utilizing all the cores and passing data around.

It is then up to the operating system to switch entire sets of cores over different processes.

This removes the footgun of a process overloading a computer with too many threads. Programmers need to consider how to best distribute work over a finite number of cores.

Re: Asynchronous IO: the next billion-dollar mistake?

#76
I think compare programing pattern(threads) to kernel async apis is a questionable comparation.

The point of kernel async apis is not about letting programmers write system calls directly. It's about expose the actual async operations under the hook (it could be disk, be network, be anything outside of the computer case).

Those actions are never mean to be interleaved with cpu computation, because they are usually with ms level delay (which could be millions of cpu ticks). The kernel fakes these into sync calls by pause everything. But it isn't always the best idea to do these.

Let userland program decide what they want to do with the delay will be a way better idea. Even they eventually just invent blocking io calls again. They can still decide what operations are more relevant to itself instead of let the kernel guessing it.

Re: Asynchronous IO: the next billion-dollar mistake?

#78
To put a different spin on what others are saying, asynchronous IO is a different programming model for concurrency that's actually more ergonomic and easier to get right for an average developer (which includes great developers on their not-highly-focused days).

Dealing with raciness, deadlocks and starvation is simply hard, especially when you are focused on solving a different but also hard business problem.

That's also why RDBMSes had and continue to have such a success: they hide this complexity behind a few common patterns and a simple language.

Now, I do agree that languages that suffer from the "color of your functions" problems didn't get it right (Python, for instance). But ultimately, this is an easier mental model, and it's been present since the dawn of purely functional languages (nothing stops a Lisp implementation from doing async IO, and it might only be non-obvious how to do "cancellation" while "gather" is natural too)

Re: Asynchronous IO: the next billion-dollar mistake?

#79
Async IO is not only about creating sockets and spawning threads. Idea of async IO is that the world is not controlled by your CPU. There are network, storage, sound devices that might and will take time to produce the result and the CPU has to wait for it.

I feel like there is a big misunderstanding about what async IO is and what problem it solves.

Re: Asynchronous IO: the next billion-dollar mistake?

#80

> "Not only would this offer an easier mental model for developers..." Translation: "I find async i/o confusing and all developers are like me". This argument has been going on for over 20 years at this point. There are some people who think having pools of threads polling is a natural way of thinking about IO. They keep waiting for the day this becomes an efficient way to do IO.

I would concur, the author also mentions that file IO isn't async; this makes me conclude that the author hasn't grasped how much the Linux kernel has moved on since in the mid 2000s.

I suspect that the author has an incomplete view of the current kernel / userland interface as well as the inner workings of how a kernel actually "does what it does".

Post reply on HN