-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Use case
PLEASE READ: Priming documentation: https://github.com/aws-powertools/powertools-lambda-java/blob/main/Priming.md
PR introducing class-preloading: #1861.
This project uses class pre-loading to implement automatic priming to reduce AWS Snapstart restore duration. The class pre-loader reads the classesloaded.txt
of a powertools module that implements automatic priming and attempts to load each class listed in this file before AWS Snapstart takes a memory snapshot. If a class is not found, it will be ignored (this is the case for test classes for example).
The goal of this issue is to design and implement a mechanism that keeps the classesloaded.txt
file automatically up-to-date as the project and code in each module evolves. An individual contributor should not have any knowledge about AWS Snapstart or priming techniques when contributing a change to this project. This process should be as automated as possible.
Solution/User Experience
Idea (please suggest alternatives if you have another idea)
Create a GitHub workflow that runs when a merge to main branch happens.
Workflow Steps:
- Merge to Main - Trigger on push to main branch (after PR merge)
- Checkout Code - Get the latest main branch code
- Java Files Changed? - Check if any
.java
files were modified in the merge - Identify Affected Powertools Modules - Determine which modules need updates
- Generate classesloaded.txt - Create the runtime classes file for each module
- Clean Files - Apply
sed
commands as per Priming documentation- Example
sed
command:sed 's/.*\[class,load\] \([^ ]*\) source:.*/\1/' classloaded.txt > classloaded_clean.txt
- Example
- Sort File Contents - Sort file contents to assure stable diffs
- Files Have Diff? - Check if generated files differ from existing ones
- Create Update PR - Create a new PR with the updated classesloaded.txt files (if there is a diff)
flowchart TD
A[Merge to Main Branch] --> B[Checkout Code]
B --> C{Java Files Changed?}
C -->|No| D[Stop - No Action Needed]
C -->|Yes| E[Identify Affected Powertools Modules]
E --> F[Generate classesloaded.txt for Each Module]
F --> G[Clean Affected Files Using sed Command]
G --> H[Sort File Contents to Assure Stable Diffs]
H --> I{Files Have Diff?}
I -->|No| J[Stop - No Changes]
I -->|Yes| K[Create New Branch]
K --> L[Commit Changes to New Branch]
L --> M[Create PR to Update classesloaded.txt]
M --> N[End - PR Ready for Review]
style A fill:#e1f5fe
style D fill:#ffebee
style J fill:#ffebee
style N fill:#e8f5e8
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Java) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, TypeScript, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status