Hi.I have a custom optimization layer that helps me to decrease wasm binary
size. It is a sort of PGO optimization, I have a statistic about each
function in wasm - how many times it called. Then I remove functions with
zero invocations from wasm and generate js version of same function to
invoke if it suddenly needed (1 js file - 1 removed function). This
optimization works very good except it uses js which is slow and big.
Now I want to generate small wasm modules (<4Kb) instead of js versions. I
thought that wasm-split can help, but I realized that it generates a big
module that can't be load in synchronous way. Moreover there is another
problem, it replaces all placeholders with actual implementation on
instantiation. But, I don't want to replace placeholders because they
continue to track call stats (this is minor problem, I know workaround for
it).
Is there some way to force wasm-split to generate multiple modules (1 per
function). Something like this:
std::unique_ptr<Module> fn1 =
ModuleSplitting::splitFunctions(wasm, <ALL FUNCTIONS - fn1>);
std::unique_ptr<Module> fn2 =
ModuleSplitting::splitFunctions(wasm, <ALL FUNCTIONS - fn1 - fn2>);
...
ModuleWriter writer;
writer.setBinary(options.emitBinary);
writer.setDebugInfo(options.passOptions.debugInfo);
writer.write(wasm, options.primaryOutput);
writer.write(*fn1, wasmFn1);
writer.write(*fn2, wasmFn2);
Or if it's not possible, what do you think is it doable and how hard is it?
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVGzr8Wr_MR4733AkKnkkyoq2ainU6kzsS9dOkVuXki7NQ%40mail.gmail.com.