3 ms·
Wouldn't it make more sense to improve Emscripten's huge TypedArray array so it can grow and shrink, or be chunked. Or maybe even implement a "virtual" TypedArr
by IshKebab 11y ago
Wouldn't it make more sense to improve Emscripten's huge TypedArray array so it can grow and shrink, or be chunked. Or maybe even implement a "virtual" TypedArray that you can just allocate as the full size of virtual memory.
- Matheus28 11y agoSome browsers already support growing the TypedArray, so it's a poor excuse...
- DiThi 11y agoCan you link to information about this? I can't find anything.
- Matheus28 11y agoI was mistaken by "some browsers", it seems that actually only Firefox nightly has it enabled at the moment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer#Browser_compatibility https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... So yeah, not good enough to be used in production.
- azakai 11y agoEmscripten has an option to chunk the typed array, https://github.com/kripken/emscripten/wiki/Split-Memory https://github.com/kripken/emscripten/wiki/Split-Memory In that mode, memory allocation is basically like in C and C++: each block can be allocated and freed independently. Of course, this does have a performance cost, so it's a tradeoff.
- ant6n 11y agoI wonder why it's an issue to allocate 2GB of zeros anyway. With virtual memory, it should all map to the same zeroed page until they get written. And With transparent huge page support, it should only allocate few such pages until they get written.
- Hydraulix989 11y agoWhen I was testing last summer, users' browsers would crash while allocating even 512 MB for the emscripten heap.
- DiThi 11y agoBecause many browsers are still 32 bit even in 64 bit systems. That means they get 2GB of virtual space in total. And frequently they don't have 256 MB of aligned and continuous virtual memory (and I suffered the pain of trying to develop a web application that uses 128 MB for months, in the end we ditched the C++ part).
- ant6n 11y agoThat's fair, I guess. Although I thought browsers like chrome run every window in a different process, thus each has their own virtual memory. I guess the browsers should specialize on very large typed arrays, because with asm.js etc they will most likely be very sparse (e.g. allocate 2gb of zeros, use 50mb).