Ok, looks like there are 2 issues here. First, IE and Edge might have a specific bug, worth filing that for them.
Second, native code can avoid initializing memory, as modern OSes have a way to just get an already-zero-initialized page. That means allocating zero'd memory can be essentially free. In JS though we have to actually zero out the memory. There is actually one case where we don't, the first time memory is used, it is guaranteed to be zerod out since that's how typed arrays start. We might be able to add hooks into dlmalloc (or however it requests those pages), but i'm not sure offhand how easy it would be. But, it would just be for the first use of the memory, so in a long-running app it would not help. I filed https://github.com/kripken/emscripten/issues/4334 On Wed, May 18, 2016 at 7:32 AM, 'Sören König' via emscripten-discuss < [email protected]> wrote: > hmm this would explain the different timings. but 2 seconds to zero out a > larger bunch of memory?!? is the resulting javascriptcode really so slow? > here are some timing on a native build on the same machine: > > malloc/free: 0.0002104s > vector ctor: 0.019273s > vector resize: 0.0157814s > vector reserve: 0.0001271s > > this is about 20 times faster than firefox and 100 times faster than IE > for the vector ctor. > > > Am Mittwoch, 18. Mai 2016 14:14:07 UTC+2 schrieb AlainC: >> >> For malloc and reserve (with an initially empty array), there is no >> initialization of the elments in the array. >> For std constructor and resize, each element will be initialized >> individually (to 0) in a loop I think. >> > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
