nodejs / nodejs/node

Increased CPU utilization after upgrading from Node.js v20.20.0 to v22.x

未关闭
#62,939 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stale
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

Version

v22.22.0 / v22.22.2 / 24.15.0

Platform
Oracle Linux 8 latest
Subsystem

No response

What steps will reproduce the bug?
  1. Run workload on Node.js v20.20.0 → CPU ~68–70%
  2. Upgrade to Node.js v22.22.x or 24.15.0
  3. Run identical workload (same TPS, config)
  4. Observe CPU increase (~86–88%)
  5. Revert to v20 → CPU returns to baseline
How often does it reproduce? Is there a required condition?

consistently 100% reproducable

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

no bigger than 5% CPU degradation

What do you see instead?

20% CPU degradation

Additional information

We are observing a significant increase in CPU utilization after upgrading our runtime from Node.js v20.20.0 → v22.x (22.22.x), with no application-level changes.

A/B testing strongly indicates the regression is tied to the Node.js runtime upgrade rather than application logic.

Impact

  • ~20% relative CPU increase observed
  • Consistent across multiple test runs
  • No functional regression, but clear performance degradation

Environment

  • Node.js versions:
    • v20.20.0 (baseline)
    • v22.22.0 / v22.22.2
  • Workload:
    • High-throughput service (~17–18K TPS)
    • Distributed/multi-node setup
  • Runtime flags:
    • --max-semi-space-size=256
    • --max-old-space-size=3072

Observed Behavior

Scenario Node Version CPU Utilization
Baseline v20.20.0 ~68–70%
Upgraded runtime v22.22.x ~86–88%
v22.x + --max-semi-space-size=16 v22.22.x ~88%
Reverted runtime v20.20.0 ~68%

Key Findings

  1. Strong correlation with Node.js version

    • Reverting v22 → v20 reduces CPU by ~12–20%
    • No application changes between runs
  2. Memory tuning did not help

    • Adjusting --max-semi-space-size showed no improvement
    • Lower values increased GC frequency without reducing CPU
  3. Latest v22 versions do not fix the issue

    • Testing with v22.22.2 shows same behavior
  4. Maglev likely not the cause

    • Disabled by default in Node ≥22.9.0
    • Issue persists on versions where Maglev is disabled

What Was Ruled Out

  • Application-level regression
  • Load/TPS variation
  • GC tuning via semi-space adjustments
  • Early v22-only issues

Suspected Cause

Likely related to runtime-level changes introduced in Node.js v22, such as:

  • V8 upgrade (v11.x → v12.x)
  • JIT execution changes
  • GC or memory management differences
  • libuv / stream internal changes

Reproduction Steps (High-level)

  1. Run workload on Node.js v20.20.0 → CPU ~68–70%
  2. Upgrade to Node.js v22.22.x
  3. Run identical workload (same TPS, config)
  4. Observe CPU increase (~86–88%)
  5. Revert to v20 → CPU returns to baseline

Additional Notes

  • No explicit Node.js release notes mention this regression
  • Issue is reproducible under high throughput
  • Not observed in lower TPS environments (≤5–7K TPS)

##Questions##

  • Are there known CPU regressions or behavior changes in Node.js v22 / V8 12.x?
  • Are there recommended runtime flags or GC tuning options for high-throughput workloads in v22?
  • Any guidance on mitigating CPU increase when upgrading from v20 → v22?
  • Will an upgrade to the latest available version of Node.js v26 fix this issue?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在 Oracle Linux 8 上使用列出的内存标志,在 Node.js v20.20.0 和 v22.22.x 中复现已报告的高吞吐量工作负载,同时保持 TPS 和配置一致。比较 CPU 利用率,并记录一个最小且可重复的工作负载,或隔离出负责该运行时变更的原因;issue 中未指定源文件或测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, linux, node.js
领域
backend, performance
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
活跃
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。