Closed
Description
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
const randomBuffer = (length) => Buffer.from(Array.from({length}, () => Math.random() * 255))
const testCases = [
{bytesPerBuffer: 32, numBuffers: 10},
]
for (const {bytesPerBuffer, numBuffers} of testCases) {
const results = []
for (let i = 0; i < 100_000; i++) {
const buffers = Array.from({length: numBuffers}, () => randomBuffer(bytesPerBuffer))
const before = performance.now()
Buffer.concat(buffers)
const after = performance.now()
results.push(after - before)
}
const avgTime = results.reduce((a, b) => a + b, 0) / results.length
console.log(`concat ${numBuffers} buffers, ${bytesPerBuffer} each: ${avgTime}s`)
}
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