Updated the pwsh-runtime layer build process, such that all .ps1 script files are built into the pwsh-runtime.psm1 module file. This speeds up the time taken to load the module as there is no evaluation of the file system or dot-sourcing of script files. This change reduces AWS Lambda init times.
When tested with a small sample size of cold start executions (ten execution before and after), with a Lambda Function configured with 1024MB of memory, this change improves Init Duration by ~200ms on average.
Testing
The data shows the Init Duration decreases when using a combined pwsh-runtime.psm1 file. The data shows a faster minimum, a faster maximum and a lower average Init Duration.
PS> $output = foreach ($group in ($data | Group-Object -Property Psm1Format)) {
$measured = $group.Group.InitDuration | Measure-Object -Average -Maximum -Minimum
[PSCustomObject]@{
Name = $group.Name
Maximum = $measured.Maximum
Minimum = $measured.Minimum
Average = $measured.Average
}
}
$output | Format-Table
Name Maximum Minimum Average
---- ------- ------- -------
Combined 1312.510 998.160 1139.207
Separate 1496.960 1176.150 1334.301
Description of changes:
Updated the
pwsh-runtime
layer build process, such that all.ps1
script files are built into thepwsh-runtime.psm1
module file. This speeds up the time taken to load the module as there is no evaluation of the file system or dot-sourcing of script files. This change reduces AWS Lambda init times.When tested with a small sample size of cold start executions (ten execution before and after), with a Lambda Function configured with
1024MB
of memory, this change improves Init Duration by ~200ms on average.Testing
The data shows the Init Duration decreases when using a combined
pwsh-runtime.psm1
file. The data shows a faster minimum, a faster maximum and a lower average Init Duration.The raw init duration data in CSV format:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.