Skip to content

Commit e23bd89

Browse files
authored
Add profile analysis support in dev inner loop cold start pipeline (#10901)
* Add cold start profile analysis support on windows. * Remove ThreadTime from default perfview arguments * Fix `outputParentDirectory`. Removed cleanup code.
1 parent 01ad933 commit e23bd89

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

eng/ci/host.coldstart.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ parameters:
2020
- name: perfViewCollectArguments
2121
displayName: PerfView profile collection arguments (Valid only if "Collect PerfView Profile" is true))
2222
type: string
23-
default: '/NoGui /AcceptEula /NoV2Rundown /NoNGenRundown /NoClrRundown /BufferSizeMB=64 /CircularMB=64 /ThreadTime /Providers=a7044dd6-c8ef-4980-858c-942d972b6250'
23+
default: '/NoGui /AcceptEula /NoV2Rundown /NoNGenRundown /NoClrRundown /BufferSizeMB=64 /CircularMB=64 /Providers=a7044dd6-c8ef-4980-858c-942d972b6250'
2424

2525
resources:
2626
repositories:

eng/ci/templates/official/jobs/run-coldstart.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,31 @@ jobs:
4242
AzureWebJobsScriptRoot: '$(functionAppOutputPath)'
4343
perfViewPath: C:\.tools\perfview\perfview.exe
4444
traceDirectory: $(Build.ArtifactStagingDirectory)/out
45-
traceFileName: PerfViewData_$(Build.BuildNumber)_${{ parameters.functionAppName }}.etl
45+
traceFileNameWithoutExtension: PerfViewData_$(Build.BuildNumber)_${{ parameters.functionAppName }}
46+
traceFileName: $(traceFileNameWithoutExtension).etl
47+
traceFileZipName: $(traceFileName).zip
4648
traceFilePath: $(traceDirectory)/$(traceFileName)
49+
traceZipFilePath: $(traceDirectory)/$(traceFileZipName)
50+
traceAnalysisResultsDirectory: $(traceDirectory)/results
51+
traceAnalysisResultMarkdownFilePath: $(traceAnalysisResultsDirectory)/$(traceFileNameWithoutExtension).md
4752
traceLogPath: $(logsDirectory)/logs.log
53+
${{ if eq(parameters.os, 'Linux') }}:
54+
publishRid: linux-x64
55+
${{ if eq(parameters.os, 'Windows') }}:
56+
publishRid: win-x64
4857

4958
${{ if and(eq(parameters.collectPerfViewProfileOnWindows, true), eq(parameters.instanceId, '1')) }}: # profile collection is only on the first instance
5059
templateContext:
51-
outputParentDirectory: $(System.DefaultWorkingDirectory)/out
60+
outputParentDirectory: $(traceDirectory)
5261
outputs:
5362
- output: pipelineArtifact
5463
displayName: Publish PerfView profile
55-
path: $(traceFilePath).zip
64+
path: $(traceZipFilePath)
5665
artifact: PerfViewData_${{ parameters.functionAppName }}
66+
- output: pipelineArtifact
67+
displayName: Publish ColdStart Analysis Result
68+
path: $(traceAnalysisResultsDirectory)
69+
artifact: ColdStartProfileAnalysisResult_${{ parameters.functionAppName }}
5770

5871
steps:
5972
- template: /eng/ci/templates/install-dotnet.yml@self
@@ -74,7 +87,7 @@ jobs:
7487
zipAfterPublish: false
7588
modifyOutputPath: false
7689
projects: '$(Build.ArtifactStagingDirectory)/PerformanceTestApps/${{ parameters.functionAppName }}/HelloHttp.csproj'
77-
arguments: -c Release -o $(functionAppOutputPath) -f net9.0
90+
arguments: -c Release -o $(functionAppOutputPath) -f net9.0 -r $(publishRid)
7891
workingDirectory: $(Build.ArtifactStagingDirectory)/PerformanceTestApps/${{ parameters.functionAppName }}
7992

8093
- task: DotNetCoreCLI@2
@@ -85,7 +98,7 @@ jobs:
8598
zipAfterPublish: false
8699
modifyOutputPath: false
87100
projects: '$(Build.SourcesDirectory)/src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj'
88-
arguments: -c Release -o $(hostOutputPath) -f net8.0 -p:PlaceholderSimulation=true
101+
arguments: -c Release -o $(hostOutputPath) -r $(publishRid) -f net8.0 -p:PlaceholderSimulation=true
89102
workingDirectory: $(Build.SourcesDirectory)/src/WebJobs.Script.WebHost
90103

91104
- pwsh: |
@@ -169,7 +182,7 @@ jobs:
169182
while ($attempt -lt $maxAttempts) {
170183
$files = Get-ChildItem -Path $(traceDirectory)
171184
$fileCount = $files.Count
172-
if ($fileCount -eq 1 -and $files[0].Name -eq '$(traceFileName).zip') {
185+
if ($fileCount -eq 1 -and $files[0].Name -eq '$(traceFileZipName)') {
173186
break
174187
} else {
175188
Write-Host "Expected zip file not found. Rechecking again in 15 seconds..."
@@ -188,6 +201,18 @@ jobs:
188201
Get-Content $(traceLogPath)
189202
displayName: Stop PerfView
190203
204+
- pwsh: |
205+
# Install the profile analyzer tool and run it on the trace file.
206+
dotnet tool install -g Microsoft.Azure.Functions.ColdStartProfileAnalyzer --prerelease
207+
func-cold-start-analyzer --file $(traceZipFilePath) --format markdown text
208+
209+
# Upload analysis result
210+
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=$env:OS $env:FUNCTION_APP_NAME;]$(traceAnalysisResultMarkdownFilePath)"
211+
displayName: Analyze profile
212+
env:
213+
FUNCTION_APP_NAME: ${{ parameters.functionAppName }}
214+
OS: ${{ parameters.os }}
215+
191216
- ${{ if eq(parameters.os, 'Windows') }}:
192217
- pwsh: |
193218
$processIdFile = "$(Build.ArtifactStagingDirectory)/hostProcessId.txt"

0 commit comments

Comments
 (0)