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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk): optimize cold-start performance #320

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

jianzs
Copy link
Contributor

@jianzs jianzs commented Aug 6, 2024

Move import statements to container initialization to enhance runtime performance.

By shifting import statements to container initialization rather than at invocation time, we ensure that the import process is completed with more resources available, leading to improved cold-start performance.

For the hello and store path handlers in the quickstart example, this change reduces the latency of the first request from 9s to 2.4s. Increasing the memory size from 128MB to 1024MB further cuts the first request latency down to 1.8s. These measurements were taken in China, and the lambda instance is deployed in the us-east-1 region.

The image below shows the execution time of a function when the import statement is placed inside and outside the handler under different memory sizes.
image

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

  • SDK

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

@jianzs jianzs added sdk Client SDK and Infra SDK 💡feature This issue or pull request is related to a new feature. labels Aug 6, 2024
Copy link

changeset-bot bot commented Aug 6, 2024

🦋 Changeset detected

Latest commit: a1d47be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@plutolang/pluto-infra Patch
@plutolang/cli Patch
@plutolang/simulator-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jianzs jianzs requested a review from Peefy August 6, 2024 12:16
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job! LGTM!

@Peefy
Copy link
Contributor

Peefy commented Aug 6, 2024

PR conflicted.

Move import statements to container initialization to enhance runtime performance.

By shifting import statements to container initialization rather than at invocation time, we ensure that the import process is completed with more resources available, leading to improved cold-start performance.

For the `hello` and `store` path handlers in the quickstart example, this change reduces the latency of the first request from 9s to 2.4s. Increasing the memory size from 128MB to 1024MB further cuts the first request latency down to 1.8s. These measurements were taken in China, and the lambda instance is deployed in the us-east-1 region.
@jianzs jianzs merged commit ba661d2 into pluto-lang:main Aug 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡feature This issue or pull request is related to a new feature. sdk Client SDK and Infra SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants