arrayBuffer->Detach() in C++ has more overhead than it was expected to. #1266
Guthib-of-Dan
started this conversation in
Ideas
Replies: 1 comment 8 replies
-
Lol. Well, yes. Rust, C, C++ are fast because they inherently do not have a GC. Go, Java, JavaScript, Haskell are slow because they are inherently designed around a GC. Proposing manual memory management for JavaScript is like proposing Atheism to be more like Islam. It's the wrong venue. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have recently finished creating 2 TC39 proposals on the way we handle network data in JavaScript - "JSON.parseBinary" and "ArrayBuffer.prototype.detach" (the one I am going to talk about now).
Both proposals contain benchmarks to make a solid background for the idea and "proposal-arraybuffer-detach" has an example with C++ V8 API and NAPI, where I call some js callback in a loop from C++, give it an ArrayBuffer over existing memory and detach that memory after the callback (or IN the callback). Just like uWebSockets.js does.
The nuance is that results do have a difference, which is unnoticeable at first.
What an AI suggest is that inside the callback "ArrayBuffer" as a param is kept hot in memory, but after callback - not. Also this is not just about speed, this is about immediately handling the memory you know you needn't after some parsing (gc-pressure test in that repo suggest that leaving GC handle all that memory comes at a huge cost).
What should you do with this?
So we can create new handlers or extend existing functionality to support manual memory management. Everything, obviously, has a sense of integrating only if at least "proposal-arraybuffer-detach" gets its deserved appraisal.
Btw, don't you mind me mentioning uWebSockets.js in my proposal?
It is already there in README, but this discussion is the first place where it goes to. Do you have any objections?
Beta Was this translation helpful? Give feedback.
All reactions