Skip to content

Reduce PowerShell Lambda INIT time by omitting unwanted files from pa…#2358

Open
sankettangade wants to merge 1 commit into
devfrom
stangade-perf-improvements-lambda
Open

Reduce PowerShell Lambda INIT time by omitting unwanted files from pa…#2358
sankettangade wants to merge 1 commit into
devfrom
stangade-perf-improvements-lambda

Conversation

@sankettangade
Copy link
Copy Markdown
Contributor

Description of changes:

New-AWSPowerShellLambdaPackage now strips files that have no purpose at Lambda runtime from AWS-authored PowerShell modules during packaging:

  • Files stripped: *.xml (PowerShell help XML, .NET XMLDoc, PowerShellGet metadata) and *.pdb (debug symbols).
  • Scope: Only AWSPowerShell.NetCore and AWS.Tools.* modules under the package's Modules/ 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):

Architecture Mean Init (Unstripped) Mean Init (Stripped) Δ ms Improvement %
x86_64 2563.7 ms 2448.6 ms −115.1 ms 4.49%
arm64 2939.6 ms 2805.6 ms −134.0 ms 4.56%

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-AWSPowerShellLambdaPackage benefit automatically with no script or invocation changes.


Test Plan

  • All Pester tests pass (Invoke-Pester PowerShell/Tests/)
  • Manual end-to-end packaging of STS, S3, EC2 handlers on x86_64 and arm64
  • Functions deployed to AWS Lambda and invoked successfully without Module load failed or Cannot find errors in CloudWatch logs
  • Cold-start benchmarks (100 invocations × 6 functions) compared against matched-runtime unstripped baseline

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sankettangade sankettangade marked this pull request as ready for review May 7, 2026 19:54
@sankettangade sankettangade requested review from a team as code owners May 7, 2026 19:54
@sankettangade sankettangade requested review from normj and philasmar May 7, 2026 19:54
@afroz429 afroz429 self-requested a review May 18, 2026 18:17
@sankettangade sankettangade force-pushed the stangade-perf-improvements-lambda branch from 788a8d7 to 264183c Compare May 18, 2026 19:39
@GarrettBeatty GarrettBeatty requested a review from Copilot May 18, 2026 19:41
@GarrettBeatty GarrettBeatty added the Release Not Needed Add this label if a PR does not need to be released. label May 18, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.NetCore and AWS.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release Not Needed Add this label if a PR does not need to be released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants