feat(vm-runner): out-of-process wasm compilation daemon#16067
Conversation
(cherry picked from commit a551a34)
Sandboxed, memory-limited compilation for Wasmtime on Linux. This commit only adds the daemon, actual usage is in the next.
Use the compiler daemon introduced in the previous commit. This is meant to be an optional setup that lives side-by-side with in-process compilation as an experiment for now.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #16067 +/- ##
==========================================
- Coverage 73.24% 73.15% -0.10%
==========================================
Files 856 862 +6
Lines 188398 189049 +651
Branches 188398 189049 +651
==========================================
+ Hits 137996 138301 +305
- Misses 45996 46316 +320
- Partials 4406 4432 +26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Regarding the chosen size limits, I ran experiments on jakmeier/experiments_on_wasmtime_memory_usage against >3000 mainnet contracts. Results show that on average, more than 6 threads doesn't meaningfully reduce compilation time. Virtual memory usage (what is limited by RLIMIT_AS in the PR) does keep increasing with more allocated threads though. Hence I chose 6 threads per worker so we don't have to overallocate too much. With 6 threads, maximum virtual memory usage is 596.46 MB for mainnet contracts. (Crafted contracts we identified as being memory hungry actually stay below that, now that we have limits in place and use Winch.) Compilation time
Peak memory usage (RSS)
Peak virtual memory usage
I also plotted compilation time with different thread numbers grouped by effective WASM size, to ensure the global average and mean don't hide a meaningful improvement on large contracts. Looks like 6 threads hits diminishing returns on all size buckets.
|
I recall we did not converge on this topic during the meeting. I actually favor the currently implemented option, but that's definitely something which is worth a deeper dive. |

Sandboxed, memory-limited compilation for Wasmtime on Linux.
This is meant to be an optional setup that lives side-by-side with in-process compilation as an experiment for now.
The implementation is not complete, to keep the initial PR reasonably sized.
(Hint: Review it commit-by-commit.)
Follow-ups are planned for:
Questions that need to be resolved and might also need follow-ups:
WasmCompilationUnknownError? Now I treat them the same asWasmUnknownError, potentially committing it to the chain if it fails compilation on most nodes and validators. I'm not so happy about that and it's opposite to what we discussed in the last meeting on the topic. But it seems more consistent for an initial commit.