Skip to content

Commit

Permalink
Increase Receive Buffer Drain Ratio (#651)
Browse files Browse the repository at this point in the history
* Add Multi-Machine Tests to Perf Pipeline

Co-authored-by: Nick Banks <nibanks@microsoft.com>
  • Loading branch information
ThadHouse and nibanks committed Jul 28, 2020
1 parent e04cff5 commit d985d44
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 15 deletions.
32 changes: 32 additions & 0 deletions .azure/azure-pipelines.perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parameters:
- Normal
- PGO
- Record
- RecordQUICTrace

#
# Builds
Expand Down Expand Up @@ -69,22 +70,53 @@ stages:
platform: windows
localTls: schannel
remoteTls: schannel
${{ if eq(parameters.mode, 'PGO') }}:
extraArgs: -PGO
${{ if eq(parameters.mode, 'Record') }}:
extraArgs: -Record
${{ if eq(parameters.mode, 'RecordQUICTrace') }}:
extraArgs: -RecordQUIC
- template: ./templates/run-performance.yml
parameters:
pool: MsQuic-Win-Perf
platform: windows
localTls: schannel
remoteTls: schannel
arch: x86
${{ if eq(parameters.mode, 'PGO') }}:
extraArgs: -PGO
${{ if eq(parameters.mode, 'Record') }}:
extraArgs: -Record
${{ if eq(parameters.mode, 'RecordQUICTrace') }}:
extraArgs: -RecordQUIC
- template: ./templates/run-performance.yml
parameters:
pool: MsQuic-Win-Perf
platform: windows
localTls: schannel
remoteTls: schannel
extraName: Loopback
${{ if eq(parameters.mode, 'PGO') }}:
extraArgs: -PGO -Local
${{ if eq(parameters.mode, 'Record') }}:
extraArgs: -Record -Local
${{ if eq(parameters.mode, 'Normal') }}:
extraArgs: -Local
${{ if eq(parameters.mode, 'RecordQUICTrace') }}:
extraArgs: -RecordQUIC -Local
- template: ./templates/run-performance.yml
parameters:
pool: MsQuic-Win-Perf
platform: windows
localTls: schannel
remoteTls: schannel
extraName: Loopback
arch: x86
${{ if eq(parameters.mode, 'PGO') }}:
extraArgs: -PGO -Local
${{ if eq(parameters.mode, 'Record') }}:
extraArgs: -Record -Local
${{ if eq(parameters.mode, 'Normal') }}:
extraArgs: -Local
${{ if eq(parameters.mode, 'RecordQUICTrace') }}:
extraArgs: -RecordQUIC -Local
2 changes: 1 addition & 1 deletion .azure/templates/run-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- task: PowerShell@2
displayName: Run Performance Test
timeoutInMinutes: 12
timeoutInMinutes: 20
continueOnError: true
inputs:
pwsh: true
Expand Down
88 changes: 81 additions & 7 deletions scripts/performance-helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $WpaStackWalkProfileXml = `
<Profiles>
<SystemCollector Id="SC_HighVolume" Realtime="false">
<BufferSize Value="1024"/>
<Buffers Value="20"/>
<Buffers Value="80"/>
</SystemCollector>
<SystemProvider Id="SP_CPU">
<Keywords>
Expand All @@ -35,9 +35,55 @@ $WpaStackWalkProfileXml = `
</WindowsPerformanceRecorder>
"@

# WPA Profile for collecting QUIC Logs.
$WpaQUICLogProfileXml = `
@"
<?xml version="1.0" encoding="utf-8"?>
<WindowsPerformanceRecorder Version="1.0" Author="MsQuic" Copyright="Microsoft Corporation" Company="Microsoft Corporation">
<Profiles>
<SystemCollector Id="SC_HighVolume" Realtime="false">
<BufferSize Value="1024"/>
<Buffers Value="80"/>
</SystemCollector>
<EventCollector Id="EC_LowVolume" Realtime="false" Name="LowVolume">
<BufferSize Value="1024"/>
<Buffers Value="80"/>
</EventCollector>
<SystemProvider Id="SP_CPU">
<Keywords>
<Keyword Value="CpuConfig"/>
<Keyword Value="Loader"/>
<Keyword Value="ProcessThread"/>
<Keyword Value="SampledProfile"/>
</Keywords>
<Stacks>
<Stack Value="SampledProfile"/>
</Stacks>
</SystemProvider>
<EventProvider Id="MsQuicEtwPerf" Name="ff15e657-4f26-570e-88ab-0796b258d11c" NonPagedMemory="true" Level="5">
<Keywords>
<Keyword Value="0xE0000000"/>
</Keywords>
</EventProvider>
<Profile Id="CPU.Light.File" Name="CPU" Description="CPU Stacks" LoggingMode="File" DetailLevel="Light">
<Collectors>
<SystemCollectorId Value="SC_HighVolume">
<SystemProviderId Value="SP_CPU" />
</SystemCollectorId>
<EventCollectorId Value="EC_LowVolume">
<EventProviders>
<EventProviderId Value="MsQuicEtwPerf" />
</EventProviders>
</EventCollectorId>
</Collectors>
</Profile>
</Profiles>
</WindowsPerformanceRecorder>
"@

function Set-ScriptVariables {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
param ($Local, $LocalTls, $LocalArch, $RemoteTls, $RemoteArch, $Config, $Publish, $Record)
param ($Local, $LocalTls, $LocalArch, $RemoteTls, $RemoteArch, $Config, $Publish, $Record, $RecordQUIC)
$script:Local = $Local
$script:LocalTls = $LocalTls
$script:LocalArch = $LocalArch
Expand All @@ -46,6 +92,7 @@ function Set-ScriptVariables {
$script:Config = $Config
$script:Publish = $Publish
$script:Record = $Record
$script:RecordQUIC = $RecordQUIC
}

function Set-Session {
Expand Down Expand Up @@ -132,7 +179,7 @@ function Wait-ForRemoteReady {

function Wait-ForRemote {
param ($Job)
Wait-Job -Job $Job -Timeout 10 | Out-Null
Wait-Job -Job $Job -Timeout 60 | Out-Null
Stop-Job -Job $Job | Out-Null
$RetVal = Receive-Job -Job $Job
return $RetVal -join "`n"
Expand Down Expand Up @@ -307,17 +354,21 @@ function Invoke-RemoteExe {

Write-Debug "Running Remote: $Exe $RunArgs"

$WpaXml = $WpaStackWalkProfileXml
if ($RecordQUIC) {
$WpaXml = $WpaQUICLogProfileXml
}

return Invoke-TestCommand -Session $Session -ScriptBlock {
param ($Exe, $RunArgs, $BasePath, $Record, $WpaStackWalkProfileXml)
param ($Exe, $RunArgs, $BasePath, $Record, $WpaXml)
if ($null -ne $BasePath) {
$env:LD_LIBRARY_PATH = $BasePath
}

if ($Record -and $IsWindows) {
$EtwXmlName = $Exe + ".remote.wprp"
wpr.exe -cancel 2> $null

$WpaStackWalkProfileXml | Out-File $EtwXmlName
$WpaXml | Out-File $EtwXmlName
wpr.exe -start $EtwXmlName -filemode 2> $null
}

Expand All @@ -327,7 +378,7 @@ function Invoke-RemoteExe {
$EtwName = $Exe + ".remote.etl"
wpr.exe -stop $EtwName 2> $null
}
} -AsJob -ArgumentList $Exe, $RunArgs, $BasePath, $Record, $WpaStackWalkProfileXml
} -AsJob -ArgumentList $Exe, $RunArgs, $BasePath, $Record, $WpaXml
}

function Get-RemoteFile {
Expand All @@ -349,6 +400,29 @@ function Remove-RemoteFile {
}
}

function Start-Tracing {
param($Exe)
if ($Record -and $IsWindows -and !$Local) {
$EtwXmlName = $Exe + ".local.wprp"

$WpaXml = $WpaStackWalkProfileXml
if ($RecordQUIC) {
$WpaXml = $WpaQUICLogProfileXml
}

$WpaXml | Out-File $EtwXmlName
wpr.exe -start $EtwXmlName -filemode 2> $null
}
}

function Stop-Tracing {
param($Exe)
if ($Record -and $IsWindows -and !$Local) {
$EtwName = $Exe + ".local.etl"
wpr.exe -stop $EtwName 2> $null
}
}

function Invoke-LocalExe {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '')]
param ($Exe, $RunArgs, $Timeout)
Expand Down
44 changes: 38 additions & 6 deletions scripts/performance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ This script runs performance tests locally for a period of time.
.PARAMETER Publish
Publishes the results to the artifacts directory.
.PARAMETER Record
Records ETW traces
.PARAMETER RecordStack
Records ETW stack traces
.PARAMETER Timeout
Timeout in seconds for each individual client test invocation.
.PARAMETER RecordQUIC
Record QUIC specific trace events
#>

param (
Expand Down Expand Up @@ -87,12 +90,16 @@ param (
[switch]$Local = $false,

[Parameter(Mandatory = $false)]
[switch]$Record = $false,
[switch]$RecordStack = $false,

[Parameter(Mandatory = $false)]
[switch]$PGO = $false,

[int]$Timeout = 60
[Parameter(Mandatory = $false)]
[int]$Timeout = 60,

[Parameter(Mandatory = $false)]
[switch]$RecordQUIC = $false
)

Set-StrictMode -Version 'Latest'
Expand All @@ -101,6 +108,8 @@ $PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent

$Record = $RecordStack -or $RecordQUIC

# Remove any previous remote PowerShell sessions
Get-PSSession | Remove-PSSession

Expand Down Expand Up @@ -147,7 +156,8 @@ Set-ScriptVariables -Local $Local `
-RemoteArch $RemoteArch `
-Config $Config `
-Publish $Publish `
-Record $Record
-Record $Record `
-RecordQUIC $RecordQUIC

if ($Local) {
$RemoteAddress = "localhost"
Expand Down Expand Up @@ -296,6 +306,8 @@ function Invoke-Test {

$AllRunsResults = @()

Start-Tracing -Exe $LocalExe

try {
1..$Test.Iterations | ForEach-Object {
$LocalResults = Invoke-LocalExe -Exe $LocalExe -RunArgs $LocalArguments -Timeout $Timeout
Expand All @@ -314,8 +326,15 @@ function Invoke-Test {
Write-Debug $RemoteResults.ToString()
}

Stop-Tracing -Exe $LocalExe

if ($Record) {
Get-RemoteFile -From ($RemoteExe + ".remote.etl") -To (Join-Path $OutputDir ($Test.ToString() + ".etl"))
if ($Local) {
Get-RemoteFile -From ($RemoteExe + ".remote.etl") -To (Join-Path $OutputDir ($Test.ToString() + ".combined.etl"))
} else {
Get-RemoteFile -From ($RemoteExe + ".remote.etl") -To (Join-Path $OutputDir ($Test.ToString() + ".server.etl"))
Copy-Item -Path ($LocalExe + ".local.etl") -Destination (Join-Path $OutputDir ($Test.ToString() + ".client.etl"))
}
}

if ($PGO) {
Expand All @@ -333,6 +352,19 @@ function Invoke-Test {

$LocalDataCache = LocalSetup

if ($Record -and $IsWindows) {
try {
wpr.exe -cancel 2> $null
} catch {
}
Invoke-TestCommand -Session $Session -ScriptBlock {
try {
wpr.exe -cancel 2> $null
} catch {
}
}
}

try {
$Tests = Get-Tests $TestsFile

Expand Down
2 changes: 1 addition & 1 deletion src/core/quicdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ QUIC_STATIC_ASSERT(
// The flow control window is doubled when more than (1 / ratio) of the current
// window is delivered to the app within 1 RTT.
//
#define QUIC_RECV_BUFFER_DRAIN_RATIO 2
#define QUIC_RECV_BUFFER_DRAIN_RATIO 8

//
// The default value for send buffering being enabled or not.
Expand Down

0 comments on commit d985d44

Please sign in to comment.