-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extending String de-optimizes method dispatch / Importing AWS SDK DynamoDB affects performance of third party library #6182
Comments
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 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. |
Maybe let me show the steps:
|
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 |
I isolated it to a call to
I don't know why it would cause global de-optimization, since theoretically this is a read operation and it's not like the other library code uses the created class, but I will see if we can remove this. |
I hypothesize the creation of an additional It looks to be related to autoboxing of string primitives. |
A fix was released in https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.709.0. The fix is available in v3.5.0 of |
Original PR adding the feature: #899 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
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
Observed Behavior
with dynamodb import
Expected Behavior
test output: around 800ms lower
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: