Deep .NET: Let's Build Our Own ArrayPool with Stephen Toub and Scott Hanselman

Поділитися
Вставка

КОМЕНТАРІ • 85

  • @CuriouslyContent
    @CuriouslyContent 2 місяці тому +30

    What I love about this series is that you have an expert who could, if asked to do so, completely overwhelm most regular developers with technical detail and advanced topics, but you also have a seasoned non-expert (in this area anyway) sitting in to ask questions and explore the knowledge space in a way that is comfortable for most mere mortals.

  • @mranthonymills
    @mranthonymills 2 місяці тому +29

    I'm really loving these "let's make a simple version of X so you understand it" videos!

  • @justgame5508
    @justgame5508 2 місяці тому +18

    Locking content next could be really interesting. ConcurrentDictionary, lock, Semaphore, SemaphoreSlim etc. I think most developers (me included) use and take these for granted without really knowing what they’re doing behind the scenes

  • @JasonBock
    @JasonBock 2 місяці тому +8

    I love this series. I really enjoy hearing Toub talk about these deep concepts.
    One request: get Toub a better mic :). Occasionally his voice got really quiet and it was hard to hear what he was saying.

  • @Rob_III
    @Rob_III 2 місяці тому +10

    Over an hour of two legends! I'm a simple man, I click, I watch!

    • @georgepagotelis
      @georgepagotelis 2 місяці тому

      found the comment to like - cheers hahaha

  • @flygonfiasco9751
    @flygonfiasco9751 2 місяці тому +6

    Would love to see a similar video going in depth about the GC. Love this duo!

  •  2 місяці тому +7

    Great episode. Suggestion for topics could be some math stuff like using optimized vectors SIMD etc. I think Tanner Gooding focuses on that area? Or various synchronization mechanisms in .NET (lock/Semaphore/SemaphoreSlim/new System.Threading.Lock.

  • @barionlp
    @barionlp 2 місяці тому +5

    can you make a deep dive on how to correctly measure performance? it seems trivial at first but I feel like there are so many things people do wrong when measuring

  • @yohannes2kifle
    @yohannes2kifle 2 місяці тому +9

    This is fast becoming my favorite series of your channel, and I really loved this episode

  • @egr0eg
    @egr0eg 2 місяці тому +7

    Great series, clear explanations. Maybe a future episode on how System.Threading.Channels are implemented(comparison with other producer consumer collections) or some concurrent collections internal implementations.

  • @nokkeli
    @nokkeli 2 місяці тому +4

    That doggo looks sooo relaxed sleeping on the couch

  • @chrisanders7257
    @chrisanders7257 2 місяці тому +2

    This is so great. Everytime I watch Stephen I'll learn something new

  • @ahupond
    @ahupond 2 місяці тому +1

    So cool to get insights on how the framework actually works, and how it is expected to be used. The internet was definitely lacking content of that level of expertise, and I hope deep dotnet will continue for a long time. So excited to hear there'll be more guests, although I could be listening to Stephen for hours. He did set the standard at quite the level!

  • @talwald1680
    @talwald1680 2 місяці тому +1

    Great, as always! Please schedule these so we know they are coming!
    Also, I would love a deep dive on Kestral internals and all the great work put into that over the last few years.

  • @frotes
    @frotes 2 місяці тому +3

    I see Stephen and Scott, I like

  • @GuildOfCalamity
    @GuildOfCalamity 2 місяці тому +2

    Love these roll-your-own videos, keep em coming plz!
    Small request: Can you use a dark theme? My eyeballs are burning after that.

  • @JustinLampe
    @JustinLampe 2 місяці тому +3

    And the best series continues 🎉

  • @HG-Dev
    @HG-Dev 2 місяці тому +1

    I wager many will appreciate the attention given to the issue of analysis paralysis. Perhaps it's for the best that multi-threaded resource sharing largely goes over my head...

  • @ollhax
    @ollhax 2 місяці тому +1

    Love this series! It's very interesting (and useful!) to get a glimpse of the inner workings and tradeoffs you talk about. As a game developer I tend to use _a lot_ of pooling, accepting the increased memory use and the sometimes reduced linear performance over having the GC kick in and cause frame drops that are very noticeable for the player. I hope this is a use case that is considered as well :)

  • @juanbautista6766
    @juanbautista6766 2 місяці тому +2

    Just started and already know this gonna be a banger of a video

  • @henrikstornblom
    @henrikstornblom 2 місяці тому +2

    These videos are so great and interesting. Thanks.

  • @gavincampbell1061
    @gavincampbell1061 2 місяці тому +1

    If the array returned from the pool could be up to almost twice the size requested, I take it when iterating the array we should only ever go up to the length we requested as the rest could be garbage data?
    Being aware that the array's length is actually the next power of 2 we could populate the full array if we wanted to, but if you did a for loop with the end condition being the array's length, you could exceed your original requested length, which you may not have populated.
    Sorry if that was mentioned in the video and I missed it.
    Thanks for the videos, they're really useful and insightful.

    • @vyrp
      @vyrp 2 місяці тому +4

      Yes, you need to be careful. That's a common mistake. My tip would be use AsSpan() on the returned pooled array as soon as possible and only working on the span: `var span = arrayFromPool.AsSpan(0, requestedLength);`

  • @MatteoGariglio
    @MatteoGariglio 2 місяці тому +1

    Thanks for bringing up this topic! It's very interesting and instructive. I really like the 'Deep Dot Net' video series-there's always so much more to learn and ideas to draw inspiration from. Thanks for organizing it, and special thanks to Stephen for sharing his valuable knowledge!

  • @sajadmalik9097
    @sajadmalik9097 2 місяці тому +4

    Next in the series:
    - Deep dive into garbage collector.
    - an even deeper dive into garbage collector.
    Please... I am really looking forward to this topic..
    Anyone else wants to learn GC from @SthephenToub.

  • @VitalyPavluk
    @VitalyPavluk 2 місяці тому

    Wow!! Such an amazing Deep .NET episode... See how the complex stuff is created from simple bricks by Stephen is kind of magic

  • @Dustyy01
    @Dustyy01 2 місяці тому +2

    Finally a new Episode 🎉🔥

  • @mrqbboy
    @mrqbboy Місяць тому

    Thanks Guys. This is the best programming content I've enjoyed this year.

  • @hahnkev
    @hahnkev 2 місяці тому +1

    Can't wait for that performance blog post for dotnet 9!

  • @hafthors
    @hafthors 2 місяці тому +2

    Awesome content y'all. How about some content on how to diagnose CPU/memory performance problems? Maybe even some heapdump in windbg/sos stuff. Maybe a look under the hood of how .NET heap objects work. Maybe you could pull in Tess or Maoni for that?

  • @victorchisomnwisu9776
    @victorchisomnwisu9776 2 місяці тому +1

    didn't know you could do an assignment in a ternary operator. Thanks again for the video. Awesome!

    • @vyrp
      @vyrp 2 місяці тому +1

      Assignment is an expression, so you can put it almost anywhere.

  • @leknyzma
    @leknyzma 2 місяці тому +2

    I thought you stopped...welcome back Task.Run()

  • @RJiiFin
    @RJiiFin 2 місяці тому +1

    Really like these deep dives! Thank you

  • @DarthAffe
    @DarthAffe 2 місяці тому +1

    Again a great episode!
    For the future I'd be really interested in a episode about boxing, as there are some quite hidden pitfalls that can cause high GC pressure. Things like interfaces on value types, equality checks and maybe more common, but non obvious problems?
    Btw: Really looking forward to the yearly Performance Improvements blog post :)

  • @clashclan4739
    @clashclan4739 2 місяці тому

    We want more topics covered from stephen than others

  • @secvbulrep
    @secvbulrep Місяць тому

    We need more!!! Thnks a lot!

  • @rodrigolima206
    @rodrigolima206 2 місяці тому

    Another very nice explanation, as always. Thanks.

  • @aguilaaudax1362
    @aguilaaudax1362 2 місяці тому +2

    First time ever Microsoft is actually teaching something

    • @shanselman
      @shanselman 2 місяці тому +5

      I’ve been here putting out content for 17 years, I’m gonna go ahead and say that this was not the first time 😂

  • @mehmetck
    @mehmetck 2 місяці тому

    I listened like Stephen’s dog 😅 We love this series please do more often

  • @CuriouslyContent
    @CuriouslyContent 2 місяці тому

    Always learning from you two! Keep up the great content!

  • @Spirch
    @Spirch 2 місяці тому +2

    i like it, only issue is there is a lot of small mic cut while talking, if you fix this next time

  • @SohaibHasan
    @SohaibHasan 2 місяці тому

    Very informative! Thank you.

  • @Findalfen
    @Findalfen Місяць тому

    Would love to have Maoni Stephens come to the show to talk a bit about the GC.

  • @majixx
    @majixx 2 місяці тому

    Yet another gem!

  • @DotnetareaBr
    @DotnetareaBr 7 днів тому

    A gold mine.

  • @LycosLinz
    @LycosLinz 2 місяці тому +1

    @StephenToub Around 44:28 in the video, I was wondering, why isn't there an overload like `bool TryRent(int minimumLength, out T[] array)` where you can decide not to allocate at all and use some other slower path that is still significantly faster than allocating a fresh new array?

  • @cccyberfamilydk
    @cccyberfamilydk 2 місяці тому

    Great as usual.

  • @禹睿陈-z5i
    @禹睿陈-z5i 2 місяці тому

    Wow!!!!!!!!!!!!!!!!!!!!
    It's been a century since the last update

  • @rb9238
    @rb9238 2 місяці тому

    Excellent!

  • @naveenkp7849
    @naveenkp7849 2 місяці тому +1

    Why can’t we have more of Stephen’s

  • @TheOneAndOnlySecrest
    @TheOneAndOnlySecrest 2 місяці тому

    I would have liked an explanation why default collections like a List do not use ArrayPool.
    As lists usually grow over time it would be a nice use case for a pool to avoid a lot of allocations or not?

  • @alucard2876
    @alucard2876 2 місяці тому

    Finally!!!

  • @AmirHosseini-ow6oi
    @AmirHosseini-ow6oi 2 місяці тому

    Amazing ❤

  • @yairvogel6282
    @yairvogel6282 Місяць тому

    21:09 "I love it when copilot just does stuff for me. Especially when I'm going to delete the code after"😂

  • @bity-bite
    @bity-bite 2 місяці тому

    19:46 Why not use uint instead?

  • @knkootbaoat6759
    @knkootbaoat6759 2 місяці тому

    thanks for the pools.
    opps i mean show

  • @TodorTsankov-vz3sd
    @TodorTsankov-vz3sd 2 місяці тому

    🎉🎉

  • @gregorifelicio6030
    @gregorifelicio6030 2 місяці тому

    ❤❤❤❤

  • @JobertoDiniz
    @JobertoDiniz Місяць тому

    I lack the basic knowledge of why would I use arraypool in first place. It allocates 30 concurrentqueues

  • @gilbertsenyonjo963
    @gilbertsenyonjo963 2 місяці тому

    Hi. At 17:53, what does ??= mean? I cant find it on google

    • @vyrp
      @vyrp 2 місяці тому

      `a ??= b;` means `if (a is null) a = b;`
      Search for "C# null-coalescing assignment".

    • @michaldivismusic
      @michaldivismusic Місяць тому

      It means if the left side is null, assign the right side to it. Otherwise, do nothing. Basically this:
      if (left is null)
      {
      left = right;
      }

  • @mohanrajaloganathan5587
    @mohanrajaloganathan5587 2 місяці тому

    When async call is made for network request, how operating system invokes back dotnet runtime when the network request gets completed?
    Could you go even deeper and explain, how a normal async httpcall or system timer gets registered with epoll (in linux)?
    Can you write a simple timer which registers with operating system and gets invoked by operating system?

    • @vyrp
      @vyrp 2 місяці тому

      In Windows, look for IO Completion Ports (IOCP) and overlapped IO.

  • @superpcstation
    @superpcstation 2 місяці тому

    13:40 does anybody know why he assigned the global variable to local first?

    • @vyrp
      @vyrp 2 місяці тому

      Are you talking about `T? item = _item;`?
      It's because we need to make _item null before returning. Look at lines 18 and 19 at 13:52.

  • @dtienloi
    @dtienloi 2 місяці тому +4

    Copilot completion is distracting…

    • @vyrp
      @vyrp 2 місяці тому

      Agree

  • @troncek
    @troncek 2 місяці тому

    Dogo at 22:06. :)

  • @Kitulous
    @Kitulous 2 місяці тому

    33:47 deficiency cores? yes these are definitely what efficiency cores are haha

  • @programmerstalks7196
    @programmerstalks7196 2 місяці тому +1

    It's a really awesome topic to bathe in.. 🚿 yeah

  • @shawncicoria
    @shawncicoria 2 місяці тому

    good to see the Doodle passed out on the couch. That's where they belong!!!

  • @deivycode
    @deivycode 2 місяці тому

    Les't talk about GC

  • @bity-bite
    @bity-bite 2 місяці тому

    19:46 Why not use uint instead?

    • @vyrp
      @vyrp 2 місяці тому

      My guess would be because int is CLS compliant, while uint is not. That matters while building the standard library and not while building your own library, but I guess Stephen is used to working on the standard library.
      CLS compliance matters because .NET code can be called by many different languages, some of which might not have the concept of unsigned integer.