-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OOM on 15k+ concurrent - suspect VIRT? #112
Comments
This issue happens because Wasmtime reserves 8 GB of space for each WebAssembly instance (process) heap. At 15k+ processes you basically end up with over 128 TB of memory reserved. Modern 64bit CPUs actually don't have 64 bit memory instructions, they only usually support 48 bit in practice (because why would you need all that space??), so this ends up at around 256 TB. And because half of the memory space is split between kernel and user space inside of an OS process, once you pass 128 TB the OS will not give you more memory. Notice that it doesn't really matter if you compile in debug/release mode. This all is usually virtual memory, but you can't go above 128 TB even with virtual memory because of hardware limitations of CPUs and paging systems. Why does Wasmtime do this? It allows for bound-check elimination. Wasm instances use 32bit memories. If you do One way of fixing this is just to sacrifice performance and pre-allocate smaller heaps in Wasmtime. Once we fill up the heap, allocate a bigger space and copy everything over from previous heap. Wasmtime already supports this and that's how Erlang does it. I couldn't decide what a reasonable starting size would be, so I left the default. This could also be a flag in the VM, Erlang has the There is another related issue here: #79. Wasmtime also uses As an interesting side-note, some Intel CPUs have 5-level paging (57 bit) and can address up to 128 PB of virtual memory. |
A little clarification: wasmtime reserves 4 GB + 2 GB (for guard pages) but 8GB per instance and only for 64-bit architectures. But all this limits can be configured: https://github.com/bytecodealliance/wasmtime/blob/59a9bd628568cd804839f174b9219ea7d40440d3/docs/contributing-architecture.md#linear-memory |
Whilst I was stress testing the UDP stack - I wrote medium about it:
https://missmissm.medium.com/play-ping-pong-with-lunatic-udp-ef557a22a604
repro here:
I hit OOM at around 15k flows on debug target - I suspect OOM (suspect virt mem) will not go away if target is release?
$ ulimit -a
lunatic-solutions/lunatic-rs#33
lunatic-solutions/lunatic-rs#17
The text was updated successfully, but these errors were encountered: