-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
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.
Description
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?
- Clone this repo.
- Run
npm install. - Run
node v8_buffers.js, which usesv8::ArrayBuffer::NewBackingStore+v8::ArrayBuffer::New. - Run
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::New should be comparable to the native V8 APIs.
What do you see instead?
It's around 4x slower:
$ node node_buffers.js
1000000
nodeBuffers: 1.649s
$ node v8_buffers.js
1000000
rawArrayBuffers: 432.881msIt is even worse (~6x) if you use time to include the GC finalizer time:
$ \time node node_buffers.js
1000000
nodeBuffers: 1.657s
2.99user 0.41system 0:02.68elapsed 127%CPU (0avgtext+0avgdata 648340maxresident)k
0inputs+0outputs (0major+332498minor)pagefaults 0swaps
$ \time node v8_buffers.js
1000000
rawArrayBuffers: 430.123ms
0.54user 0.12system 0:00.60elapsed 111%CPU (0avgtext+0avgdata 308632maxresident)k
0inputs+0outputs (0major+71241minor)pagefaults 0swapsAdditional information
I know that node::Buffer::New does 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 script profiles:
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