Replies: 1 comment
-
|
Electron is the only platform that is shipped with external ArrayBuffer disabled. If you build Node.js from source, you disable it using a define. When the feature is disabled, a regular ArrayBuffer is used instead. When you access the data structure, the fallback handler would call a native function through Node API to retrieve/store the value. When you use one of the special properties like None of that, of course, applies to WebAssembly. JavaScript has access to the entire WASM memory space. It's just one giant ArrayBuffer. This buffer can become "detached" though when memory allocation occurs in WASM. Data accessors have to check for that, slowing things down a bit. That's why it's quicker to use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
Absolutely amazing project I have been looking for.
In the documentation is stated that shared arrays are not supported in Electron applications. But what about the rest?
If I do this:
Is there any memory copy?
I did a few benchmarks in the browser:
The fastest one: Accessing each element in 10k array is on pair with JavaScript but array access is about twice slower that next example.
Accessing via get: Fastest to get an array but slow iteration about 6-8 slower than example above.
Zig code. It is dumb AI generated snippet so I would not search for any
Generally, I want to access data stored on the zig side from JavaScript, preferably without causing GS spikes. With such a goal in mind I might prefer slower iterations than even if it would be faster copying 10k array using typedArray and iterating elements directly. Zigar exposing memory usage on the zig side, however would be nice to understand better what happens in JS
Again, fantastic project! I am comparing to wasm-bindgen. Yes, it is powerful and full-featured, but my concern was always about how it is managing data and how much garbage it creates while with zigar I can see where I forced to use allocators, and even though I did not tried yet, I would assume for those cases I could use Arena allocator for example to avoid heap allocations.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions