feat: replace wasm-bindgen gluecode with language agnostic wrapper #15

Closed
opened 2026-01-20 14:42:06 +01:00 by max · 2 comments
Owner

Currently we have a wasm wrapper that only works with wasm files specifically generated by wasm-pack with wasm-bindgen. It would be very cool to have a wrapper that works with more generic wasm modules.

For this we also need to implement a new memory management strategy which is outlined here:

Execution Flow.svg

Currently we have a wasm wrapper that only works with wasm files specifically generated by wasm-pack with wasm-bindgen. It would be very cool to have a wrapper that works with more generic wasm modules. For this we also need to implement a new memory management strategy which is outlined here: ![Execution Flow.svg](/attachments/23e66a97-edcc-4aeb-bba6-ea06df5001d5)
Author
Owner

One downside of the new approach is that we cant really cache anything with it. Currently we dont reexecute nodes when their inputs dont change:

Link to Code

let inputHash = `node-${node.id}-${fastHashArrayBuffer(encoded_inputs)}`;
let cachedValue = this.cache?.get(inputHash);
if (cachedValue !== undefined) {
  results[node.id] = cachedValue as Int32Array;
  continue;
}

results[node.id] = node_type.execute(encoded_inputs);
One downside of the new approach is that we cant really cache anything with it. Currently we dont reexecute nodes when their inputs dont change: [Link to Code](https://git.max-richter.dev/max/nodarium/src/commit/6b6038e546a6d5e9584d397b7ebddfd6c55c6c27/app/src/lib/runtime/runtime-executor.ts#L238) ```ts let inputHash = `node-${node.id}-${fastHashArrayBuffer(encoded_inputs)}`; let cachedValue = this.cache?.get(inputHash); if (cachedValue !== undefined) { results[node.id] = cachedValue as Int32Array; continue; } results[node.id] = node_type.execute(encoded_inputs); ```
Author
Owner

Hmm, actually this branch already works pretty well 😂 There are no memory leaks and the performance is comparable to main

main feat/remove-wasm-bindgen
image.png image.png
Hmm, actually this branch already works pretty well 😂 There are no memory leaks and the performance is comparable to `main` | `main` | `feat/remove-wasm-bindgen` | | --- | --- | |![image.png](/attachments/acc89c45-b910-46c0-b61b-d694339cabe5) | ![image.png](/attachments/fd21ef14-6648-4aef-ae62-4b1daccdde89) |
max closed this issue 2026-01-20 18:57:43 +01:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: max/nodarium#15