5 ms·
Can CPU and memory limits be enforced? If so, how is it done?
by AYBABTME 8y ago
Can CPU and memory limits be enforced? If so, how is it done?
- humblebee 8y agoIt supports both a `DefaultMemoryPages` size, as well as a `MaxMemoryPages` in the vmconfig[0]. Only the `DefaultMemoryPages` is set when running through the cli (value of 128 pages, with a page size of 64KB), and there appear to be no flags to configure it at the moment. [0] https://github.com/perlin-network/life/blob/master/exec/vm.go#L56-L64 https://github.com/perlin-network/life/blob/master/exec/vm.g...
- AgentME 8y agoIt looks like this Life VM has a "RunWithGasLimit" function that can run WebAssembly for a limited number of steps. I'm not sure if it pauses or aborts the VM when the limit is reached. On a related note: you can enforce a CPU limit on WebAssembly in any engine by using wasm-metering[0]. Note that if the WebAssembly hits the limit, it is entirely aborted, not paused. So wasm-metering is good for limiting the CPU usage of a WebAssembly binary that has short functions called regularly, but not capable of time-slicing a long-running WebAssembly function. I think you'll need custom support from a WebAssembly VM (or a much more extensive preprocessor) for that. [0] https://github.com/ewasm/wasm-metering https://github.com/ewasm/wasm-metering