HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Modeling Data Concurrency w/ Asynchronous I/O in Zig - RedisConf 2020

Redis3 HN recommenders · recommended in 3 months, 2020-2021
YouTube
11K views · 6 years ago · talk · dated

Zig creator Andrew Kelley's RedisConf 2020 talk on modeling data flow with asynchronous I/O in Zig. It explains how Zig's async/await avoids function coloring, and Loris Cro demonstrates OkRedis, a zero-allocation Redis client.

HN recommends it as the clearest explanation of how Zig achieves colorless async/await.

C, C++, Rust, Go & systems languagesProgramming language design#zig#asyncawait#functioncoloring#andrewkelley#redisclient

4 comments from Hacker News

@kbd2021 · in “Red and blue functions are a good thing”

I really can't agree with this premise after seeing how Zig implements color-less async/await: link I highly recommend watching Andrew Kelley's video (linked in that article) on this topic: ▶ this video

Strongly recommendsView on HN
@jorangreef2021 · in “Comparison of Rust async and Linux thread context switch time and memory use”

I recently wrote an IO abstraction over io_uring using Zig's async/await. Here's how you would do a write()/fsync()/read() with this ( link ): const offset: u64 = 0; const bytes_written = try io.write(fd, buffer_write[0..], offset); try io.fsync(fd); const bytes_read = try io.read(fd, buffer_read[0..], offset); Other sync functions can use this asynchronous IO completion code in a synchronous style (as this snippet shows) and still get all the zero-syscall and asynchronous performance of io_uring. What this is actually doing under the hood is filling SQEs into io_uring's submission queue ring buffer and then later reading completion events off io_uring's completion queue ring buffer, so it's fully asynchronous in the I/O sense but this hasn't spilled out and leaked over into the control flow. The control flow is as it should be, nice and simple and synchronous. Beyond this, Zig still allows you to explicitly indicate concurrency with the `async` keyword, for example if you wanted to run multiple async code paths concurrently. But the crucial part is that Zig's async/await does not force function coloring on you to do all of this: ▶ this video Pretty incredible on Zig's part to be able to pull this off. Huge kudos to Andrew Kelley. Also, thanks to Jens Axboe and io_uring, what you saw above was first-class single-threaded or thread-per-core, there's no threadpool doing that for you, it's pure ring buffer communication to the kernel and back, no context switches, no expensive coor

RecommendsView on HN
@bvrmn2020 · in “What Color Is Your Function? (2015)”

There is an interesting approach in Zig to explicitly kick call frames to achieve colorless asyncness. ▶ this video

RecommendsView on HN
@pron2020 · in “State of Loom”

> Code that's meant to be pinned (and may behave incorrectly if not pinned) looks no different from any other code. Same goes for async/await. The decision to keep you running on the same native thread is up to the scheduler. > Java isn't positioned as a high-level, high-abstraction language and that's not, IME, the user community it has. I beg to differ. It aims to be a good compromise between productivity, observability and performance. Every choice, from JIT to GC, is about improving performance for the common case while helping productivity, not improving performance by adding fine-grained control. There are a few cases where this is not possible. Primitives is one of them, and, indeed, 25 years later, we're "expanding" primitives rather than find some automatic way for optimal memory layout. > It's always been advertised as a safer alternative to C++ - rather like Rust. I think you're mistaken, and in any event, this is certainly not our position. Java is designed for a good blend of productivity, observability and performance, and unless the circumstances are unusual, it opts for improving common-case performance with high abstractions rather than worst-case performance with low abstractions like C++/Rust. Roughly speaking, the stance on performance is how do we get to 95% with the least amount of programmer effort. Anyway, regardless of what I said above, the constraints on the design of usermode threads other than philosophy are also very different for Java than for C

CitesView on HN
Rust's Journey to Async/Await48:46

Rust's Journey to Async/Await

InfoQ
90K views • 6 years ago
RustLatam 2019 - Without Boats: Zero-Cost Async IO32:24

RustLatam 2019 - Without Boats: Zero-Cost Async IO

Rust Programming Language
55K views • 7 years ago
[#36] Zig Roadmap 2024 - Andrew Kelley1:00:23

[#36] Zig Roadmap 2024 - Andrew Kelley

Zig SHOWTIME
66K views • 2 years ago
Crust of Rust: async/await2:34:01

Crust of Rust: async/await

Jon Gjengset
246K views • 5 years ago
Zig: A programming language designed for robustness, optimality, and clarity –  Andrew Kelley54:14

Zig: A programming language designed for robustness, optimality, and clarity –  Andrew Kelley

Recurse Center
75K views • 8 years ago
The Road to Zig 1.0 - Andrew Kelley59:48

The Road to Zig 1.0 - Andrew Kelley

ChariotSolutions
168K views • 7 years ago
Google I/O 2012 - Go Concurrency Patterns51:27

Google I/O 2012 - Go Concurrency Patterns

Google for Developers
894K views • 14 years ago
Andrew Kelley: A Practical Guide to Applying Data Oriented Design (DoD)46:40

Andrew Kelley: A Practical Guide to Applying Data Oriented Design (DoD)

ChimiChanga
415K views • 2 years ago
Zig Roadmap 2023 - Andrew Kelley43:20

Zig Roadmap 2023 - Andrew Kelley

Zig SHOWTIME
77K views • 4 years ago
Rust at speed — building a fast concurrent database52:54

Rust at speed — building a fast concurrent database

Jon Gjengset
225K views • 7 years ago
The Why, What, and How of Pinning in Rust3:03:54

The Why, What, and How of Pinning in Rust

Jon Gjengset
87K views • 7 years ago
Are We There Yet - Rich Hickey1:10:05

Are We There Yet - Rich Hickey

Zhang Jian
24K views • 7 years ago
Parallelism, Concurrency, and Asynchrony in Perl 6 / Jonathan Worthington58:08

Parallelism, Concurrency, and Asynchrony in Perl 6 / Jonathan Worthington

yapcasia
6K views • 11 years ago
Google I/O 2012 - Meet the Go Team1:00:29

Google I/O 2012 - Meet the Go Team

Google for Developers
108K views • 14 years ago
Dmitry Vyukov — Go scheduler: Implementing language with lightweight concurrency1:00:40

Dmitry Vyukov — Go scheduler: Implementing language with lightweight concurrency

Hydra
47K views • 7 years ago
Build Your Own Async2:12:42

Build Your Own Async

David Beazley
60K views • 7 years ago
Clojure Concurrency - Rich Hickey2:32:39

Clojure Concurrency - Rich Hickey

ClojureTV
73K views • 13 years ago
"Data Driven UIs, Incrementally" by Yaron Minsky36:18

"Data Driven UIs, Incrementally" by Yaron Minsky

Strange Loop Conference
20K views • 8 years ago
2021: Year of the Linux Gaming Desktop - Andrew Kelley42:38

2021: Year of the Linux Gaming Desktop - Andrew Kelley

Zig SHOWTIME
15K views • 5 years ago
Raymond Hettinger, Keynote on Concurrency, PyBay 20171:13:53

Raymond Hettinger, Keynote on Concurrency, PyBay 2017

SF Python
161K views • 9 years ago