Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PGO support for OpenSSL #3014

Merged
merged 10 commits into from
Aug 26, 2022
32 changes: 32 additions & 0 deletions .azure/azure-pipelines.periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ stages:
extraPrepareArgs: -DisableTest
extraBuildArgs: -DisableTest -DisableTools -PGO

- stage: build_winuser_openssl
displayName: Build Windows (OpenSSL)
dependsOn: []
variables:
runCodesignValidationInjection: false
jobs:
- template: ./templates/build-config-user.yml
parameters:
image: windows-latest
platform: windows
arch: x64
tls: openssl
config: Release
extraPrepareArgs: -DisableTest
extraBuildArgs: -DisableTest -DisableTools -PGO

#
# Performance Tests
#
Expand All @@ -56,9 +72,25 @@ stages:
extraArgs: -PGO
failOnRegression: 0

- stage: perf_winuser_openssl
displayName: Performance Testing Windows (OpenSSL)
dependsOn:
- build_winuser_openssl
jobs:
- template: ./templates/run-performance.yml
parameters:
pool: MsQuic-Win-Perf
platform: windows
localTls: openssl
remoteTls: openssl
arch: x64
extraArgs: -PGO
failOnRegression: 0

- stage: make_pull_request
displayName: Make Pull Request
dependsOn:
- perf_winuser_schannel
- perf_winuser_openssl
jobs:
- template: ./templates/make-pgo-pr.yml
61 changes: 5 additions & 56 deletions .azure/templates/make-pgo-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,20 @@ jobs:
value: true
- group: DeploymentKeys
steps:
- checkout: none

- task: PowerShell@2
displayName: Prepare Test Machine
inputs:
targetType: inline
pwsh: true
script: |
git clone --single-branch --branch main https://github.com/microsoft/msquic
git config --global credential.helper store
Set-Content -Path "$env:HOME\.git-credentials" -Value "https://$($env:MAPPED_DEPLOYMENT_KEY):[email protected]`n" -NoNewLine

# Set Git Config Info
Set-Location msquic
git config user.email "[email protected]"
git config user.name "QUIC Dev[bot]"
env:
MAPPED_DEPLOYMENT_KEY: $(GitHubDeploymentKey)
- checkout: self
path: msquic

- task: DownloadBuildArtifacts@0
displayName: Download Perf Artifacts
inputs:
artifactName: performance
downloadPath: msquic/artifacts/PerfDataResults

- task: PowerShell@2
displayName: Copy Files
inputs:
targetType: inline
pwsh: true
script: Copy-Item -Path msquic/artifacts/PerfDataResults/performance/windows/x64_Release_schannel/msquic.pgd msquic/src/bin/winuser/pgo_x64/msquic.schannel.pgd -Force
downloadPath: artifacts/PerfDataResults

- task: PowerShell@2
displayName: Create Branch, Commit, and Pull Request
inputs:
targetType: inline
pwsh: true
script: |
Set-Location msquic
$BranchName = "merge-pgo-$(get-date -format 'yyyy-MM-dd')"
git checkout -b $BranchName
git commit -am "Update PGO data"
git push --set-upstream origin $BranchName

$Headers = @{
'Accept' = 'application/vnd.github+json'
'Authorization' = "token $($env:MAPPED_DEPLOYMENT_KEY)"
}
$Uri = "https://api.github.com/repos/microsoft/msquic/pulls"
$Body = @{
'title' = '[Automated] Update PGO'
'head' = "$($BranchName)"
'base' = 'main'
'body' = 'Update the PGO database with the latest perf numbers'
'maintainer_can_modify' = $True
}
$Result = Invoke-RESTMethod -Uri $Uri -Headers $Headers -Body ($Body | ConvertTo-Json) -ContentType "application/json" -Method Post
Write-Host $Result
$Number = ($Result | Select-Object -Property 'number')

$Uri = "https://api.github.com/repos/microsoft/msquic/issues/$($Number.number)/labels"
$Body = @{
'labels' = 'Area: Automation','Area: Performance'
}
$Result = Invoke-RESTMethod -Uri $Uri -Headers $Headers -Body ($Body | ConvertTo-Json) -ContentType "application/json" -Method Post

filePath: scripts/make-pgo-pr.ps1
arguments: -BuildNumber '$(Build.BuildNumber)'
env:
MAPPED_DEPLOYMENT_KEY: $(GitHubDeploymentKey)
70 changes: 70 additions & 0 deletions scripts/make-pgo-pr.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<#

.SYNOPSIS
This script commits new PGD files and creates a PR to ingest into MsQuic.

.PARAMETER Config
Specifies the build configuration to use.

.PARAMETER Arch
Specifies what the CPU arch is
#>

param (
[Parameter(Mandatory = $false)]
[ValidateSet("Debug", "Release")]
[string]$Config = "Release",

[Parameter(Mandatory = $false)]
[ValidateSet("x86", "x64", "arm", "arm64")]
[string]$Arch = "x64",

[Parameter(Mandatory = $false)]
[string]$BuildNumber = "$(get-date -format 'yyyy-MM-dd')"
)

# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent
Write-Debug "Rootdir is $($RootDir)"

git config --global credential.helper store
Set-Content -Path "$env:HOME\.git-credentials" -Value "https://$($env:MAPPED_DEPLOYMENT_KEY):[email protected]`n" -NoNewLine

# Set Git Config Info.
git config user.email "[email protected]"
git config user.name "QUIC Dev[bot]"

# Make the branch.
$BranchName = "merge-pgo-$($BranchName)"
git fetch
git checkout -b $BranchName main

Copy-Item -Path artifacts/PerfDataResults/performance/windows/$($Arch)_$($Config)_schannel/msquic.pgd src/bin/winuser/pgo_$($Arch)/msquic.schannel.pgd -Force
Copy-Item -Path artifacts/PerfDataResults/performance/windows/$($Arch)_$($Config)_openssl/msquic.pgd src/bin/winuser/pgo_$($Arch)/msquic.openssl.pgd -Force

# Commit the new PGD files.
git commit -am "Update PGO data"
git push --set-upstream origin $BranchName

# Make the PR with GitHub REST API and add tags to it.
$Headers = @{
'Accept' = 'application/vnd.github+json'
'Authorization' = "token $($env:MAPPED_DEPLOYMENT_KEY)"
}
$Uri = "https://api.github.com/repos/microsoft/msquic/pulls"
$Body = @{
'title' = '[Automated] Update PGO'
'head' = "$($BranchName)"
'base' = 'main'
'body' = 'Update the PGO database with the latest perf numbers'
'maintainer_can_modify' = $True
}
$Result = Invoke-RESTMethod -Uri $Uri -Headers $Headers -Body ($Body | ConvertTo-Json) -ContentType "application/json" -Method Post
Write-Debug $Result
$Number = ($Result | Select-Object -Property 'number')

$Uri = "https://api.github.com/repos/microsoft/msquic/issues/$($Number.number)/labels"
$Body = @{
'labels' = 'Area: Automation','Area: Performance'
}
$Result = Invoke-RESTMethod -Uri $Uri -Headers $Headers -Body ($Body | ConvertTo-Json) -ContentType "application/json" -Method Post
6 changes: 5 additions & 1 deletion scripts/performance-helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ $ProgressPreference = 'SilentlyContinue'

function Set-ScriptVariables {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
param ($Local, $LocalTls, $LocalArch, $RemoteTls, $RemoteArch, $SharedEC, $XDP, $Config, $Publish, $Record, $LogProfile, $RemoteAddress, $Session, $Kernel, $FailOnRegression)
param ($Local, $LocalTls, $LocalArch, $RemoteTls, $RemoteArch, $SharedEC, $XDP, $Config, $Publish, $Record, $LogProfile, $RemoteAddress, $Session, $Kernel, $FailOnRegression, $PGO)
$script:Local = $Local
$script:LocalTls = $LocalTls
$script:LocalArch = $LocalArch
$script:RemoteTls = $RemoteTls
$script:RemoteArch = $RemoteArch
$script:SharedEC = $SharedEC
$script:XDP = $XDP
$script:PGO = $PGO
$script:Config = $Config
$script:Publish = $Publish
$script:Record = $Record
Expand Down Expand Up @@ -1564,6 +1565,9 @@ function Test-CanRunTest {
if ($script:XDP -and $Test.TestName.Contains("Tcp")) {
return $false
}
if ($script:PGO -and $Test.TestName.Contains("Tcp")) {
return $false
}
return $true
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/performance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ Set-ScriptVariables -Local $Local `
-RemoteAddress $RemoteAddress `
-Session $Session `
-Kernel $Kernel `
-FailOnRegression $FailOnRegression
-FailOnRegression $FailOnRegression `
-PGO $PGO

$RemotePlatform = Invoke-TestCommand -Session $Session -ScriptBlock {
if ($IsWindows) {
Expand Down