perf(layer): precompile Python sources in Lambda layers - #8520
Open
leandrodamascena wants to merge 1 commit into
Open
leandrodamascena wants to merge 1 commit into
leandrodamascena wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8520 +/- ##
========================================
Coverage 96.92% 96.92%
========================================
Files 317 317
Lines 15911 15911
Branches 1398 1398
========================================
Hits 15422 15422
Misses 353 353
Partials 136 136 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Issue number: closes #8516
Summary
Changes
Precompile the final layer contents inside the existing Lambda runtime image, after dependency pruning. Keep the
.pyfiles so source inspection, tracebacks, and source fallback remain available.Use
checked-hashinvalidation: timestamp caches were ignored in five of ten runtime/architecture combinations because ZIP packaging rounded source timestamps. Hash-based caches were used in all ten.The canary now exercises parsing, JSON Schema validation, and source inspection, and rejects layer source recompilation before sending the deployment notification. Validation runs on
Create;DeleteandUpdatestill work after a cache failure. Layer build changes also trigger the relevant CI checks.User experience
Consumers keep the same imports and deployment process. In the Lambda experiment, Python 3.13 ARM64 median initialization fell from 1,176 ms to 827 ms with 512 MB, measured over three cold starts per variant. Gains depend on the imports and runtime.
Keeping both sources and bytecode increases uncompressed layer size by approximately 5–8 MB in the tested artifacts. Existing functions pinned to a layer version keep their current artifact.
Validation
The full production layer release pipeline has not been run for this branch.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.