Performance degradation of Buffer allocation in NodeJS v24
未关闭
还没有人认领这个 Issue。
buffer
performance
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在所述 Linux 环境中运行随附的 Buffer.allocUnsafe 基准测试,分别使用 Node.js v20.12.1 和 v24.13.0,然后检查 Buffer 分配路径是否有影响较大 chunk 的变更。完成的标准是解释清楚该回归问题,并通过可复现的基准测试或测试演示相关行为及任何修复。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend, performance
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100