Skip to content

Performance regression when enumerating objects (for shallow cloning) v12.15.0 to v12.16.1 #32049

Closed
@dominykas

Description

@dominykas
  • Version: 12.16.1
  • Platform: Linux; OSX
  • Subsystem: V8

What steps will reproduce the bug?

The following code became slightly slower going from v12.15.0 to v12.16.1 (likely 12.16.0).

'use strict';

const NUM_METHODS = 250;
const ITERATIONS = 10000;

const obj = {};

for (let i = 0; i < NUM_METHODS; ++i) {

    obj[`item${i}`] = {};
}

console.time();

for (let i = 0; i < ITERATIONS; ++i) {
    const res = Object.assign({}, obj); // { ...obj } performs worse by a similar margin
}

console.timeEnd();

Additional information

I'm still not 100% sure this accounts for all of the slowdowns while looping through object keys that I'm seeing and I'm working on a further reduced test case, but the results here are very consistent.

Adding more items into the object makes things slower, seemingly linearly.

Note that this is quite similar to #31961, however the fix on master in 3d894d0 resolves #31961, but not this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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