jsxcad / JSxCAD

Packages for CAD in Javascript
MIT License
31 stars 5 forks source link

Performance difference with the native C++ environment. #1077

Open alalialisiong opened 2 years ago

alalialisiong commented 2 years ago

Hi. I'm using the CGAL library in a similar way to yours. My project was built by referring to your emcc build command and cgal.cc . However, there are too many differences when comparing the performance in native c++ environment and wasm environment. For example, I experimented with a simple example from the surface_mesh_simplification package in the CGAL library. When tested using the same model and options, the following results were obtained. native c++ => 0.085 sec wasm => 4.977 sec May I ask if you find the same phenomenon?

pentacular commented 2 years ago

Sorry for the late reply -- I missed the notification.

I would expect it to be significantly slower for a couple of reasons.

(a) CGAL depends on exception handling within its numeric models, and this is slow in WASM at the moment. (b) Using GMP based numbers can get expensive for fractions with large numerators and denominators.

There isn't much that you can do about (a), but if you don't require precise construction, you may find that an Epick kernel speeds things up significantly.

Mostly I deal with speed issues via aggressive caching.