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

Experimental flag to boost 'package' command performance #7923

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

eyalroth
Copy link

@eyalroth eyalroth commented Mar 6, 2025

Which issue(s) does this change fix?

#4053

Why is this change necessary?

sam package (and deploy) can take an extremely long time.

This happens because the command zips every lambda resource in a template, even if all the lambdas point to the same local path. For instance, with NodeJS lambdas, there are many files involved due to the nature of npm/node, and that puts a serious dent on the disk (especially so in CI environments where SSD is not guarenteed).

How does it address the issue?

Normally, sam build will create a separate directory for each lambda resource in the template. However, there is an experimental flag -- SAM_CLI_BETA_BUILD_PERFORMANCE -- which creates only one shared directory for all the lambdas. This boosts sam build performance tremendously, and it works because in most cases, all lambdas in a project share the same code (just a different handler endpoint).

This PR adds a new flag -- SAM_CLI_BETA_PACKAGE_PERFORMANCE -- that is aimed to work in conjunction with the build performance flag.

All that it does is add a cache that is currently only used by ResourceZip + S3Uploader. The uploader checks if the local path was previously uploaded, and if so, it simply returns the cached upload url.

What side effects does this change have?

Should have no effect as the changes are only enabled when using the new flag.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Mar 6, 2025
@eyalroth eyalroth force-pushed the experimental-package-performance branch from d585998 to 5164b4c Compare March 6, 2025 15:06
@eyalroth eyalroth marked this pull request as ready for review March 6, 2025 15:08
@eyalroth eyalroth requested a review from a team as a code owner March 6, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant