Nidin Vinayakan: Shared Memory & Parallel Programming with JavaScript | JSConf EU 2017

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

In that simple example of a for loop, you know how many threads you have and how much countting you have to do. Just split the work between threads, have them start at 0 and 100mln each and then sum up the number and write it to the buffer at the very end.
Atomics are expensive and constantly writing to memory is expensive (can only write by going all the way to the RAM each time).
Atomics are only good for synchronising threads like in an estafette race. Sometimes you need a mutex to defer all threads untill the current lock holder finishes doing everything it needed to (not just one addition). And sometimes you just need a bit of logic to properly distribute the work.

danser_theplayer
welcome to shbcf.ru