ktock/container2wasm

How to set browser VM specs (cpu mhz / available memory)?

alienself opened this issue · 5 comments

Hi, I am using an alpine image to test nodejs performance with this project.

However when running cat /proc/cpuinfo, i get cpu MHz: 14.178 and cat /proc/meminfo gives a total memory of around 128MB.

Is this "normal"? What if I want to allocate let say 4GB of ram allowed by wasm32? What about the CPU, something seems odd with this low mhz, no?
In other words, any way to configure the "specs" of the VM in the browser?

Additionally, do containers have multi-threading support since wasm-thread are a thing and available with emscripten?

Yes a section of how to modify or parameterize cpu, disk, mem, storage would be very practical step for this project. But perhaps it is just a Docker concern and c2w handles that aspect transparently?

ktock commented

any way to configure the "specs" of the VM in the browser?

VM memory size is configurable during conversion by passing --build-arg VM_MEMORY_SIZE_MB=<SIZE> but no other parameter is provided as of now. SGTM about allowing configuration of other parameters as well. Configuration during conversion should be done in a similar way as VM_MEMORY_SIZE_MB. And, it would be great if we can add some flags for the Wasm image itself for changing some VM parameters when launching the container.

multi-threading support

Yes, this is a future plan.

@ktock thank you very much for you reply!
The vm memory flag is definitely what I was looking for.

What about the cpu clock speed? Do you think by default the vm is running at its maximal speed?

Additionally is it possible to run the vm inside a worker?

Ps: loved your talk at Cloud Native very exciting work!

ktock commented

What about the cpu clock speed? Do you think by default the vm is running at its maximal speed?

Tuning hasn't done yet, so maybe there is room for improvement. (e.g. Bochs configuration file is here)

Additionally is it possible to run the vm inside a worker?

On a browser's web worker, right? Our example runs the container(vm) inside a web worker ( https://github.com/ktock/container2wasm/blob/d05d6977df7a0d51dbc807a893f1854db8960c75/examples/wasi-browser/htdocs/worker.js ).

Ps: loved your talk at Cloud Native very exciting work!

Thanks!

@ktock okay thanks for pointing me to the config file.
The culprit seems to be cpu: ips=40000000 which is currently set to a fixed value (of 40 MIPS) which is quite low.
Any way to get this exposed like you did with ${MEMORY_SIZE}?

On a browser's web worker, right? Our example runs the container(vm) inside a web worker
Ah perfect!