Reduce PowerShell Lambda INIT time by omitting unwanted files from pa…#2358
Conversation
788a8d7 to
264183c
Compare
There was a problem hiding this comment.
Pull request overview
This PR reduces AWS Lambda PowerShell package size and cold-start INIT time by stripping runtime-unneeded files from AWS-authored PowerShell modules during dependency preparation.
Changes:
- Adds constants and helper logic to remove XML help/docs and PDB files from
AWSPowerShell.NetCoreandAWS.Tools.*modules. - Invokes the strip step after dependent module preparation.
- Adds Pester coverage for stripping behavior and updates module version/changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
PowerShell/Module/Private/_Constants.ps1 |
Defines strip file filters and AWS-authored module name patterns. |
PowerShell/Module/Private/_DeploymentFunctions.ps1 |
Adds _stripAwsModuleFiles and calls it during dependency preparation. |
PowerShell/Tests/_stripAwsModuleFiles.Tests.ps1 |
Adds tests for stripping, preservation, third-party modules, and no-op cases. |
PowerShell/Tests/Get-AWSPowerShelLambdaTemplate.Tests.ps1 |
Moves helper and mocks into BeforeAll. |
PowerShell/Module/AWSLambdaPSCore.psd1 |
Bumps PowerShell module version to 5.0.2.0. |
CHANGELOG.md |
Adds release notes for the packaging optimization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
philasmar
left a comment
There was a problem hiding this comment.
You should not modify the CHANGELOG.md manually. Add a change file to your PR. Follow this guide to do so https://github.com/aws/aws-lambda-dotnet/blob/master/CONTRIBUTING.md#adding-a-change-file-to-your-contribution-branch.
|
@philasmar this powershell module file and related things is not configured for autover i dont think |
@philasmar As Garrett said, PowerShell files are not configured for auto changelog generation, I checked the previous PRs that modify these same files and saw we had to add the changelog manually. |
Description of changes:
New-AWSPowerShellLambdaPackagenow strips files that have no purpose at Lambda runtime from AWS-authored PowerShell modules during packaging:*.xml(PowerShell help XML, .NET XMLDoc, PowerShellGet metadata) and*.pdb(debug symbols).AWSPowerShell.NetCoreandAWS.Tools.*modules under the package'sModules/directory. Third-party PowerShell modules are not touched.Measured Impact
Cold-start INIT measured against a matched-runtime baseline (
dotnet10,Microsoft.PowerShell.SDK 7.5.4, 512 MB, us-east-1, 100 cold starts each).AWS.Tools.EC2 example (largest module tested):
EC2 also showed a notable tail-latency improvement: P99 dropped from 4697.8 ms → 2954.4 ms on x86_64 (−1.7s).
Across services, the improvement scales with bytes stripped per module, averaging ~5% INIT reduction on chunky modules. All users of
New-AWSPowerShellLambdaPackagebenefit automatically with no script or invocation changes.Test Plan
Invoke-Pester PowerShell/Tests/)Module load failedorCannot finderrors in CloudWatch logsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.