wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Save AOT file on compilation of WASM binary using wasm-c-api

Open robinvanemden opened this issue 3 years ago • 2 comments

For one of our use cases, it would be useful to be able to load a WASM, run it, save the compiled module, and then use that compiled module on every subsequent run.

To be able to do that, should I serialize the compiled module to disk within the wasm-c-api application? Ideally, in way that results in saving the AOT version of the original WASM binary?

robinvanemden avatar Jan 30 '21 17:01 robinvanemden

Hi, not sure what you want to save to disk, the WASM or AOT file which is readonly and not to be changed again, or the module instance data in memory and to be used in next time? Normally the former is called XIP (execution-in-place), and the latter is called snapshot. Both of them are really difficult to implement. For XIP, there is an RPC issue opened, we might implement the AOT XIP in the future.

For snapshot, there is no any plan yet, you might have a try by yourself. For example, in the first time run, serialize and save the module instance runtime data, including linear memory data (memory size, memory data), global data, table data, app heap data (not sure whether you can disable app heap or not). And in the next time, load AOT file again, and then restore the saved module instance data. Please refer to AOTModuleInstance/AOTMemoryInstance/ structure for more details.

wenyongh avatar Feb 01 '21 13:02 wenyongh

Hi Wenyongh! Thanks for your pointers towards implementation of snapshot functionality with WAMR and the link to the RPC issue. In my question, I was actually refering XIP - though snapshots would be valuable to as too.

robinvanemden avatar Feb 04 '21 08:02 robinvanemden