How To Avoid Locks (Mutex) In Your Golang Programs?

Поделиться
HTML-код
  • Опубликовано: 30 янв 2025

Комментарии • 38

  • @anthonygg_
    @anthonygg_  2 года назад

    ► Join my Discord community for free education 👉 discord.com/invite/bDy8t4b3Rz
    ► Become a Patreon for exclusive tutorials 👉 www.patreon.com/anthonygg_
    Thanks for watching

  • @wskeal86
    @wskeal86 Год назад +12

    Thanks for the video.
    Channels use mutexes under the hood, so there is still the same problem with scalability but the overhead of using channels is bigger than using mutex (which is low level sync primitive).
    In situations where you build the web server (like you did in your video) it is always better to use mutexes rather than channels to sync all the goroutines that are trying to access the same memory addresses (maps/slices/struct fields etc) concurrently.
    In some cases atomics might be more performant. But the scalability is still not good due to CPU cache misses.

    • @liyaodong2
      @liyaodong2 Год назад

      Is only buffered channel uses channel under the hood?

    • @justintie
      @justintie Год назад

      can perfect scalability be at all achieved?

  • @kruczek1986
    @kruczek1986 Год назад +4

    hi, to get data of palyer we need add onother readChan? or how to achieve this ?

  • @mubeeninamdar6573
    @mubeeninamdar6573 Год назад +7

    A single goroutine still needs to sequentially update the variable from each chan receive - how is that any more performant than a mutex? I.e. there’s still a sequential write regardless of the approach.

  • @csmastery1337
    @csmastery1337 2 года назад +5

    I was looking into this topic recently, and this is a perfect video.
    You can really tell that you're an expert, and the video is very entertaining.

  • @tpotjj2979
    @tpotjj2979 2 года назад +2

    5,2k subscribers, keey the content going!

  • @gianlucapiccirillo8398
    @gianlucapiccirillo8398 5 месяцев назад

    I notice u do “ddo” in vim to clear the line and start in insert mode. “cc” might be useful for u, it is equivalent with one less keystroke. Great video!

  • @ibrahimgumus2814
    @ibrahimgumus2814 2 года назад +2

    Great content 👌

  • @jacob_90s
    @jacob_90s Год назад +2

    Very interesting, but I would have liked if you had gone into the mechanics of how this worked, especially to ensure it's not a fluke of design that could be patched out in a future version.

  • @madlep
    @madlep Год назад +1

    As an experienced Elixir/Erlang dev learning Go, this is all sounding *VERY* familiar 😂

  • @ruslangabitov5202
    @ruslangabitov5202 Год назад +1

    Sometimes I've been using Mutes but not as a structure field but over embedding it. Which method in your opinion is better? Have you made the video on this topic already?

  • @osotrop
    @osotrop 2 года назад +1

    thank you for another great video

  • @vladimireliseev7602
    @vladimireliseev7602 9 месяцев назад

    Thanks for the video. Can you share the code of example? May be on github?

  • @mohammedragab4966
    @mohammedragab4966 Год назад

    Great , but how we can fix out of order problem in this model ?

  • @obey-onekenobi2818
    @obey-onekenobi2818 Год назад

    What will happen when channel buffer size is overflowed? And how to choose proper buffer size

  • @stardriver8660
    @stardriver8660 Год назад

    Hi Anthony, i am always getting setting foo printed in order but I don't think here it should be in order, any clue what might be the reason causing that? thank you

  • @asif.haswarey
    @asif.haswarey Год назад +3

    Would have been nice to concisely describe your use-case before starting the coding session.

  • @foreveryoung6108
    @foreveryoung6108 2 года назад +2

    15:11 this is how the word "Object" sounds in Slavic languages, it's funny to hear you say it)

    • @anthonygg_
      @anthonygg_  2 года назад +1

      Im a man of the world 😆

  • @itsyaccine
    @itsyaccine 2 года назад +1

    Can you do one about pointers in golang?

    • @anthonygg_
      @anthonygg_  2 года назад

      I have one in the "how to golang" playlist

  • @MasterFX2000
    @MasterFX2000 Год назад

    That helped me a lot

  • @wMwPlay
    @wMwPlay 2 года назад +1

    high value engineer move

  • @Krevedosa
    @Krevedosa Год назад +1

    Anthony, thanks for the great content. Could you say please what is your origin? I have an argument with my wife😂

  • @aggellos2001
    @aggellos2001 2 года назад +1

    💪

  • @alexmeh1919
    @alexmeh1919 Год назад

    🤘🤘🤘

  • @mysterio7385
    @mysterio7385 2 года назад +1

    Great vid but the amount of typos gave me aneurysm

  • @bablzz
    @bablzz Год назад +1

    That’s lit! But we need close the channel, doesn’t it?

  • @wMwPlay
    @wMwPlay 2 года назад +1

    so, basic idea is to send all objects through 1 channel