WASM questions (JS in browser) #256
Replies: 2 comments 18 replies
-
I don't think you can control the memory for each instance efficiently, iirc the heap can only grow but not shrink, and growing the heap seems quite slow. I think instead of parallelizing it by setting up many instances, we should look into using pthread for concurrency. I tried implementing a very simple OpenMP interface with pthread but it was very inefficient due to synchronization overhead, but we did many optimizations afterwards and it might be feasible for now. |
Beta Was this translation helpful? Give feedback.
-
Also, regarding memory usage, you may want to check if you are freeing the memory after using the objects. We wrote a simple utility to free up the memory after use for our editor demo manifold/bindings/wasm/examples/worker.js Line 39 in 0fb4769 You may want to do something similar but free the memory more often. |
Beta Was this translation helpful? Give feedback.
-
I've managed to get Manifold working in my app fairly quickly. Love it. My experience with WASM has been limited to a couple of helper functions where I ditched auto-generated bindings in favor of direct access to shared memory. In those cases, I am also directly controlling the loading and unloading of WASM modules since it is a) a feature that is optionally turned on/off and b) the WASM gets loaded into a lot workers, which can end up sitting on a lot of memory.
For the Manifold bindings, is it possible to control (or have visibility into) the amount of memory reserved for each instance? Is it possible to control the url from which the WASM is loaded? In my use case, I would be loading the library into as many workers as the browser indicates for concurrency and then parallelizing operations on a shared buffer (which is ultimately use by a ThreeJS mesh).
Beta Was this translation helpful? Give feedback.
All reactions