Skip to content

extending String de-optimizes method dispatch / Importing AWS SDK DynamoDB affects performance of third party library #6182

@sazarkin

Description

@sazarkin

Checkboxes for prior research

Describe the bug

After migrating from v2 to v3 I've noticed slowdown of one of our metrics.
Importing dynamodb client affects parsing of html files.

What exactly aws sdk v3 does on import? Is it changes some runtime params? How to turn it off?

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.13.1

Reproduction Steps

"use strict";
const initStart = performance.now();
const parse5_1 = require("parse5");

if (process.env.AWS_SDK === '1') {
    const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
    const version = require('@aws-sdk/client-dynamodb/package.json').version;
    console.log('DynamoDB', typeof client_dynamodb_1.DynamoDB, version);
}

const html = `<doctype html><html><head><title>Test</title></head><body><h1>Hello World</h1></body></html>`;

async function benchParse(count) {
    for (let i = 0; i < count; i++) {
        const doc = (0, parse5_1.parse)(html);
        (0, parse5_1.serialize)(doc);
    }
}

const name = 'bench-parse5';
const count = 1000000;
const benchFunc = benchParse;
const initDone = performance.now();
console.log('---', name, `init ${(initDone - initStart).toFixed(2)}ms`);
const startTime = performance.now();
console.profile(name);
benchFunc(count).then(() => {
    console.profileEnd();
    const grandTotal = performance.now() - startTime;
    console.log(`Count: ${count} Time: ${grandTotal.toFixed(2)}ms`);
    console.log('---');
});
{
  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.592.0",
    "parse5": "^7.1.2"
  }
}

Observed Behavior

with dynamodb import

DynamoDB function 3.592.0
--- bench-parse5 init 66.59ms
Count: 1000000 Time: 4507.70ms
---

Expected Behavior

test output: around 800ms lower

--- bench-parse5 init 12.97ms
Count: 1000000 Time: 3730.11ms
---

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Labels

bugThis issue is a bug.p1This is a high priority issuequeuedThis issues is on the AWS team's backlog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions