Comparision of a Normal Merge Sort and Distributed Merge Sort is used.
Normal Merge Sort: It is done in the main thread (the only thread)
, basic implementaion of merge sort.
Distributed Merge Sort: It is done in the worker threads, by using
at max 4 worker threads at a time. Merge Sorting 1/4 of part array in
different workers. Then merging the 4 parts, in two different workers by
making it parallel. Thereby speeding it up.
Using
SharedArrayBuffer, we can easily send reference to the worker threads without the overhead
of copying over. Combining
Web Workers
and
SharedArrayBuffer,We can implement a lot of parallel algorithms, achieve speed which was
possible in low level languages. Also read,
TypedArrays
which makes numerical arrays creation superfast.