I have some C++ code (compiled to WASM) that I'm having trouble optimizing. I've been profiling the code with Chrome DevTools, and I've made sure to specify the
optimization flag.
The slowest parts of the code seem to be related to allocating, resizing, and destroying std::vector<T> instances. In my case, `T` is always a basic numeric type, like float or int. Unfortunately, I don't have much control over
how these allocations / deletions happen, as they are deep within the internals of a library I am using.
Basically, there is a class that I'm using that allocates a bunch of small vectors upon construction and destroys them upon deletion. The constructor / destructor for this class are the parts that I'm noticing are quite slow, and the vast majority of the call time seems to be spent on resizing and/or destructing std::vector<T>.
Short of rewriting this part of the code to use some sort of global memory pool, rather than a bunch of small, independent allocations (not even sure this would help - just a guess), is there anything else I can do or should look into?
I should note that I am using the ALLOW_MEMORY_GROWTH flag as well.
Thanks,