3 ms·
If only JS had better multithreading shared memory capabilities it would be perfect for me. But just with fixed length array buffers limited to numbers I can't
by pietrovismara 7y ago
If only JS had better multithreading shared memory capabilities it would be perfect for me. But just with fixed length array buffers limited to numbers I can't do much. I tried regular IPC instead but there's too much latency. It is a huge shame.
- disease 7y agoI was going to reply "but SharedArrayBuffer!" until I checked the site below and came back to reality. https://caniuse.com/#feat=sharedarraybuffer https://caniuse.com/#feat=sharedarraybuffer
- pietrovismara 7y agoAnd as I said, SharedArrayBuffer is a fixed length, number only array. While it may work well for some use cases, it really can't for many others. Or am I missing something? By the way, browser compatibility is not a concern if you develop for Electron. Just target Chrome and you're done.
- meheleventyone 7y agoI think they meant it’s not supported. Although saying that memory in lower level languages is basically treated as an array of numbers and you can treat the array buffers similarly. It’s also how Wasm memory is exposed. So you can serialize JS and other data in and out of them.
- seangrogg 7y agoAlthough it's number-only said numbers can be used to represent anything, really. If you can convert your data to number-friendly formats and back there's really no issue. If you need strings you can use the native TextEncoder/TextDecoder and shuffle things around as UTF-8. If you need JSON-like objects you can look at encoding formats such as Protocol Buffers, Thrift, and the like. This introduces non-zero latency shuffling data between formats but that's largely what normally occurs over IO boundaries anyways.
- littlecranky67 7y agoFunny thing is, it is not supported on purpose. Most browser had support for SharedArrayBuffer but it got disabled when Meltdown/Spectre came to light (as well as high precision timers in the browser) [0]. [0]: https://www.sitepen.com/blog/the-return-of-sharedarraybuffers-and-atomics/ https://www.sitepen.com/blog/the-return-of-sharedarraybuffer...
- BubRoss 7y agoWhen you say regular IPC, have you tried this? https://github.com/LiveAsynchronousVisualizedArchitecture/simdb https://github.com/LiveAsynchronousVisualizedArchitecture/si... It should be MUCH faster than loopback IP IPC if that's what you were trying.