6 ms·
I wonder if the advent of async/await in all the popular and upcoming programming languages will be seen, after some (buffering) interval, as a disaster of majo
by ncmncm 7y ago
I wonder if the advent of async/await in all the popular and upcoming programming languages will be seen, after some (buffering) interval, as a disaster of major proportions. And, I wonder how the programming world will respond to the disaster.
It seems advisable to begin that response now. The linked article might be the beginning of such a response, but it seems too tentative. We may need an Iron Law of Flow Control, visibly acknowledged and observed in each system that uses an async/await facility, at the point of use, or a note explaining where it is handled farther back up the chain.
TCP vs IP is an excellent example of such an alternative: IP does not bother with buffering, except as a completely local performance optimization, and happily drops packets at the first hint of trouble, assured that somebody closer to the source has buffered copies of whatever they actually care about.
- sk5t 7y ago> IP does not bother with buffering Did you mean UDP? But even if so, this description overall seems way off in the weeds.
- detaro 7y agoTCP is not based on UDP, so that would not make sense at all. The parent describes it quite accurately: IP makes no guarantee on delivery and allows dropping packets, TCP promises to fix that on a higher level for applications that need it.
- sk5t 7y agoNobody's claiming TCP/IP to be based on UDP/IP. I mean to suggest that buffering isn't a proper feature distinction between TCP and unreliable protocols. Separately, it seems a tad obscure to use IP as the exemplar here--doesn't most everyone want UDP features on top?
- ncmncm 7y agoHardly anybody relies on any of the extras UDP provides, so they are typically just wasted overhead. But user-level libraries offer UDP, so that is what people use.
- kragen 7y agoI've never seen a UDP application that didn't depend on port numbers, which are an extra UDP provides.
- MaxBarraclough 7y ago> the extras UDP provides Like what? UDP is lightweight and bare-bones, no?
- ncmncm 7y agoIt adds source and destination ports and a checksum. Computing the checksum is a nuisance, and it is usually inadequate, so it is allowed to be zero in IPV4, but not IPV6. Normally, if you need a checksum, you need one that cannot be forged, and you need more than 16 bits. So the L3 one is just overhead. I have never seen an actual use of UDP that looked at the port numbers, although firewalls often use them for filtering.
- detaro 7y agoName a few UDP-based protocols whose implementations do not listen to only a specific port number, or a rely on port numbers established as part of the protocol flow, then?
- ncmncm 7y agoUDP copies IP behavior up the chain. To be clear: every intermediate router is expected to implement only IP, and completely ignore UDP or TCP. Each discards packets freely. (Router buyers have taken up violating the design, and meddling with TCP along the route. Yet, the point stands.)
- sk5t 7y agoIt's the word "buffer" that threw me. Like, the buffer is a concept on the sending or receiving system and a separate concern from the protocol. That said I am certainly open to learning something new about TCP/IP today.
- codebje 7y agoThe buffer you're thinking of is a packet-level queue to allow mismatches between physical transmission rates and processing rates, and is separate from the protocol. The buffer the original comment is talking about is likely the TCP receive buffer, which is used both to allow the application layer to process bytes at its leisure rather than as they arrive, and to allow out-of-order data to be reassembled correctly rather than retransmitted in-order every time. The receive buffer is documented at the protocol level. Well, honestly I don't recall if the buffer is ever documented in the spec or just common implementation practice. There is a documented "receive window" though, which is how many bytes the receiver is comfortable having "in flight" - sent but not acknowledged. The existence of this window implies the existence of a buffer at least as large as that window on the receiver.
- lazulicurio 7y ago> I wonder if the advent of async/await in all the popular and upcoming programming languages will be seen, after some (buffering) interval, as a disaster of major proportions. And, I wonder how the programming world will respond to the disaster. I think that there is value in async/await as a concept, but that some language's specific implementations will be eventually seen as a mistake. My primary experience is in .Net, and I've grown disenchanted with async/await in that realm. I feel like it makes the easy things easier and the hard things harder[1], which, IMO, is the wrong trade-off for a concurrency primitive[2]. By comparison, what I've read about async/await in Rust seems very promising. [1] Specifically, I think that the Task API is warty and over-complicated, with abominations such as .ConfigureAwait (I know that there are situations where it can be useful, but those don't make the method any less terrible). While await doesn't strictly depend on Task[1a], in practice you're going to be using Task. [1a] http://blog.i3arnon.com/2018/01/02/task-enumerable-awaiter/ http://blog.i3arnon.com/2018/01/02/task-enumerable-awaiter/ [2] Before anyone chimes in with "async/await has nothing to do with concurrency/threads---it's just state machines": yes, that is technically true in the narrow sense of how the compiler desugars the async/await keywords. However, as soon as you start talking about actually scheduling and executing your tasks, concurrency/threads become very important.
- sk5t 7y agoI actually liked .NET async/await because it came with good usable libraries for async RDBMS operations tied into NT IO completion ports, easing a super common bottleneck; compare to other common RDBMS clients that might offer a facade of asynchrony but are really just blocking and queuing behind the curtain. The task library (TPL) is a smidgen wordy, as was MSFT's way about ten years back, most folks will never get deep into it though.
- LennyWhiteJr 7y agoasync/await in .NET is actually good because they added async equivalent APIs to nearly all blocking operations. There's also always (from what I've seen) an optional cancellation token parameter that allows an easy mechanism to alleviate backpressure. Need an easy way to cancel 100 async requests? Easy, just pass in a cancellation token and cancel it when needed. All the requests will throw an OperationCanceledException which can be cleanly handled. I haven't seen anything this nice in javascript or python.
- wahern 7y agoThe fundamental problem isn't async code, it's buffering. Async-await patterns simply shift scheduling from the system (kernel or low-level runtime) into the application, but that's it. Languages like Python and JavaScript provide broken async-await APIs that do too much hidden buffering, including unbounded buffering. But that's a stupid design decision on their part, a reflection of poor interface design arguably stemming from a) bolting async I/O onto pre-existing architectures and runtimes that can't accommodate it well, and b) the implementers not having sufficient real-world experience designing and implementing such systems. But even in threaded code you can have buffering problems. For example, Linux' default socket buffer size sysctls are arguably far too large, optimized for high throughput of a few connections (i.e. benchmarks), not for good responsiveness. That makes it too easy for any massively concurrent service daemon, threaded or not, to flood the outbound network queues. The answer for any I/O model is to never, ever implement an in-memory input or output sink with an unlimited size, whether for buffering data, connections, or any other resource (e.g. stack frames if an event loop recursively reenters itself). That solves most of the problems right there. The remaining problems are more nuanced, and may require reducing buffer sizes as much as possible (think single-digit Kb instead of Mb[1]), and considering how various resource buffers and APIs interact (additively, multiplicatively) to create hidden buffer bloat. [1] Especially if you're not doing any heavy processing of the buffer contents, such as audio-video processing where you may need moderately larger buffer sizes to benefit from pipelined and SIMD processing.
- kasperni 7y ago> I wonder if the advent of async/await in all the popular and upcoming programming languages... Not all of them. Go has Goroutines. And Java is settling on virtual threads (fibers) with Project Loom instead of async/await.
- yxhuvud 7y agoI trust you have seen https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://vorpus.org/blog/notes-on-structured-concurrency-or-g... ? That seems like the response you are asking for, with plenty of control over how asynchronicity is handled.