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

preview_player
Показать описание
Can you make JavaScript run even faster? Or is it limited as a single thread language?

Follow me on:

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:

And yes, Node also has threads:
Рекомендации по теме
Комментарии
Автор

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

NerdlFest
Автор

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

aufkeinsten
Автор

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

pranjalagnihotri
Автор

8:20 if you could (in depth with examples) explain all shared datatypes and atomics, please do. That's something I wish someone like you would explain to me :)

Rssks
Автор

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!

MaltaTV
Автор

This is quickly becoming one of my favorite JS channels

pawekoaczynski
Автор

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

dhawaljoshi
Автор

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.

BTW, in Nodejs environment, we have worker threads which are kind of similar to web workers and solves the same problem.

MYMPSWORLD
Автор

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.

philodox
Автор

After completing my Basic HTML course today - thank you for that easy tutorial on Javascript.

ilinbb
Автор

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.

ioshaven
Автор

Javascript: One cannot have all the knowledge about me.

SimonDev: I will take that challenge personally.

Dam, this guy is so good. Glad i found this channel a few months ago by searching for a procedural terrain.

ToothlessXDIn
Автор

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

thomasbates
Автор

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

BogacGuven
Автор

The new Dune movie was awesome! Still, the David Lynch version will always have a special place in my heart. Great video!

taylormason
Автор

Thank you father. We love your videos!

IDontWantAHandleKThanks
Автор

You are correct in your interview. I learned this the first time I implemented a more clever free list vs one that was a stupid linear array. Even then the smart one was log n and the array was order N. The performance dropped by 20% because the linear caching vs cache misses of the log N version. i went back to the linear list and got my 20% back.

mattropolis
Автор

i loved it man amazing like always, if there was one place that i wish to work at i would wish to work with you you're amazing keep it up!

boudyhesham
Автор

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!

soykike
Автор

You are really good at explaining in simple terms.

frahohen