Zig's I/O and Concurrency Story - King Protty - Software You Can Love 2022

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

ความคิดเห็น • 34

  • @tenthlegionstudios1343
    @tenthlegionstudios1343 ปีที่แล้ว +9

    came to this talk before I knew what tiger beetle was - since then I have watched almost all the tiger beetle videos and looked into the code. TigerBeetle is legit - your consensus algorithm is one of the most straightforward beautiful things, the two LSM tree's built in house plus all IO optimizations plus all the memory safety are so cool. View Time Stamped replication is amazing. State replication machines and protocol aware recovery - so cool. Also, love this talk and am coming back for a second time to watch it again. Thanks!

  • @10e999
    @10e999 ปีที่แล้ว +26

    Hum I'm not at the level required to follow this talk properly.
    that said, I'm glad Zig conf tackle advance topics. It's motivating to slowly understanding more about system programming.

    • @sanador2826
      @sanador2826 ปีที่แล้ว +2

      Same boat but now I have some language to use for reading :D

    • @10e999
      @10e999 11 หลายเดือนก่อน

      @@sanador2826 Great mantality !

    • @10e999
      @10e999 หลายเดือนก่อน

      I'm back! Great talk !

  • @d0m96
    @d0m96 ปีที่แล้ว +18

    Awesome talk! Thanks for putting it together, learned a lot :)

  • @CallousCoder
    @CallousCoder ปีที่แล้ว +1

    Oh nice another lecture by King! I love hearing him talk! He as a knack for doing complex material in a very airy funny way. I love it!

  • @marijnstollenga1601
    @marijnstollenga1601 ปีที่แล้ว +2

    Can't wait for this! Sounds like with this you would have amazing performance simply by embracing async in your pograms

  • @13madman37
    @13madman37 ปีที่แล้ว +8

    I always find it interesting to see that people stop at Overlapped IO when talking about non-blocking IO on Windows. APIs like Registered IO (now available for well over 10 years) and IoRing (okay, this is something new right now) are available too and are very similar to io_uring which everyone seems to talk about...

    • @kprotty6828
      @kprotty6828 ปีที่แล้ว +5

      AFAIK (correct me if i'm wrong here), windows RIO requires registered buffers which wouldn't fit zig's intrusive memory model + would hit the locked memory limit on linux for general purpose use. IoRing is getting there but currently only documents/supports reads and requires windows 11.

    • @13madman37
      @13madman37 ปีที่แล้ว +2

      @@kprotty6828 Thanks for the reply. I mainly wanted to make the general observation that Registered IO and IoRing were not mentioned in the talk as it seems to be the case everywhere. These APIs always seem to be overlooked. And yes, Registered IO works with physically locked buffers and I only worked with it in specific contexts where this wasn't an issue (never tried to build a library on top of it). While writes are now supported by IoRing, they are still not documented in the Win32 API (took this info from the windows-internals blog).

  • @michaelravits2309
    @michaelravits2309 ปีที่แล้ว +5

    Thanks! Very clear explanation.

  • @hbobenicio
    @hbobenicio ปีที่แล้ว +4

    Awesome talk King!

  • @TheOneWhoHasWallnuts
    @TheOneWhoHasWallnuts ปีที่แล้ว +3

    >Get rid of current event loop?
    Finally!!! To me it's currently the most unintuitive and opaque thing in zig to be forced into the event loop's pattern when making use of std. What I'd like to have is the ability to write my own (close to main) and hand STL a yield function (at compile time) which gives me back my thread immediately when called (via `suspend`). The response I'd expect from an STL-provided wait function kinda like I/O Completion Port does it. This wait function would give you incoming connections or files or cpu bound tasks even (as a tagged union) you can switch on. This can be in user space of course if possible.
    In practice this would mean that the user runs their own thread pool (e.g. 1 thread per logical core), each thread calling wait in a loop and handling the event when it becomes available.
    What I'm not sure about is how to best allow the user to integrate their own tasks. Ideally there'd be only 1 wake trigger.

    • @kprotty6828
      @kprotty6828 ปีที่แล้ว +2

      Zig (stdlib) doesn't enforce the event loop but provides it as an option for those who don't want to implement their own. Zig async also operates on coroutines (stackless state machines it builds) rather than OS threads or the traditional green thread approach.
      It sounds like you want a cross-platform reactor instead? By running their own thread pool, would that mean multiple threads polling the same reactor? This is what Go, Tokio, and Zig's stdlib current event loop already do: You have fine grained scheduling with `Loop.onNextTick(&node_with_suspended_frame_to_resume)` and IO completions are serviced via said frames (handling and dispatching ready tasks are done inside the loop).
      If this doesn't sound like what you want, were you instead describing the thread-per-core architecture in the video?

    • @TheOneWhoHasWallnuts
      @TheOneWhoHasWallnuts ปีที่แล้ว +1

      Sounds like I gotta mess with it again some time - Probably when 0.10.1 drops. The way I remember it, in order to roll your own, you'd have to implement the same interface the STL event loop uses, which wasn't just yield/wait but something opinionated I couldn't become friends with and also wouldn't let me just throw my own frames in.

  • @RobertLJ11
    @RobertLJ11 ปีที่แล้ว +4

    Great talk . Thank you 😀

  • @beauteetmusculation8191
    @beauteetmusculation8191 ปีที่แล้ว +2

    Thanks for the video. I've worked a bit with the network API of the Zig standard library and it was somewhat confusing to me. Ended-up using a very simple poll(2) syscall and call it a day. I know it's not AT ALL efficient, but at least it's available everywhere and is pretty simple.
    I really hope there will be a way, someday, to make efficient network applications without having to dig into very obscure, non-portable APIs. For now, the Zig standard networking API seems at an early stage.

  • @Pascal-uq8gw
    @Pascal-uq8gw ปีที่แล้ว

    What an information bomb! 🎁 A lot of things are starting to make sense now. Keep it up.

  • @vladyslav007
    @vladyslav007 ปีที่แล้ว +2

    Yey, cool to see some zig talks again

  • @nickdhrones6425
    @nickdhrones6425 ปีที่แล้ว +1

    New to zig! Learned a lot.

  • @baobaobiz
    @baobaobiz 9 หลายเดือนก่อน

    "I own concurrency". Only 15 secs in, a sudden tsunami of respect thrusting my way.

  • @origamibulldoser1618
    @origamibulldoser1618 ปีที่แล้ว

    Lots of context and knowledge. Very interesting :)

  • @nathanfranck5822
    @nathanfranck5822 ปีที่แล้ว +6

    20:12 Jared Sumner just hates Windows confirmed

  • @Pismice
    @Pismice 4 หลายเดือนก่อน

    Hey I’m new to concurrency and I’m trying to wrap my heads about all the concepts surrounding this topic. Do you have any good books or blogs or whatever so that I can understand it deeper ?

  • @realsong-fake
    @realsong-fake ปีที่แล้ว

    I would like to see a runtime with dynamic amount of io reactors. a single poll based event loop can stop to scale completely when many fd given. On the other hand thread per io reactors can be waste of resource as you don't always need io throughput.

  • @michaelravits2309
    @michaelravits2309 ปีที่แล้ว +3

    One question, why TigerBeetle didn't go straight with DPDK. Sacrificing cross platform, but kinda makes sense in your case, no?

    • @tigerbeetledb
      @tigerbeetledb ปีที่แล้ว +8

      Great question! We were aware of it, but our philosophy is to work on commodity hardware, targeting slow/small hardware as well, and being fast like that (e.g. thinking about disk/memory access patterns). With large enough disk blocks (64 KiB) and with io_uring, performance is almost also on par, from what we have read. TigerBeetle was designed just as io_uring was out, so we were also lucky that we had the benefit of being able to target it.

  • @martinmartin6300
    @martinmartin6300 10 หลายเดือนก่อน

    I am not nearly as deep into zig as you guys but as someone who came from outside I have to say that asyncio seems to be a big mistake imho. Zig is supposed to be "simple" but even after that shirt period of evolvment time zig seems to be more and more cluttered with optional/secondary stuff.

  • @doge6363
    @doge6363 ปีที่แล้ว

    gr8 talk

  • @MarkVolkmann
    @MarkVolkmann 11 หลายเดือนก่อน

    If you were hoping to learn how to write some specific Zig code, you won’t see it in this talk. Zero lines of ZIP Code are displayed.

    • @Peter-bg1ku
      @Peter-bg1ku 3 หลายเดือนก่อน

      Yes, zero lines of "ZIP Code" displayed, you are correct ..

  • @abanoubha
    @abanoubha ปีที่แล้ว

    great talk 🤍