Skip to content

Performance degradation of Buffer allocation in NodeJS v24 #61967

Description

@damanis

Version

v24.13.0

Platform

Linux ubuntu24 6.14.0-37-generic #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

console.log(process.version);
let table = [], count = 1e6;
for (let chunk_size of [10, 20, 50, 100, 200].map(v=>v*1024))
{
    let ts = Date.now();
    for (let i = 0; i<count; i++)
        Buffer.allocUnsafe(chunk_size);
    let te = Date.now();
    table.push({chunk_size, ms: te-ts});
}
console.table(table, ['chunk_size', 'ms']);

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

Buffer allocation in NodeJS v24 should be same or better than in v20.

What do you see instead?

Degradation depended on chunk size:

v20.12.1
┌─────────┬────────────┬──────┐
│ (index) │ chunk_size │ ms   │
├─────────┼────────────┼──────┤
│ 0       │ 10240      │ 1044 │
│ 1       │ 20480      │ 1110 │
│ 2       │ 51200      │ 1230 │
│ 3       │ 102400     │ 1339 │
│ 4       │ 204800     │ 1969 │
└─────────┴────────────┴──────┘


v24.13.0
┌─────────┬────────────┬──────┐
│ (index) │ chunk_size │ ms   │
├─────────┼────────────┼──────┤
│ 0       │ 10240      │ 996  │
│ 1       │ 20480      │ 1223 │
│ 2       │ 51200      │ 1387 │
│ 3       │ 102400     │ 2077 │
│ 4       │ 204800     │ 3349 │
└─────────┴────────────┴──────┘

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.performanceIssues and PRs related to the performance of Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions