Skip to content

Feature request: Implement mechanism to update classesloaded.txt file for automatic priming #2006

@phipag

Description

@phipag

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:

  1. Merge to Main - Trigger on push to main branch (after PR merge)
  2. Checkout Code - Get the latest main branch code
  3. Java Files Changed? - Check if any .java files were modified in the merge
  4. Identify Affected Powertools Modules - Determine which modules need updates
  5. Generate classesloaded.txt - Create the runtime classes file for each module
  6. Clean Files - Apply sed commands as per Priming documentation
    • Example sed command: sed 's/.*\[class,load\] \([^ ]*\) source:.*/\1/' classloaded.txt > classloaded_clean.txt
  7. Sort File Contents - Sort file contents to assure stable diffs
  8. Files Have Diff? - Check if generated files differ from existing ones
  9. 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
Loading

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedTasks that can't be started yetfeature-requestNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions