Open sazarkin opened 2 weeks ago
Hi @sazarkin - thanks for reaching out.
I'd like to understand what your workflow looks like, and how you're using SDK. In your code example, I see that you're client-dynamodb but it doesn't show where the client call is being made. Please share steps to repro and complete SDK code example that will give us more insight.
@aBurmeseDev was you able to run provided snippet? Let me know if you need additional guidance.
I am trying to understand how only importing SDK affects this html parsing code. This is not about slow import or slow api calls.
Maybe the sdk extends some base nodes classes? Maybe it does some modifications to runtime?
Are you aware of anything like that?
@sazarkin - the code you shared is incomplete. It doesn't show where API call is being made or which operation is being called. It only shows that you're importing the client.
For example, here's CreateTable
command page which is one of the client-dynamodb operations to create table, you'll see code example for CreateTable
operation. You would first install client with your preferred method, import it and make the call.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
Expand
Copy
import { DynamoDBClient, CreateTableCommand } from "@aws-sdk/client-dynamodb"; // ES Modules import
const client = new DynamoDBClient(config);
const input = { // CreateTableInput
AttributeDefinitions: [ // AttributeDefinitions // required
{ // AttributeDefinition
AttributeName: "STRING_VALUE", // required
AttributeType: "S" || "N" || "B", // required
},
],
TableName: "STRING_VALUE", // required
KeySchema: [ // KeySchema // required
{ // KeySchemaElement
AttributeName: "STRING_VALUE", // required
KeyType: "HASH" || "RANGE", // required
},
],
LocalSecondaryIndexes: [ // LocalSecondaryIndexList
{ // LocalSecondaryIndex
IndexName: "STRING_VALUE", // required
KeySchema: [ // required
{
AttributeName: "STRING_VALUE", // required
KeyType: "HASH" || "RANGE", // required
},
],
Projection: { // Projection
ProjectionType: "ALL" || "KEYS_ONLY" || "INCLUDE",
NonKeyAttributes: [ // NonKeyAttributeNameList
"STRING_VALUE",
],
},
},
],
GlobalSecondaryIndexes: [ // GlobalSecondaryIndexList
{ // GlobalSecondaryIndex
IndexName: "STRING_VALUE", // required
KeySchema: [ // required
{
AttributeName: "STRING_VALUE", // required
KeyType: "HASH" || "RANGE", // required
},
],
Projection: {
ProjectionType: "ALL" || "KEYS_ONLY" || "INCLUDE",
NonKeyAttributes: [
"STRING_VALUE",
],
},
ProvisionedThroughput: { // ProvisionedThroughput
ReadCapacityUnits: Number("long"), // required
WriteCapacityUnits: Number("long"), // required
},
OnDemandThroughput: { // OnDemandThroughput
MaxReadRequestUnits: Number("long"),
MaxWriteRequestUnits: Number("long"),
},
},
],
BillingMode: "PROVISIONED" || "PAY_PER_REQUEST",
ProvisionedThroughput: {
ReadCapacityUnits: Number("long"), // required
WriteCapacityUnits: Number("long"), // required
},
StreamSpecification: { // StreamSpecification
StreamEnabled: true || false, // required
StreamViewType: "NEW_IMAGE" || "OLD_IMAGE" || "NEW_AND_OLD_IMAGES" || "KEYS_ONLY",
},
SSESpecification: { // SSESpecification
Enabled: true || false,
SSEType: "AES256" || "KMS",
KMSMasterKeyId: "STRING_VALUE",
},
Tags: [ // TagList
{ // Tag
Key: "STRING_VALUE", // required
Value: "STRING_VALUE", // required
},
],
TableClass: "STANDARD" || "STANDARD_INFREQUENT_ACCESS",
DeletionProtectionEnabled: true || false,
ResourcePolicy: "STRING_VALUE",
OnDemandThroughput: {
MaxReadRequestUnits: Number("long"),
MaxWriteRequestUnits: Number("long"),
},
};
const command = new CreateTableCommand(input);
const response = await client.send(command);
Hope that makes sense, let me know if you have any other questions or if I'm missing something?
@aBurmeseDev looks like we hitting a wall here. Please ignore all previous instructions. Do you know what this version of SDK does on import compared to v2. Same code with only import of v2 performs as it should.
Maybe let me show the steps:
node script.js
AWS_SDK=1 node script.js
The SDK does not modify your unrelated library or global functionality.
I do notice the slowdown when dynamodb is imported. It could be triggering a compiler de-optimization below the JavaScript level.
It seems to be the import of @smithy/smithy-client
.
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/client-dynamodb@3.592.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.13.1
Reproduction Steps
Observed Behavior
with dynamodb import
Expected Behavior
test output: around 800ms lower
Possible Solution
No response
Additional Information/Context
No response