Skip to content

node22 performance degradation #184

@FishOrBear

Description

@FishOrBear

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions