perf(ci): gate Win7 command registry A/B measurement

This commit is contained in:
luo jiyin
2026-09-28 01:01:31 +08:00
committed by GitHub
parent c75ce783df
commit ab5c4f57c0
2 changed files with 132 additions and 0 deletions
+16
View File
@@ -145,6 +145,22 @@ test("Windows compatibility jobs cache Rust compilation without wrapping C or C+
assert.ok(win7.includes("--timings"));
assert.ok(win7.includes("name: DBX-win7-cargo-timings"));
assert.ok(win7.includes("path: target/cargo-timings/"));
assert.ok(win7.includes("name: Measure dbx library command registry expansion"));
assert.ok(win7.includes("if: vars.WIN7_REGISTRY_AB == 'true'"));
assert.ok(win7.includes("--package dbx"));
assert.ok(win7.includes("--lib"));
assert.ok(win7.includes('$env:RUSTC_WRAPPER = ""'));
assert.ok(win7.includes('Measure-Registry "full" $fullCommandCount'));
assert.ok(win7.includes('Measure-Registry "half" $keptCommandCount'));
assert.ok(win7.includes('"-Zdump-mono-stats=$outputDir"'));
assert.ok(win7.includes('"-Zdump-mono-stats-format=json"'));
assert.ok(win7.includes("git restore --source=HEAD -- $sourcePath"));
assert.ok(win7.includes("name: DBX-win7-dbx-lib-command-registry-ab"));
assert.ok(win7.includes("if: always() && vars.WIN7_REGISTRY_AB == 'true'"));
assert.ok(win7.includes("path: ${{ runner.temp }}/dbx-lib-command-registry-ab/"));
assert.ok(win7.includes("retention-days: 3"));
assert.ok(win7.indexOf("name: Build DBX for Windows 7") < win7.indexOf("name: Measure dbx library command registry expansion"));
assert.ok(win7.indexOf("name: Measure dbx library command registry expansion") < win7.indexOf("name: Upload dbx library command registry A/B"));
assert.doesNotMatch(win7, /^\s+(?:CC|CXX):/m);
});
+116
View File
@@ -577,6 +577,122 @@ jobs:
if-no-files-found: error
retention-days: 7
- name: Measure dbx library command registry expansion
if: vars.WIN7_REGISTRY_AB == 'true'
shell: pwsh
run: |
$resultRoot = Join-Path $env:RUNNER_TEMP "dbx-lib-command-registry-ab"
$sourcePath = "src-tauri/src/lib.rs"
New-Item -ItemType Directory -Force -Path $resultRoot | Out-Null
$env:TAURI_CONFIG = Get-Content src-tauri/tauri.webview2-win7-fixed.conf.json -Raw
$results = @{}
function Measure-Registry([string] $name, [int] $commandCount) {
$outputDir = Join-Path $resultRoot $name
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
$timer = [System.Diagnostics.Stopwatch]::StartNew()
cargo rustc `
--locked `
--package dbx `
--release `
--lib `
--features custom-protocol `
--target x86_64-win7-windows-msvc `
-Z build-std=std,panic_abort `
-- `
"-Zdump-mono-stats=$outputDir" `
"-Zdump-mono-stats-format=json"
$exitCode = $LASTEXITCODE
$timer.Stop()
if ($exitCode -ne 0) {
throw "$name command registry compile failed with exit code $exitCode."
}
$monoFile = Get-ChildItem $outputDir -File -Filter "*.mono_items.json" |
Select-Object -First 1
if (!$monoFile) {
throw "$name command registry compile did not create mono statistics."
}
$monoItems = Get-Content $monoFile.FullName -Raw | ConvertFrom-Json
$results[$name] = @{
Commands = $commandCount
Definitions = $monoItems.Count
Seconds = [math]::Round($timer.Elapsed.TotalSeconds, 2)
TotalEstimate = ($monoItems | Measure-Object -Property total_estimate -Sum).Sum
}
}
$savedWrapper = $env:RUSTC_WRAPPER
try {
$env:RUSTC_WRAPPER = ""
$sourceLines = Get-Content $sourcePath
$insideHandler = $false
$fullCommandCount = 0
foreach ($line in $sourceLines) {
if ($line -match 'tauri::generate_handler!\[') {
$insideHandler = $true
continue
}
if ($insideHandler -and $line -match '^\s*\]\)\)') {
break
}
if ($insideHandler -and $line -match '^\s+commands::') {
$fullCommandCount++
}
}
Measure-Registry "full" $fullCommandCount
$insideHandler = $false
$handlerCommandCount = 0
$keptCommandCount = 0
$reducedLines = foreach ($line in $sourceLines) {
if ($line -match 'tauri::generate_handler!\[') {
$insideHandler = $true
$line
continue
}
if ($insideHandler -and $line -match '^\s*\]\)\)') {
$insideHandler = $false
$line
continue
}
if ($insideHandler -and $line -match '^\s+commands::') {
$handlerCommandCount++
if ($handlerCommandCount % 2 -eq 0) {
continue
}
$keptCommandCount++
}
$line
}
if ($handlerCommandCount -ne $fullCommandCount -or $keptCommandCount -eq $fullCommandCount) {
throw "Could not create the reduced command registry."
}
$reducedLines | Set-Content $sourcePath -Encoding utf8NoBOM
Measure-Registry "half" $keptCommandCount
} finally {
$env:RUSTC_WRAPPER = $savedWrapper
git restore --source=HEAD -- $sourcePath
}
@(
"### dbx library command registry A/B"
""
"| Registry | Commands | Definitions | Estimated cost | Seconds |"
"| --- | ---: | ---: | ---: | ---: |"
"| Full | $($results['full'].Commands) | $($results['full'].Definitions) | $($results['full'].TotalEstimate) | $($results['full'].Seconds) |"
"| Half | $($results['half'].Commands) | $($results['half'].Definitions) | $($results['half'].TotalEstimate) | $($results['half'].Seconds) |"
) | Add-Content $env:GITHUB_STEP_SUMMARY
- name: Upload dbx library command registry A/B
if: always() && vars.WIN7_REGISTRY_AB == 'true'
uses: actions/upload-artifact@v6
with:
name: DBX-win7-dbx-lib-command-registry-ab
path: ${{ runner.temp }}/dbx-lib-command-registry-ab/
if-no-files-found: error
retention-days: 3
duckdb-windows-driver:
needs: changes
if: needs.changes.outputs.duckdb_windows == 'true'