Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions eng/pipelines/coreclr/templates/build-cache-stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
parameters:
archType: 'x64'
osGroup: 'linux'
buildConfig: ''
runtimeFlavor: ''
runtimeVariant: ''
helixQueues: ''
targetRid: ''
nameSuffix: ''
platform: ''
shouldContinueOnError: false
osSubgroup: ''

steps:
# Roslyn compiler cache
- ${{ if or(eq(parameters.osGroup, 'windows'), and(or(eq(parameters.osGroup, 'linux'), eq(parameters.osGroup, 'freebsd'), eq(parameters.osGroup, 'openbsd'), eq(parameters.osGroup, 'osx')), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'arm64')))) }}:
- ${{ if ne(parameters.osGroup, 'windows') }}:
- script: |
set -euo pipefail

dotnet="$(Build.SourcesDirectory)/.dotnet/dotnet"
if [[ -z "${ROSLYN_CACHE_PATH:-}" ||
-z "${ROSLYN_CACHE_BUILD_START:-}" ||
! -x "$dotnet" ]]; then
echo "Roslyn compiler cache statistics are unavailable."
exit 0
fi

sdkVersion="$("$dotnet" --version)"
compilerServer="$(Build.SourcesDirectory)/.dotnet/sdk/$sdkVersion/Roslyn/bincore/VBCSCompiler.dll"
if [[ ! -f "$compilerServer" ]]; then
echo "Roslyn compiler server not found at $compilerServer."
exit 0
fi

"$dotnet" "$compilerServer" \
"-cachestats:${ROSLYN_CACHE_BUILD_START}" \
"-cachepath:${ROSLYN_CACHE_PATH}" || true
displayName: Roslyn compiler cache stats
condition: always()

- ${{ if eq(parameters.osGroup, 'windows') }}:
- pwsh: |
$dotnet = Join-Path "$(Build.SourcesDirectory)" ".dotnet\dotnet.exe"
if ([string]::IsNullOrEmpty($env:ROSLYN_CACHE_PATH) -or
[string]::IsNullOrEmpty($env:ROSLYN_CACHE_BUILD_START) -or
-not (Test-Path -PathType Leaf $dotnet)) {
Write-Host "Roslyn compiler cache statistics are unavailable."
exit 0
}

$sdkVersion = (& $dotnet --version).Trim()
$compilerServer = Join-Path "$(Build.SourcesDirectory)" ".dotnet\sdk\$sdkVersion\Roslyn\bincore\VBCSCompiler.dll"
if (-not (Test-Path -PathType Leaf $compilerServer)) {
Write-Host "Roslyn compiler server not found at $compilerServer."
exit 0
}

& $dotnet $compilerServer `
"-cachestats:$env:ROSLYN_CACHE_BUILD_START" `
"-cachepath:$env:ROSLYN_CACHE_PATH"

if ($LASTEXITCODE -ne 0) {
Write-Warning "Roslyn compiler cache statistics exited with code $LASTEXITCODE."
}

exit 0
displayName: Roslyn compiler cache stats
condition: always()

# sccache native compiler cache
- ${{ if and(or(eq(parameters.osGroup, 'linux'), eq(parameters.osGroup, 'freebsd'), eq(parameters.osGroup, 'openbsd'), eq(parameters.osGroup, 'osx')), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'arm64'))) }}:
- script: sccache --show-stats || true
displayName: Sccache stats
condition: always()
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
buildArgs: -s clr+libs -c $(_BuildConfig)
timeoutInMinutes: 360
preBuildSteps:
- template: /eng/pipelines/coreclr/templates/setup-sccache.yml
- template: /eng/pipelines/coreclr/templates/setup-build-caches.yml
postBuildSteps:
- template: /eng/pipelines/coreclr/templates/sccache-stats.yml
- template: /eng/pipelines/coreclr/templates/build-cache-stats.yml
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
Expand Down Expand Up @@ -56,9 +56,9 @@ jobs:
buildArgs: -s clr.aot+libs.native+libs.sfx -c $(_BuildConfig)
timeoutInMinutes: 360
preBuildSteps:
- template: /eng/pipelines/coreclr/templates/setup-sccache.yml
- template: /eng/pipelines/coreclr/templates/setup-build-caches.yml
postBuildSteps:
- template: /eng/pipelines/coreclr/templates/sccache-stats.yml
- template: /eng/pipelines/coreclr/templates/build-cache-stats.yml
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
Expand Down
24 changes: 0 additions & 24 deletions eng/pipelines/coreclr/templates/roslyn-cache-stats.yml

This file was deleted.

20 changes: 0 additions & 20 deletions eng/pipelines/coreclr/templates/sccache-stats.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,44 @@ parameters:
sccacheVersion: '0.15.0'

steps:
- ${{ if and(or(eq(parameters.osGroup, 'linux'), eq(parameters.osGroup, 'freebsd'), eq(parameters.osGroup, 'openbsd'), eq(parameters.osGroup, 'osx')), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'arm64'))) }}:
- template: /eng/pipelines/coreclr/templates/setup-roslyn-cache.yml
parameters:
osGroup: ${{ parameters.osGroup }}
osSubgroup: ${{ parameters.osSubgroup }}
archType: ${{ parameters.archType }}
nameSuffix: ${{ parameters.nameSuffix }}
# Roslyn compiler cache
- ${{ if or(eq(parameters.osGroup, 'windows'), and(or(eq(parameters.osGroup, 'linux'), eq(parameters.osGroup, 'freebsd'), eq(parameters.osGroup, 'openbsd'), eq(parameters.osGroup, 'osx')), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'arm64')))) }}:
# Cache entries restored by pull request builds come only from the pull
# request itself or its target branch. This lets rolling builds seed the
# cache without allowing pull requests to modify caches used by main.
#
# Keep Debug and Release entries separate so rolling builds can seed both
# configurations without competing for the same immutable cache key.
# Roslyn's own deterministic key accounts for legs that override the
# matrix configuration in their build arguments.
- task: Cache@2
displayName: Roslyn compiler cache
continueOnError: true
inputs:
key: roslyn | v2 | ${{ parameters.osGroup }}${{ parameters.osSubgroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }} | "$(buildConfigUpper)" | "$(Build.BuildId)"
path: $(Pipeline.Workspace)/.roslyn-cache
restoreKeys: |
roslyn | v2 | ${{ parameters.osGroup }}${{ parameters.osSubgroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }} | "$(buildConfigUpper)"
roslyn | v1 | ${{ parameters.osGroup }}${{ parameters.osSubgroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }}

- ${{ if ne(parameters.osGroup, 'windows') }}:
- script: |
set -euo pipefail
echo "##vso[task.setvariable variable=ROSLYN_CACHE_PATH]$(Pipeline.Workspace)/.roslyn-cache"
echo "##vso[task.setvariable variable=ROSLYN_CACHE_BUILD_START]$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
displayName: Configure Roslyn compiler cache

- ${{ if eq(parameters.osGroup, 'windows') }}:
- pwsh: |
$cachePath = Join-Path "$(Pipeline.Workspace)" ".roslyn-cache"
$buildStart = [DateTime]::UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")

Write-Host "##vso[task.setvariable variable=ROSLYN_CACHE_PATH]$cachePath"
Write-Host "##vso[task.setvariable variable=ROSLYN_CACHE_BUILD_START]$buildStart"
displayName: Configure Roslyn compiler cache

# sccache native compiler cache
- ${{ if and(or(eq(parameters.osGroup, 'linux'), eq(parameters.osGroup, 'freebsd'), eq(parameters.osGroup, 'openbsd'), eq(parameters.osGroup, 'osx')), or(eq(parameters.archType, 'x64'), eq(parameters.archType, 'arm64'))) }}:
# Set up the Azure Pipeline Cache for sccache's local cache directory.
# Use a rolling key so each build can update the cache; restoreKeys
# falls back to the most recent saved entry.
Expand All @@ -32,7 +62,7 @@ steps:
# the *managed* Configuration (Debug for PRs, Release for rolling
# builds), but sccache only caches native (C/C++) compilations whose
# flags are controlled by RuntimeConfiguration (-rc), which is
# constant per leg regardless of buildConfig. Omitting it lets PR
# constant per leg regardless of buildConfig. Omitting it lets PR
# builds warm-start from rolling-build caches saved in the main scope.
#
# osGroup/osSubgroup/archType keep each platform's cache isolated so
Expand Down
30 changes: 0 additions & 30 deletions eng/pipelines/coreclr/templates/setup-roslyn-cache.yml

This file was deleted.

4 changes: 2 additions & 2 deletions eng/pipelines/global-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ extends:
buildArgs: -subset clr.native+libs.native+host.native -c $(_BuildConfig)
timeoutInMinutes: 120
preBuildSteps:
- template: /eng/pipelines/coreclr/templates/setup-sccache.yml
- template: /eng/pipelines/coreclr/templates/setup-build-caches.yml
postBuildSteps:
- template: /eng/pipelines/coreclr/templates/sccache-stats.yml
- template: /eng/pipelines/coreclr/templates/build-cache-stats.yml
condition:
or(
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
Expand Down
Loading
Loading