-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance regression in Buffer.concat #45802
Comments
HI @wemeetagain. I've run it locally and it seems fixed in v19. See below: v14concat 10 buffers, 32 each: 0.00033s v16concat 10 buffers, 32 each: 0.00044s v18concat 10 buffers, 32 each: 0.00114s v19concat 10 buffers, 32 each: 0.0004s Note: I haven't investigated the cause, but, I'd wait for the next v18 release and compare. |
I bisected with the help of nvm, found that 17.2.0 introduced the regression. Then profiling with const randomBuffer = (length) => Buffer.from(Array.from({ length }, () => Math.random() * 255))
const ranBuf = randomBuffer(32);
const results = []
const buffers = Array.from({ length: 10 }, () => ranBuf)
const before = performance.now();
for (let i = 0; i < 10000000; i++) {
Buffer.concat(buffers)
}
const after = performance.now()
console.log(after - before); 17.1.0 (good)
17.2.0 (bad)
In 17.2.0, Further bisecting with git identifies #40488, which updates v8 from |
Question: is the perf fix likely to be picked up for node 18.x? or will we have to wait for 20.x to have the fix in an LTS? Thank you. |
appears to be resolved by node 20 (also 22 is good) |
Version
v18.12.1
Platform
Linux ruby 5.15.0-53-generic #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Buffer
What steps will reproduce the bug?
Run this under node v18 vs node v16
How often does it reproduce? Is there a required condition?
Always reproduceable
What is the expected behavior?
Expected behavior is that there is no performance regression.
What do you see instead?
Buffer.concat is ~2.5x slower after node v16 (v17 and beyond)
Additional information
No response
The text was updated successfully, but these errors were encountered: