Reduce PowerShell Lambda INIT time by omitting unwanted files from pa…#2358
Open
sankettangade wants to merge 1 commit into
Open
Reduce PowerShell Lambda INIT time by omitting unwanted files from pa…#2358sankettangade wants to merge 1 commit into
sankettangade wants to merge 1 commit into
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.
Comment on lines
+622
to
+625
| _stripAwsModuleFiles ` | ||
| -ModulesRoot $SavedModulesDirectory ` | ||
| -Filters $AwsModuleStripFilters ` | ||
| -ModuleNamePatterns $AwsAuthoredModuleNamePatterns |
afroz429
approved these changes
May 18, 2026
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.
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.