From 8c49c9026f32075046e099c2f909142ce2b92dca Mon Sep 17 00:00:00 2001 From: monosans Date: Mon, 2 Feb 2026 16:55:00 +0300 Subject: [PATCH] fix(allocator-bench): include major and minor page fault metrics in results --- .github/scripts/allocator_bench_alpine.sh | 30 ++++++++++----- .github/scripts/allocator_bench_unix.sh | 42 +++++++++++++++++---- .github/scripts/allocator_bench_windows.ps1 | 14 ++++--- 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/.github/scripts/allocator_bench_alpine.sh b/.github/scripts/allocator_bench_alpine.sh index 4fa21d5..c283814 100644 --- a/.github/scripts/allocator_bench_alpine.sh +++ b/.github/scripts/allocator_bench_alpine.sh @@ -39,12 +39,20 @@ for allocator in system jemalloc mimalloc_v2 mimalloc_v3; do else output="$(/usr/bin/time -v /work/target/release/proxy-scraper-checker 2>&1 >/dev/null)" fi - peak="$(echo "$output" | awk -F': ' '/Maximum resident set size/ {print $2; exit}')" + peak="$(echo "$output" | awk -F': ' '/Maximum resident set size/ {print $2; exit}')" + major="$(echo "$output" | awk -F': ' '/Major \(requiring I\/O\) page faults/ {print $2; exit}')" + minor="$(echo "$output" | awk -F': ' '/Minor \(reclaiming a frame\) page faults/ {print $2; exit}')" if [ -z "$peak" ]; then echo "Failed to parse peak memory for $allocator" >&2 exit 1 fi - printf "%s\t%s\n" "$allocator" "$peak" >> /work/alpine-results.tsv + if [ -z "$major" ]; then + major=0 + fi + if [ -z "$minor" ]; then + minor=0 + fi + printf "%s\t%s\t%s\t%s\n" "$allocator" "$peak" "$major" "$minor" >> /work/alpine-results.tsv done EOF ) @@ -59,14 +67,18 @@ docker run --rm \ { echo "### ${PLATFORM_LABEL:-unknown} (tokio-multi-thread=${TOKIO_MULTI_THREAD:-false})" echo "" - echo "| Allocator | Peak KB |" - echo "| --- | ---: |" - sort -n -k2,2 alpine-results.tsv | while IFS=$'\t' read -r allocator peak; do - echo "| $allocator | $peak |" + echo "| Allocator | Peak KB | Major PF | Minor PF |" + echo "| --- | ---: | ---: | ---: |" + sort -n -k2,2 -k3,3 -k4,4 alpine-results.tsv | while IFS=$'\t' read -r allocator peak major minor; do + echo "| $allocator | $peak | $major | $minor |" done - best="$(sort -n -k2,2 alpine-results.tsv | head -n1)" + best="$(sort -n -k2,2 -k3,3 -k4,4 alpine-results.tsv | head -n1)" best_allocator="${best%%$'\t'*}" - best_peak="${best#*$'\t'}" + best_rest="${best#*$'\t'}" + best_peak="${best_rest%%$'\t'*}" + best_rest="${best_rest#*$'\t'}" + best_major="${best_rest%%$'\t'*}" + best_minor="${best_rest#*$'\t'}" echo "" - echo "**Best:** $best_allocator ($best_peak KB)" + echo "**Best:** $best_allocator ($best_peak KB, $best_major major PF, $best_minor minor PF)" } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/scripts/allocator_bench_unix.sh b/.github/scripts/allocator_bench_unix.sh index dc54ea8..f05cdaf 100644 --- a/.github/scripts/allocator_bench_unix.sh +++ b/.github/scripts/allocator_bench_unix.sh @@ -13,11 +13,23 @@ if [[ "$RUNNER_OS" == "Linux" ]]; then parse_peak() { awk -F': ' '/Maximum resident set size/ {print $2; exit}' } + parse_major() { + awk -F': ' '/Major \(requiring I\/O\) page faults/ {print $2; exit}' + } + parse_minor() { + awk -F': ' '/Minor \(reclaiming a frame\) page faults/ {print $2; exit}' + } else time_cmd=(/usr/bin/time -l) parse_peak() { awk '/maximum resident set size/ {print $1; exit}' } + parse_major() { + awk '/page faults/ {print $1; exit}' + } + parse_minor() { + awk '/page reclaims/ {print $1; exit}' + } fi build_features() { @@ -58,16 +70,26 @@ run_one() { local peak peak="$(echo "$output" | parse_peak)" + local major + major="$(echo "$output" | parse_major)" + local minor + minor="$(echo "$output" | parse_minor)" if [[ -z "$peak" ]]; then echo "Failed to parse peak memory for $allocator" >&2 exit 1 fi + if [[ -z "$major" ]]; then + major=0 + fi + if [[ -z "$minor" ]]; then + minor=0 + fi if [[ "$RUNNER_OS" != "Linux" ]]; then peak=$((peak / 1024)) fi - printf "%s\t%s\n" "$allocator" "$peak" >> results.tsv + printf "%s\t%s\t%s\t%s\n" "$allocator" "$peak" "$major" "$minor" >> results.tsv } if [[ "$RUNNER_OS" == "Windows" ]]; then @@ -82,14 +104,18 @@ done { echo "### ${PLATFORM_LABEL:-unknown} (tokio-multi-thread=${TOKIO_MULTI_THREAD:-false})" echo "" - echo "| Allocator | Peak KB |" - echo "| --- | ---: |" - sort -n -k2,2 results.tsv | while IFS=$'\t' read -r allocator peak; do - echo "| $allocator | $peak |" + echo "| Allocator | Peak KB | Major PF | Minor PF |" + echo "| --- | ---: | ---: | ---: |" + sort -n -k2,2 -k3,3 -k4,4 results.tsv | while IFS=$'\t' read -r allocator peak major minor; do + echo "| $allocator | $peak | $major | $minor |" done - best="$(sort -n -k2,2 results.tsv | head -n1)" + best="$(sort -n -k2,2 -k3,3 -k4,4 results.tsv | head -n1)" best_allocator="${best%%$'\t'*}" - best_peak="${best#*$'\t'}" + best_rest="${best#*$'\t'}" + best_peak="${best_rest%%$'\t'*}" + best_rest="${best_rest#*$'\t'}" + best_major="${best_rest%%$'\t'*}" + best_minor="${best_rest#*$'\t'}" echo "" - echo "**Best:** $best_allocator ($best_peak KB)" + echo "**Best:** $best_allocator ($best_peak KB, $best_major major PF, $best_minor minor PF)" } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/scripts/allocator_bench_windows.ps1 b/.github/scripts/allocator_bench_windows.ps1 index 36b3041..3c78885 100644 --- a/.github/scripts/allocator_bench_windows.ps1 +++ b/.github/scripts/allocator_bench_windows.ps1 @@ -37,7 +37,7 @@ function Run-One([string]$allocator, [string]$features) { } catch { } } $peakKb = [math]::Floor($peak / 1kb) - Add-Content -Path results.tsv -Value "$allocator`t$peakKb" + Add-Content -Path results.tsv -Value "$allocator`t$peakKb`t0`t0" } if (Test-Path results.tsv) { Remove-Item results.tsv -Force } @@ -51,19 +51,21 @@ $rows = Get-Content results.tsv | ForEach-Object { [pscustomobject]@{ Allocator = $parts[0] PeakKB = [int]$parts[1] + MajorPF = [int]$parts[2] + MinorPF = [int]$parts[3] } } -$sorted = $rows | Sort-Object PeakKB +$sorted = $rows | Sort-Object PeakKB, MajorPF, MinorPF $best = $sorted | Select-Object -First 1 $summary = @() $summary += "### $($env:PLATFORM_LABEL) (tokio-multi-thread=$tokioOn)" $summary += "" -$summary += "| Allocator | Peak KB |" -$summary += "| --- | ---: |" +$summary += "| Allocator | Peak KB | Major PF | Minor PF |" +$summary += "| --- | ---: | ---: | ---: |" foreach ($row in $sorted) { - $summary += "| $($row.Allocator) | $($row.PeakKB) |" + $summary += "| $($row.Allocator) | $($row.PeakKB) | $($row.MajorPF) | $($row.MinorPF) |" } $summary += "" -$summary += "**Best:** $($best.Allocator) ($($best.PeakKB) KB)" +$summary += "**Best:** $($best.Allocator) ($($best.PeakKB) KB, $($best.MajorPF) major PF, $($best.MinorPF) minor PF)" $summary -join "`n" | Add-Content $env:GITHUB_STEP_SUMMARY