-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
node::Buffer::New is 4x slower than V8 APIs #44111
Copy link
Copy link
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.node-apiIssues and PRs related to the Node-API.Issues and PRs related to the Node-API.performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.node-apiIssues and PRs related to the Node-API.Issues and PRs related to the Node-API.performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.
Type
Projects
Status
Done
Version
v19.0.0-pre
Platform
Linux 19-Ubuntu SMP Wed Jun 22 17:44:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
buffer
What steps will reproduce the bug?
npm install.node v8_buffers.js, which usesv8::ArrayBuffer::NewBackingStore+v8::ArrayBuffer::New.node node_buffers.js, which usesnode::Buffer::New.How often does it reproduce? Is there a required condition?
always
What is the expected behavior?
Performance of
node::Buffer::Newshould be comparable to the native V8 APIs.What do you see instead?
It's around 4x slower:
It is even worse (~6x) if you use
timeto include the GC finalizer time:Additional information
I know that
node::Buffer::Newdoes more than the V8 APIs, so of course it is slower. Especially a lot of the finalizer stuff seems to be pretty high overhead. But 4x feels quite a bit slower, and I suspect that there is some room for improvement.Attached are two
perf scriptprofiles:v8_buffers.gz
node_buffers.gz