chore: initial sanitized public snapshot
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
param(
|
||||
[string]$OutputPath,
|
||||
[double]$SampleSize = 10,
|
||||
[double]$MeasurementSeconds = 0.05,
|
||||
[double]$WarmupSeconds = 0.05,
|
||||
[int]$TransferBytes = 8388608,
|
||||
[switch]$SkipBenchExecution
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$OutputPath = if ([string]::IsNullOrWhiteSpace($OutputPath)) {
|
||||
Join-Path $repoRoot "docs\perf\local-comparison.md"
|
||||
} else {
|
||||
$OutputPath
|
||||
}
|
||||
$xtaskManifest = Join-Path $repoRoot "xtask\Cargo.toml"
|
||||
|
||||
$arguments = @(
|
||||
"cargo",
|
||||
"run",
|
||||
"--manifest-path",
|
||||
$xtaskManifest,
|
||||
"--",
|
||||
"perf",
|
||||
"collect-local-comparison",
|
||||
"--output-path",
|
||||
$OutputPath,
|
||||
"--sample-size",
|
||||
"$SampleSize",
|
||||
"--measurement-seconds",
|
||||
"$MeasurementSeconds",
|
||||
"--warmup-seconds",
|
||||
"$WarmupSeconds",
|
||||
"--transfer-bytes",
|
||||
"$TransferBytes"
|
||||
)
|
||||
|
||||
if ($SkipBenchExecution) {
|
||||
$arguments += "--skip-bench-execution"
|
||||
}
|
||||
|
||||
rtk @arguments
|
||||
@@ -0,0 +1,83 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet("samply", "flamegraph")]
|
||||
[string]$Profiler = "samply",
|
||||
[int]$ProfileSeconds = 4,
|
||||
[string]$Scenario = "shared_runtime_live_http_transfer/tight_cap_6way",
|
||||
[string]$OutputDir
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$OutputDir = if ([string]::IsNullOrWhiteSpace($OutputDir)) {
|
||||
Join-Path $repoRoot "artifacts\shared-runtime-http-pressure-profile"
|
||||
} else {
|
||||
$OutputDir
|
||||
}
|
||||
$manifestPath = Join-Path $repoRoot "Cargo.toml"
|
||||
$null = New-Item -ItemType Directory -Path $OutputDir -Force
|
||||
$artifactStem = ($Scenario -replace "[^A-Za-z0-9._-]", "-").Trim("-")
|
||||
if ([string]::IsNullOrWhiteSpace($artifactStem)) {
|
||||
throw "Scenario must produce a non-empty artifact stem."
|
||||
}
|
||||
|
||||
$cargoArgs = @(
|
||||
"bench",
|
||||
"-p",
|
||||
"aria2-rust-pro-tests",
|
||||
"--bench",
|
||||
"rpc_pressure",
|
||||
$Scenario,
|
||||
"--manifest-path",
|
||||
$manifestPath,
|
||||
"--",
|
||||
"--profile-time",
|
||||
$ProfileSeconds.ToString()
|
||||
)
|
||||
|
||||
$metaPath = Join-Path $OutputDir "meta.txt"
|
||||
@(
|
||||
"timestamp=$([DateTimeOffset]::Now.ToString('O'))"
|
||||
"profiler=$Profiler"
|
||||
"profile_seconds=$ProfileSeconds"
|
||||
"scenario=$Scenario"
|
||||
) | Set-Content -LiteralPath $metaPath -Encoding UTF8
|
||||
|
||||
Push-Location $repoRoot
|
||||
try {
|
||||
switch ($Profiler) {
|
||||
"samply" {
|
||||
$outputPath = Join-Path $OutputDir "$artifactStem-profile.json.gz"
|
||||
& samply record `
|
||||
--save-only `
|
||||
--no-open `
|
||||
--output $outputPath `
|
||||
--profile-name "shared-runtime-http-pressure" `
|
||||
cargo @cargoArgs
|
||||
}
|
||||
"flamegraph" {
|
||||
$outputPath = Join-Path $OutputDir "$artifactStem-flamegraph.svg"
|
||||
& cargo flamegraph `
|
||||
"-p" "aria2-rust-pro-tests" `
|
||||
"--bench" "rpc_pressure" `
|
||||
"--manifest-path" $manifestPath `
|
||||
"--output" $outputPath `
|
||||
"--" `
|
||||
$Scenario `
|
||||
"--profile-time" `
|
||||
$ProfileSeconds
|
||||
}
|
||||
default {
|
||||
throw "Unsupported profiler: $Profiler"
|
||||
}
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Profiler command failed with exit code $LASTEXITCODE."
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet("samply", "flamegraph")]
|
||||
[string]$Profiler = "flamegraph",
|
||||
[int]$ProfileSeconds = 4,
|
||||
[string]$Scenario = "shared_runtime_live_http_transfer/tight_cap_6way",
|
||||
[string]$OutputDir
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$OutputDir = if ([string]::IsNullOrWhiteSpace($OutputDir)) {
|
||||
Join-Path $repoRoot "artifacts\shared-runtime-http-pressure-profile"
|
||||
} else {
|
||||
$OutputDir
|
||||
}
|
||||
$profileScript = Join-Path $repoRoot "scripts\perf\profile_shared_runtime_http_pressure.ps1"
|
||||
|
||||
$msudoArgs = @(
|
||||
"--same-console",
|
||||
"--wait",
|
||||
"--user",
|
||||
"admin",
|
||||
"--current-directory",
|
||||
$repoRoot,
|
||||
"--",
|
||||
"pwsh",
|
||||
"-NoLogo",
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
$profileScript,
|
||||
"-Profiler",
|
||||
$Profiler,
|
||||
"-ProfileSeconds",
|
||||
$ProfileSeconds.ToString(),
|
||||
"-Scenario",
|
||||
$Scenario,
|
||||
"-OutputDir",
|
||||
$OutputDir
|
||||
)
|
||||
|
||||
& msudo @msudoArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Elevated profiler command failed with exit code $LASTEXITCODE."
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Command,
|
||||
[string]$OutputDir,
|
||||
[switch]$AllowNonZeroExit
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$OutputDir = if ([string]::IsNullOrWhiteSpace($OutputDir)) {
|
||||
Join-Path $repoRoot "artifacts\admin-command"
|
||||
} else {
|
||||
$OutputDir
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path $OutputDir -Force
|
||||
|
||||
$stdoutPath = Join-Path $OutputDir "stdout.txt"
|
||||
$stderrPath = Join-Path $OutputDir "stderr.txt"
|
||||
$metaPath = Join-Path $OutputDir "meta.txt"
|
||||
$exitCodePath = Join-Path $OutputDir "exit-code.txt"
|
||||
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = [Security.Principal.WindowsPrincipal]::new($identity)
|
||||
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
|
||||
@(
|
||||
"timestamp=$([DateTimeOffset]::Now.ToString('O'))"
|
||||
"is_admin=$isAdmin"
|
||||
) | Set-Content -LiteralPath $metaPath -Encoding UTF8
|
||||
|
||||
$psi = [System.Diagnostics.ProcessStartInfo]::new()
|
||||
$psi.FileName = "cmd.exe"
|
||||
$psi.Arguments = "/d /c $Command"
|
||||
$psi.WorkingDirectory = (Get-Location).Path
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
|
||||
$process = [System.Diagnostics.Process]::Start($psi)
|
||||
if ($null -eq $process) {
|
||||
throw "Failed to start command."
|
||||
}
|
||||
|
||||
$stdout = $process.StandardOutput.ReadToEnd()
|
||||
$stderr = $process.StandardError.ReadToEnd()
|
||||
$process.WaitForExit()
|
||||
|
||||
Set-Content -LiteralPath $stdoutPath -Value $stdout -Encoding UTF8
|
||||
Set-Content -LiteralPath $stderrPath -Value $stderr -Encoding UTF8
|
||||
Set-Content -LiteralPath $exitCodePath -Value "$($process.ExitCode)" -Encoding UTF8
|
||||
|
||||
if (-not $AllowNonZeroExit -and $process.ExitCode -ne 0) {
|
||||
throw "Command failed with exit code $($process.ExitCode)."
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$OutputDir,
|
||||
[string]$Command = "whoami /all",
|
||||
[switch]$AllowNonZeroExit
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$OutputDir = if ([string]::IsNullOrWhiteSpace($OutputDir)) {
|
||||
Join-Path $repoRoot "artifacts\admin-probe"
|
||||
} else {
|
||||
$OutputDir
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path $OutputDir -Force
|
||||
|
||||
$stdoutPath = Join-Path $OutputDir "stdout.txt"
|
||||
$stderrPath = Join-Path $OutputDir "stderr.txt"
|
||||
$metaPath = Join-Path $OutputDir "meta.txt"
|
||||
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = [Security.Principal.WindowsPrincipal]::new($identity)
|
||||
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
|
||||
@(
|
||||
"timestamp=$([DateTimeOffset]::Now.ToString('O'))"
|
||||
"is_admin=$isAdmin"
|
||||
) | Set-Content -LiteralPath $metaPath -Encoding UTF8
|
||||
|
||||
$psi = [System.Diagnostics.ProcessStartInfo]::new()
|
||||
$psi.FileName = "cmd.exe"
|
||||
$psi.Arguments = "/d /c $Command"
|
||||
$psi.WorkingDirectory = (Get-Location).Path
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
|
||||
$process = [System.Diagnostics.Process]::Start($psi)
|
||||
if ($null -eq $process) {
|
||||
throw "Failed to start probe command."
|
||||
}
|
||||
|
||||
$stdout = $process.StandardOutput.ReadToEnd()
|
||||
$stderr = $process.StandardError.ReadToEnd()
|
||||
$process.WaitForExit()
|
||||
|
||||
Set-Content -LiteralPath $stdoutPath -Value $stdout -Encoding UTF8
|
||||
Set-Content -LiteralPath $stderrPath -Value $stderr -Encoding UTF8
|
||||
|
||||
if (-not $AllowNonZeroExit -and $process.ExitCode -ne 0) {
|
||||
throw "Probe command failed with exit code $($process.ExitCode)."
|
||||
}
|
||||
Reference in New Issue
Block a user