Skip to content

Fetch Host JIT trace files from functions-release at build time#11719

Closed
Francisco-Gamino wants to merge 2 commits intodevfrom
Francisco-Gamino/fetch-jittrace-from-functions-release
Closed

Fetch Host JIT trace files from functions-release at build time#11719
Francisco-Gamino wants to merge 2 commits intodevfrom
Francisco-Gamino/fetch-jittrace-from-functions-release

Conversation

@Francisco-Gamino
Copy link
Copy Markdown
Contributor

Issue describing the changes in this PR

The JIT trace files in PreJIT/ have been moved to functions-release (artifacts/Host/JitTrace/dev/).

Changes

  • Delete coldstart.jittrace and linux.coldstart.jittrace from src/WebJobs.Script.WebHost/PreJIT/
  • Add a step in run-coldstart.yml that downloads the latest files from functions-release via ADO REST API into PreJIT/ before dotnet publish
  • Extract repo path to jitTraceRepoPath variable in coldstart.yml
  • Add retry logic (MaximumRetryCount 3, RetryIntervalSec 5) and fail the pipeline on download failure

Testing

  • Nightly run (createJitTrace=false) completes successfully
  • Manual run with createJitTrace=true produces valid merged JIT trace artifacts

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

Copilot AI review requested due to automatic review settings April 16, 2026 21:31
@Francisco-Gamino Francisco-Gamino requested a review from a team as a code owner April 16, 2026 21:31
Copy link
Copy Markdown
Contributor

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 updates the coldstart pipeline to source the host’s out-of-proc JIT trace files from the functions-release repo at build time (instead of keeping them in this repo), ensuring PreJIT/ is populated before dotnet publish.

Changes:

  • Added jitTraceRepoPath as a shared pipeline variable for the functions-release JIT trace location.
  • Added a pipeline step to download coldstart.jittrace and linux.coldstart.jittrace via ADO REST API into src/WebJobs.Script.WebHost/PreJIT/ with retries and failure-on-error behavior.
  • Added an explicit .NET 10 install step in the coldstart job.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 4 comments.

File Description
eng/ci/templates/variables/coldstart.yml Introduces jitTraceRepoPath variable for the functions-release JIT trace location.
eng/ci/templates/official/jobs/run-coldstart.yml Downloads JIT trace artifacts into PreJIT/ before publishing; also adds an explicit .NET 10 install step.

Comment on lines +152 to +157
- task: UseDotNet@2
displayName: Install .NET 10
inputs:
packageType: sdk
version: 10.x

Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

This installs .NET 10 again after /eng/ci/templates/install-dotnet.yml, which already installs the SDK pinned by global.json via useGlobalJson: true. The extra UseDotNet@2 version: 10.x step is redundant and can change which dotnet ends up on PATH (potentially diverging from the pinned SDK). Consider removing this step unless there’s a concrete need for a second .NET 10 install.

Suggested change
- task: UseDotNet@2
displayName: Install .NET 10
inputs:
packageType: sdk
version: 10.x

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +109
$token = "$(System.AccessToken)"
$headers = @{
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$token"))
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

$(System.AccessToken) can be empty unless the job is configured to allow scripts to access the OAuth token. Consider failing fast when $token is null/empty with a clear error, and/or explicitly wiring the token into the step (e.g., via env:) so this doesn’t silently produce 401s depending on pipeline settings.

Copilot uses AI. Check for mistakes.
}

$jitTracePath = "$(jitTraceRepoPath)"
$baseUrl = "https://dev.azure.com/azfunc/internal/_apis/git/repositories/functions-release/items"
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The base URL is hardcoded to a specific org/project (dev.azure.com/azfunc/internal). If this pipeline is ever run in a different project or via forks, this will break. Prefer using built-in variables like $(System.CollectionUri) / $(System.TeamProject) and constructing the REST URL from those, keeping only the repository name/id as the hardcoded part if needed.

Suggested change
$baseUrl = "https://dev.azure.com/azfunc/internal/_apis/git/repositories/functions-release/items"
$collectionUri = "$(System.CollectionUri)".TrimEnd('/')
$teamProject = "$(System.TeamProject)"
$repositoryName = "functions-release"
$baseUrl = "$collectionUri/$teamProject/_apis/git/repositories/$repositoryName/items"

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +128

foreach ($file in $files) {
$url = "${baseUrl}?path=${jitTracePath}/${file}&download=true&api-version=7.1"
$dest = Join-Path $targetDir $file
Write-Host "Downloading $file from functions-release (${jitTracePath})..."
try {
Invoke-RestMethod -Uri $url -Headers $headers -OutFile $dest -MaximumRetryCount 3 -RetryIntervalSec 5 -ErrorAction Stop
$lineCount = (Get-Content $dest | Measure-Object -Line).Lines
Write-Host "Downloaded $file ($lineCount lines) to $dest"
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The download call has no explicit timeout, so a transient network stall can hang the job for a long time. Also, Get-Content reads the entire jittrace file to count lines, which can be very slow/memory-heavy. Consider adding a reasonable -TimeoutSec and logging/validating via file size (e.g., Get-Item) instead of reading the full content.

Suggested change
foreach ($file in $files) {
$url = "${baseUrl}?path=${jitTracePath}/${file}&download=true&api-version=7.1"
$dest = Join-Path $targetDir $file
Write-Host "Downloading $file from functions-release (${jitTracePath})..."
try {
Invoke-RestMethod -Uri $url -Headers $headers -OutFile $dest -MaximumRetryCount 3 -RetryIntervalSec 5 -ErrorAction Stop
$lineCount = (Get-Content $dest | Measure-Object -Line).Lines
Write-Host "Downloaded $file ($lineCount lines) to $dest"
$downloadTimeoutSec = 300
foreach ($file in $files) {
$url = "${baseUrl}?path=${jitTracePath}/${file}&download=true&api-version=7.1"
$dest = Join-Path $targetDir $file
Write-Host "Downloading $file from functions-release (${jitTracePath})..."
try {
Invoke-RestMethod -Uri $url -Headers $headers -OutFile $dest -MaximumRetryCount 3 -RetryIntervalSec 5 -TimeoutSec $downloadTimeoutSec -ErrorAction Stop
$downloadedFile = Get-Item -Path $dest -ErrorAction Stop
if ($downloadedFile.Length -le 0) {
throw "Downloaded file '$file' is empty."
}
Write-Host "Downloaded $file ($($downloadedFile.Length) bytes) to $dest"

Copilot uses AI. Check for mistakes.
# Download the latest out-of-proc JIT trace files from functions-release and place them
# in PreJIT/ so they are included in the host publish output. The files have been removed
# from the host repo; this step is the sole source of truth.
- pwsh: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Azure pipelines has first-class support for fetching artifacts from another pipeline. Any reason we are not using that here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The JIT trace files are committed files in the functions-release repository (dev), not pipeline artifacts. DownloadPipelineArtifact only works for artifacts published by pipeline runs.
To access these files, I will use a repository resource with a checkout of the other repo instead.

…ld time

The JIT trace files in src/WebJobs.Script.WebHost/PreJIT/ were stale
because the canonical source of truth moved to the functions-release
repo (artifacts/Host/JitTrace/dev/). This change:

- Deletes coldstart.jittrace and linux.coldstart.jittrace from PreJIT/
- Adds functions-release as an ADO repository resource in host.coldstart.yml
- Adds checkout + copy steps in run-coldstart.yml to place the latest
  JIT trace files in PreJIT/ before dotnet publish
- Extracts the repo path to jitTraceRepoPath variable in coldstart.yml
- No changes to the .csproj glob (PreJIT\*.jittrace) or merge-jittrace.yml
@Francisco-Gamino Francisco-Gamino force-pushed the Francisco-Gamino/fetch-jittrace-from-functions-release branch from 931a9b3 to 3c3e594 Compare April 16, 2026 23:09
@Francisco-Gamino
Copy link
Copy Markdown
Contributor Author

This PR has been replaced by #11722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants