Experimental flag to boost 'package' command performance #7923
+40
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue(s) does this change fix?
#4053
Why is this change necessary?
sam package
(anddeploy
) 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 boostssam 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
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.