asm-dom icon indicating copy to clipboard operation
asm-dom copied to clipboard

[WIP] Multithreading: separate diffing and DOM operations

Open mbasso opened this issue 6 years ago • 2 comments
trafficstars

At the moment asm-dom uses only one thread, the main one, to perform its work. This is an experimental PR that aims to improve the performance by dividing the diffing algorithm and the DOM operations in two different threads. This is now possible thanks to the support of WebAssembly threads in Chrome 70, previously disabled due to a set of reasons involving spectre and meltdown. So, we can now use pthreads and emscripten. We should firstly change our Makefile to setup the new compilation, improve the test suite and runs it directly in the browser, since we cannot mock Worker and SharedArrayBuffer in node. After that we can develop the new core part and benchmark it to see if it is better than the existing one. Here is a list of things that needs to be done:

  • [ ] update Makefile
  • [ ] improve test suite
  • [ ] implement a Producer/Consumer pattern
  • [ ] test and update benchmarks
  • [ ] update examples
  • [ ] update documentation

mbasso avatar Dec 13 '18 00:12 mbasso

Is this PR required before we can make http calls to a backend (or other site) asynchronously? i.e. if we need to make a call to a backend, in the current implementation, prior to this PR, would we block the UI?

webern avatar May 03 '19 15:05 webern

Hi @webern, at the moment there are no plans to develop an API to make HTTP requests... I think that this kind of funtionalities shouldn't be place inside the asm-dom package but in some helper libreries instead. For more information refer to issue #17. However, emscripten has just an API to fetch data from remote servers both synchronously and asynchronously. If you want to see an example, try to check out this tutorial. What do you think? 😄

mbasso avatar May 04 '19 16:05 mbasso