Hello, I have some question related to TOTAL_MEMORY and PTHREAD_POOL_SIZE:

Is it possible to define (or override) these value at Wasm instantiation time, instead of at compilation/link time.

The reason for TOTAL_MEMORY is the following: when compiling with threading support (USE_PTHREADS=1) we can't reliably use ALLOW_MEMORY_GROWTH due to potential performance issues, so we have to use a fixed memory size through TOTAL_MEMORY.  But having to define fixed size memory at compilation/link time is not quite good for some scenarios as, at compilation time, we are generally lacking context about the data size to be processed (example: data size depends on an input file provided by the user). So in the end, defining TOTAL_MEMORY is mostly empirical/guesswork, and can lead either to crashes (not enough memory) or waste of memory on the client machine (too much reserved memory).

At runtime however, when a Web App runs from JS space and before instantiating a .wasm, there is generally more context: it is sometime possible to know in advance how much memory would be needed to process some input data. So my question is: is it possible to define or override "TOTAL_MEMORY" at Wasm instanciation time?

Same question for "PTHREAD_POOL_SIZE". Some C++ programs does not support well the fact that Worker threads initialization are asynchronous (or are they? I am not sure, but I ran into problems recently), and as so, it is preferable to let Emscripten runtime create a fixed number of Worker threads before the program starts. But, same issue here: it is not possible to know at compilation/link time the ideal number of threads to use on a client machine. Still, it is possible to have more information when the Web App runs (just have to query from JS), and before Wasm have to be started. So the question is: is it possible to define or override "PTHREAD_POOL_SIZE" at Wasm instantiation time ?

Thanks for any insights !



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 emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to