Wed, 09/04/2024 - 08:53
Hello OCC Team, I have observed a significantly slower speed when using the ReadFile and Transfer functions of STEPCAFControl_Reader to read STEP files in webassembly compared to Windows.
This is my code:
STEPCAFControl_Reader aStepReader;
aStepReader.SetColorMode(true);
aStepReader.SetNameMode(true);
aStepReader.ReadFile(filePath);
aStepReader.Transfer(myDoc);
I don't understand why WebAssembly is very slow. I debugged it on Windows, and the process of the ShapeFix_Shape's Perform function is very slow. Is there a difference in how this function is executed between WebAssembly and Windows? Does anyone know where the performance difference issue lies?
Wed, 09/04/2024 - 11:24
Hello,
The performance difference you're observing when using `STEPCAFControl_Reader` in WebAssembly versus Windows is likely due to several factors related to how WebAssembly handles complex computational tasks, particularly those involving high-precision mathematical calculations.
WebAssembly, while powerful, is not fully optimized for intensive computational tasks like geometric modeling or complex shape fixing that require significant processing power. This is especially true for operations such as those performed by the `ShapeFix_Shape::Perform` function, which likely involves a lot of precise geometric calculations.
On a desktop environment like Windows, these tasks benefit from the full power of the system's CPU, optimized math libraries, and other system-level optimizations that are not available in a WebAssembly environment. WebAssembly operates within the constraints of a web browser, where it doesn't have direct access to system resources and is generally slower at handling such intensive tasks.
For better performance, it's advisable to perform complex conversions and modeling tasks on the server side. The server can handle these operations more efficiently and then send the results, such as mesh-based data, to the client. This approach minimizes the computational load on the client side and takes advantage of the server's processing power, leading to a smoother and faster user experience.
In summary, the key issue is that WebAssembly is not as well-suited for high-precision mathematical operations as a native desktop environment, so offloading those tasks to a server is generally the best approach.
Best regards,
Dmitrii.
Wed, 09/04/2024 - 11:58
Have you tried playing with WASM extensions, improving performance of C++ exceptions?
Wed, 09/04/2024 - 13:15
Just interesting. Shape Healing sometimes needs to have some exceptions. And sometimes some other unexpected things needs to be handled. There are no specific list with requirement classes to catch.
I still recommend to calculate everything on server side. Playing for specific needs is not so stable for now.
But if something was upgraded on Emscripten side to optimize something, it is interesting. I will check the news. Looks like there are some progress should be.
Best regards, Dmitrii.