feat: rebuild runtime memory layout #20

Open
opened 2026-01-20 19:06:40 +01:00 by max · 1 comment
Owner

Currently each node holds its own memory. This means that the output of each module is moved into "js land" and then into the next node. This is very inefficient. The idea is to rebuild the entire thing so there exists only one big memory, like this:

The downside is that this makes it a lot harder to cache the outputs of each node.

Currently each node holds its own memory. This means that the output of each module is moved into "js land" and then into the next node. This is very inefficient. The idea is to rebuild the entire thing so there exists only one big memory, like this: ![](https://git.max-richter.dev/max/nodarium/attachments/23e66a97-edcc-4aeb-bba6-ea06df5001d5) The downside is that this makes it a lot harder to cache the outputs of each node.
Author
Owner

My Idea is to split this up into several steps:

1. Rewrite Macros so the wasm functions accept variadic arguments.

I want the execute functions inside the rust code to look like:

#[nodarium_execute]
pub fn execute(op_type: *i32, a: *i32, b: *i32) -> Vec<i32> {

Then the macro should also check if the number of arguments matches the number of arguments inside the definition.

Then we can update the runtime to pass each argument as a single one.

2. Implement the Arena Allocator

Then we need to update the Nodes so that we have one global memory. And each node receives in addition to its arguments a address where it should start to write its output.

...

My Idea is to split this up into several steps: ## 1. Rewrite Macros so the wasm functions accept variadic arguments. I want the execute functions inside the rust code to look like: ```rust #[nodarium_execute] pub fn execute(op_type: *i32, a: *i32, b: *i32) -> Vec<i32> { ``` Then the macro should also check if the number of arguments matches the number of arguments inside the `definition`. Then we can update the runtime to pass each argument as a single one. ## 2. Implement the Arena Allocator Then we need to update the Nodes so that we have one global memory. And each node receives in addition to its arguments a address where it should start to write its output. ...
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: max/nodarium#20