2020-12-05 09:31 阅读 1

WASM future?

Hi there,

I was using a WebWorker with a SharedArrayBuffer to do the math for the graph in my app. (Un)fortunately, SharedArrayBuffer has been disabled in response to Spectre.

So, as I was looking for an alternative (except normal ArrayBuffer - memory copying), I figured that SIMD has been dropped in favor of WASM which reached consensus and landed in all relevant browsers.

Are there plans to port to WASM? This project seems like a natural fit for WASM. I found https://github.com/ColinEberhardt/d3-wasm-force which looks like a proof-of-concept to me but has no pulse atm.

In general, which method is advised to optimize performance? 1. Main thread 2. WebWorker with ArrayBuffer (copying) 3. ~~WebWorker with SharedArrayBuffer (non-copying)~~ 4. WASM in the main thread 5. WASM in WebWorker 6. ???

Thanks in advance for the comments.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39667398 weixin_39667398 2020-12-05 09:31

    I had similar issue. Running huge simulations (~15k nodes) in web worker generaly helps.

    点赞 评论 复制链接分享
  • weixin_39622289 weixin_39622289 2020-12-05 09:31

    I too have had good luck with running large simulations in a separate web worker

    I'd also like to explore using navigator.hardwareConcurrency to spread the simulation calculations across an appropriate number of child workers (by splitting the nodes list into chunks?), but haven't had time to explore this option yet

    点赞 评论 复制链接分享
  • weixin_39716510 weixin_39716510 2020-12-05 09:31

    SharedArrayBuffer has been re-enabled in Chrome 67 in light of site isolation.

    点赞 评论 复制链接分享
  • weixin_39874881 weixin_39874881 2020-12-05 09:31

    I have no plans to port to WASM, but feel free to fork this library if it helps!

    点赞 评论 复制链接分享