Can JavaScript Go Faster? Threading in JavaScript (Data Structures & Optimization)

Поделиться
HTML-код
  • Опубликовано: 15 авг 2021
  • Can you make JavaScript run even faster? Or is it limited as a single thread language?
    Patreon: / simondevyt
    Follow me on:
    Twitter: / iced_coffee_dev
    Instagram: / beer_and_code
    Github: github.com/simondevyoutube/
    In this video we talk a bit about JavaScript's mechanisms for concurrency and spreading the work out over multiple threads/cores. We'll cover the web worker API in a bit of detail, dedicated workers, and then we'll move on to creating a small testing setup. It's kind of interesting to explore the threading opportunities that JavaScripts offers through the Web Worker API, the various pitfalls and performance footguns that lurk there, and what you can do to mitigate these issues. We'll also explore using transferable objects with ArrayBuffer, and touch quickly on what SharedArrayBuffer unlocks in terms of concurrency and multiple threads reading/writing.
    Links:
    developer.mozilla.org/en-US/d...
    surma.dev/
    surma.dev/things/is-postmessa...
    v8.dev/docs/embed
    developer.mozilla.org/en-US/d...
    developer.mozilla.org/en-US/d...
    developer.mozilla.org/en-US/d...
    developers.google.com/web/upd...
    en.wikipedia.org/wiki/JavaScript
    And yes, Node also has threads:
    nodejs.org/api/worker_threads...

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

  • @NerdlFest
    @NerdlFest 2 года назад +154

    Honestly this is some of the most edge case Javascript stuff I have ever seen. I love it so muchhhh

  • @aufkeinsten7883
    @aufkeinsten7883 2 года назад +49

    Have half an hour of work to kill and didn't want to assign myself a new ticket, then this popped up - truly godsent :D

  • @danielli3288
    @danielli3288 2 года назад +8

    we frontend developers usually don't know about this stuff, so it would be nice if you explain what threading was, just a brief explanation would be good. though i think i got the idea in the end

  • @pranjalagnihotri6072
    @pranjalagnihotri6072 2 года назад +45

    Your Javascript lessons are "The Best", your experience talks for itself 🔥

  • @Mal1t1aTV
    @Mal1t1aTV 2 года назад +30

    I feel like I actually learned about web workers and have a better understanding of what they are and how they work. Way better than random google searches!

  • @creaky2436
    @creaky2436 2 года назад +3

    CS wizardry 💥

  • @pawekoaczynski4505
    @pawekoaczynski4505 2 года назад +20

    This is quickly becoming one of my favorite JS channels

  • @ioshaven436
    @ioshaven436 2 года назад +7

    You may be able to see performance gains if you structure the workers as a predefined pool which pulls from a queue of callbacks to prevent unnecessary worker instantiation.

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

    JavaScript (more specifically in Node)

  • @marcenware0113

    I'm actually really looking forward to the new Dune movie 😂

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

    If this helped you in any way and you'd like to support future vids:

  • @Rssks
    @Rssks 2 года назад +38

    8:20

  • @dhawaljoshi
    @dhawaljoshi 2 года назад +10

    would really appreciate more videos on multi-threading with Javascript.

  • @MYMPSWORLD
    @MYMPSWORLD 2 года назад +25

    Great video! This is the first video i have seen going deeper into the js threads. Please keep posting more content like this. Do you have blog where you post the video content in text format? That will be great for quick reference.

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

    Thank you! Thank you! Thank you! I really wanted to see a video from you that included threading!

  • @BogacGuven
    @BogacGuven 2 года назад +9

    Always a pleasure to watch your content. Thanks for putting these together. ❤👍

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

    Well explained video on using transferrables. I'd love to see a followup on using Shared Array Buffers with Atomics. It'd be nice to see a tech breakdown on typed arrays and how to properly implement them. I'm currently using transferrables for 3D physics animation but would appreciate any insights into making that faster. With 3D simulations I've found every millisecond counts.

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

    Lovely! Quality work as always Simon!

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

    Simon you are awesome, I wrote something similar about the JS workers in the other video, but never thought you would actually make it, very thorough I am actually impressed on your dedication!

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

    Amazing video!