Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): experimental runtime model interpreter 馃毀馃毀 #1221

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Mar 22, 2024

馃毀馃毀馃毀

Prototyping serde alternative that accepts a Smithy json model at runtime.

AwsRestJson1 implementation is in aws/aws-sdk-js-v3#5935

Goals:

  • performance and code size parity or improvement vs. current code gen serde
  • allow runtime provision of models such as a regular Smithy JSON model file or compressed form
  • swap protocols at runtime in the same client?? 馃

@kuhe
Copy link
Contributor Author

kuhe commented Mar 27, 2024

testing of the AwsRestJson1 protocol implementation shows the following:

Sizes are in kb
stat (input files total size) / parsed (output bundle file size) / gzip (bundle plus gzip compression)

// Lambda bare-bones client from prod
/**
 * 366/129/33
 */

// Lambda aggregated client from prod
/**
 * 591/223/46
 */

// creating the aggregated client using the bare-bones client and the runtime model interpreter
// using the default lambda.json smithy model file.
/**
 * 764/524/88
 */

// creating the aggregated client using the bare-bones client and the runtime model interpreter
// using a compressed smithy model file (using pattern recognition algorithm)
// this would be the type used in production, hypothetically
/**
 * 475/215/51
 */

The conclusion is that runtime model interpretation, at least for JSON, is approximately the same as the existing aggregated client. It doesn't present meaningful performance/size benefits other than enabling modification of the model/protocol at runtime.

@kuhe
Copy link
Contributor Author

kuhe commented Mar 27, 2024

sample usage

// import bare-bones client with no commands on it
import { LambdaClient } from "@aws-sdk/client-lambda";
// import protocol implementation
import { AwsRestJson1 } from "@aws-sdk/core";
// Smithy json model
import model from "../../../scripts/smithy-model/temp/lambda.min";

const awsRestJson1 = new AwsRestJson1(model);

// create aggregated client from model in runtime
const LambdaAggregatedClient = awsRestJson1.create(LambdaClient);

// aggregated client is able to call methods
new LambdaAggregatedClient({}).getFunction({ FunctionName: "" });
new LambdaAggregatedClient({}).invoke({ FunctionName: "", Payload: "" });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant