-
Notifications
You must be signed in to change notification settings - Fork 147
Closed
Description
When we hit the memory limit, we need to deterministically stop executing the current actor, returning to the parent actor. We'd like to avoid simply aborting the message entirely as this could cause problems for, e.g., cron.
This means that we need to consume a consistent amount of gas by the time we OOM. The wrinkle here is that, in theory, an optimization of the wasm bytecode (by the underlying JIT engine) could combine two memory expansion calls into a single memory expansion call, leading us to run out of memory early. For example, given:
- Expand memory by one page.
- Allocate some large buffer.
- Expand memory by one page.
- Allocate a second large buffer.
A reasonable compiler might optimize this to:
- Expand memory by two pages.
- Allocate some large buffer.
- Allocate a second large buffer.
Ideally the compiler sees memory expansion as something that can't be re-ordered, but we need to validate that.