performance: node22 performance degradation

Version

22.0.0

Platform

Linux debian 6.1.0-13-amd64 nodejs/node#1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

const COUNT1 = 1024;
const COUNT2 = 5120;
const COUNT3 = 20480;

function encrypt(buf, value = 199)
{
    let count = Math.min(buf.length, COUNT1);
    for (let i = 0; i < count; i++)
        buf[i] += value;

    count = Math.min(buf.length, COUNT2);
    for (let i = COUNT1; i < count; i += 2)
        buf[i] += value;
}

const buf = Buffer.alloc(65535);
function aa()
{
    console.time("j");
    for (let i = 0; i < 20 * 125; i++)
        encrypt(buf, 199);
    console.timeEnd("j");
}

for (let index = 0; index < 20; index++) {
    aa()
}

When I increase the number of operations, due to the optimization of v8, the performance will be shortened to 23ms, but it is still worse than the previous 21ms performance.

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

node perf.js

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

in nodejs 20.12.2

j: 64.709ms
j: 54.228ms
j: 21.822ms
j: 21.83ms
j: 21.858ms
j: 21.851ms
j: 21.821ms
j: 21.841ms
j: 21.827ms
j: 21.887ms
j: 21.823ms
j: 21.863ms
j: 21.842ms
j: 21.857ms
j: 21.845ms
j: 21.851ms
j: 21.821ms
j: 21.843ms
j: 21.816ms
j: 21.847ms

in nodejs 22.0.0

j: 44.602ms
j: 34.992ms
j: 35.053ms
j: 34.981ms
j: 35.355ms
j: 35.013ms
j: 35.036ms
j: 34.979ms
j: 35.056ms
j: 35.135ms
j: 35.09ms
j: 34.989ms
j: 35.023ms
j: 34.974ms
j: 35.028ms
j: 35.076ms
j: 35.034ms
j: 34.973ms
j: 35.045ms
j: 35.013ms

What do you see instead?

1

Additional information

1

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I have updated the nodejs version to 22.9.0 and I will update the benchmark.

nodejs20.17.0

j: 140.934ms
j: 125.321ms
j: 49.63ms
j: 49.295ms
j: 49.417ms
j: 49.363ms
j: 49.328ms
j: 49.411ms
j: 49.232ms
j: 49.446ms
j: 49.753ms
j: 49.99ms
j: 49.585ms
j: 49.632ms
j: 49.354ms
j: 49.356ms
j: 49.381ms
j: 49.337ms
j: 49.347ms
j: 49.299ms
j: 49.462ms
j: 49.331ms
j: 49.408ms
j: 49.27ms
j: 49.269ms
j: 49.37ms
j: 49.35ms
j: 49.326ms
j: 49.338ms
j: 49.303ms

nodejs.22.9.0

j: 86.212ms
j: 73.845ms
j: 73.809ms
j: 79.236ms
j: 53.444ms
j: 53.285ms
j: 53.054ms
j: 53.05ms
j: 53.324ms
j: 53.3ms
j: 53.27ms
j: 53.185ms
j: 53.375ms
j: 53.145ms
j: 53.381ms
j: 53.341ms
j: 53.144ms
j: 53.147ms
j: 53.412ms
j: 53.042ms
j: 53.241ms
j: 53.215ms
j: 53.236ms
j: 53.166ms
j: 53.061ms
j: 53.086ms
j: 53.187ms
j: 53.011ms
j: 53.1ms
j: 53.225ms

It is probably because nodejs has disabled Maglev in 22.9.0. The performance is now similar to v20, but it is still slightly slower

@joyeecheung