Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions tools/RpsLoadProbe/apply-wiki-paste.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@ $ge = [char]0x2265
$rarr = [char]0x2192
$endash = [char]0x2013

function Fix-Utf8Mojibake([string]$text) {
if ([string]::IsNullOrEmpty($text)) { return $text }
try {
$bytes = [System.Text.Encoding]::GetEncoding(28591).GetBytes($text)
return [System.Text.Encoding]::UTF8.GetString($bytes)
}
catch {
return $text
}
function Test-Utf8Mojibake([string]$text) {
return $text -match ([string][char]0x00C2 + [char]0x00B7) -or
$text -match ([string][char]0x00C3 + [char]0x2014) -or
$text -match ([string][char]0x00C3 + [char]0x00B7) -or
$text -match ([string][char]0x00F0 + [char]0x0178 + [char]0x00A5 + [char]0x2021)
}

$raw = Fix-Utf8Mojibake ([System.IO.File]::ReadAllText((Resolve-Path $PasteFile), [System.Text.Encoding]::UTF8))
$raw = [System.IO.File]::ReadAllText((Resolve-Path $PasteFile), [System.Text.Encoding]::UTF8)
if (Test-Utf8Mojibake $raw) {
& "$PSScriptRoot/repair-wiki-mojibake.ps1" -WikiFile $PasteFile
$raw = [System.IO.File]::ReadAllText((Resolve-Path $PasteFile), [System.Text.Encoding]::UTF8)
}

function Get-Section([string]$name) {
$pattern = "(?s)---$name---\r?\n(.*?)(?=---|\z)"
if ($raw -notmatch $pattern) { throw "Missing section $name" }
return $Matches[1].TrimEnd()
$marker = "---$name---"
$start = $raw.IndexOf($marker)
if ($start -lt 0) { throw "Missing section $name" }
$start += $marker.Length
while ($start -lt $raw.Length -and ($raw[$start] -eq "`r" -or $raw[$start] -eq "`n")) { $start++ }
$next = [regex]::Match($raw.Substring($start), '\r?\n---[A-Z_]+---')
$end = if ($next.Success) { $start + $next.Index } else { $raw.Length }
return $raw.Substring($start, $end - $start).TrimEnd()
}

$winRev = Get-Section 'WIN_REVERSE'
Expand All @@ -43,7 +48,7 @@ $wiki = [System.IO.File]::ReadAllText((Resolve-Path $WikiFile), [System.Text.Enc

$runUrl = "https://github.com/justcoding121/titanium-web-proxy/actions/runs/$PrimaryRunId"
$productLine = "- Product refresh: ``compare-product`` @ ``$HeadSha`` $em [$PrimaryRunId]($runUrl). Heavier/saturation/tls:"
$wiki = [regex]::Replace($wiki, '- Product refresh:.*', $productLine, 1)
$wiki = [regex]::Replace($wiki, '- Product refresh:.*', [System.Text.RegularExpressions.MatchEvaluator]{ $productLine }, 1)

$winRevHeader = "Median of **3 repeats** on ``windows-latest`` (4 vCPU / 16 GiB). Bare reverse 5${mul}5 @ ``$HeadSha`` $em ``compare-product`` [$PrimaryRunId]($runUrl). Warmup 2s / measure 8s; concurrency 8, 16, 32, 64. Prefer TWP${div}peer ratios over absolute RPS. **RPS cells** include median RSS / CPU at the peak-RPS step as ``<br><sub>(MiB / CPU%)</sub>``. nginx terminate peers use ``keepalive 256`` + streaming buffers. Laptop High-perf / cool-paired numbers stay on the [local lab](Performance-Local-Lab)."

Expand All @@ -60,24 +65,32 @@ $linHdr = "## Linux $em Titanium vs nginx vs YARP"

$wiki = [regex]::Replace($wiki,
"(?s)($([regex]::Escape($winHdr))\r?\n\r?\n### Reverse\r?\n\r?\n).*?(?=\r?\n### MITM)",
"`${1}$winRevHeader`n`n$winRev`n",
[System.Text.RegularExpressions.MatchEvaluator]{
param($m) $m.Groups[1].Value + $winRevHeader + "`n`n" + $winRev + "`n"
},
1)

$wiki = [regex]::Replace($wiki,
'(?s)(### MITM \(TWP only\)\r?\n\r?\n).*?(?=\r?\n## Linux)',
"`${1}$mitmNote`n`n$winMitm`n",
[System.Text.RegularExpressions.MatchEvaluator]{
param($m) $m.Groups[1].Value + $mitmNote + "`n`n" + $winMitm + "`n"
},
1)

$wiki = [regex]::Replace($wiki,
"(?s)($([regex]::Escape($linHdr))\r?\n\r?\n### Reverse\r?\n\r?\n).*?(?=\r?\n### MITM)",
"`${1}$linRevHeader`n`n$linRev`n",
[System.Text.RegularExpressions.MatchEvaluator]{
param($m) $m.Groups[1].Value + $linRevHeader + "`n`n" + $linRev + "`n"
},
1)

$idx = $wiki.IndexOf($linHdr)
$tail = $wiki.Substring($idx)
$tail = [regex]::Replace($tail,
'(?s)(### MITM \(TWP only\)\r?\n\r?\n).*?(?=\r?\n## Heavier)',
"`${1}$mitmNote`n`n$linMitm`n",
[System.Text.RegularExpressions.MatchEvaluator]{
param($m) $m.Groups[1].Value + $mitmNote + "`n`n" + $linMitm + "`n"
},
1)
$wiki = $wiki.Substring(0, $idx) + $tail

Expand Down
22 changes: 22 additions & 0 deletions tools/RpsLoadProbe/fix-wiki-encoding.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Repair paste output or wiki/Performance.md, then optionally apply paste to the wiki.
param(
[string] $PasteFile = 'tools/RpsLoadProbe/results/wiki-paste-out2.txt',
[string] $WikiFile = 'wiki/Performance.md',
[switch] $ApplyPaste,
[string] $HeadSha = 'df172718',
[string] $PrimaryRunId = '33041445371'
)

$ErrorActionPreference = 'Stop'

if ($ApplyPaste) {
& "$PSScriptRoot/apply-wiki-paste.ps1" -PasteFile $PasteFile -WikiFile $WikiFile -HeadSha $HeadSha -PrimaryRunId $PrimaryRunId
& "$PSScriptRoot/repair-wiki-mojibake.ps1" -WikiFile $WikiFile
exit 0
}

if (Test-Path $PasteFile) {
& "$PSScriptRoot/repair-wiki-mojibake.ps1" -WikiFile $PasteFile
}

Write-Host "To regenerate paste with UTF-8: pwsh -NoProfile -Command `"& { `$o = & '$PSScriptRoot/paste-compare-product-wiki.ps1' -RunIds '33041445371,33055267086,33055272140'; [IO.File]::WriteAllLines('$PasteFile', @(`$o), (New-Object Text.UTF8Encoding `$false)) }`""
40 changes: 40 additions & 0 deletions tools/RpsLoadProbe/repair-wiki-mojibake.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Repair common UTF-8 mojibake sequences in wiki/Performance.md without touching valid Unicode.
param(
[string] $WikiFile = 'wiki/Performance.md'
)

$ErrorActionPreference = 'Stop'

$middleDot = [char]0x00B7
$middleDotM = [string][char]0x00C2 + [char]0x00B7
$times = [char]0x00D7
$timesM = [string][char]0x00C3 + [char]0x2014
$div = [char]0x00F7
$divM = [string][char]0x00C3 + [char]0x00B7
$medal = [char]::ConvertFromUtf32(0x1F947)
$medalM = [string][char]0x00F0 + [char]0x0178 + [char]0x00A5 + [char]0x2021

$wikiPath = Resolve-Path $WikiFile
$wiki = [System.IO.File]::ReadAllText($wikiPath, [System.Text.Encoding]::UTF8)

function Count-Mojibake([string]$text) {
return @{
Dot = ([regex]::Matches($text, [regex]::Escape($middleDotM))).Count
Times = ([regex]::Matches($text, [regex]::Escape($timesM))).Count
Div = ([regex]::Matches($text, [regex]::Escape($divM))).Count
Medal = ([regex]::Matches($text, [regex]::Escape($medalM))).Count
Bad = ([regex]::Matches($text, [char]0xFFFD)).Count
}
}

$before = Count-Mojibake $wiki
$wiki = $wiki.Replace($middleDotM, $middleDot)
$wiki = $wiki.Replace($timesM, $times)
$wiki = $wiki.Replace($divM, $div)
$wiki = $wiki.Replace($medalM, $medal)
$after = Count-Mojibake $wiki

$utf8 = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($wikiPath, $wiki, $utf8)
Write-Host ('Repaired {0}: dot {1}->{2} times {3}->{4} div {5}->{6} medal {7}->{8} bad {9}' -f `
$WikiFile, $before.Dot, $after.Dot, $before.Times, $after.Times, $before.Div, $after.Div, $before.Medal, $after.Medal, $after.Bad)
2 changes: 1 addition & 1 deletion wiki/Performance-Profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ The [architecture-sensitive](Performance-Local-Lab#architecture-sensitive) lapto
| H3→H1 latency bundle (skip drain / skip Flush / HEADERS+DATA coalesce) | Cool absolute win (`cool-h3h1-latency-bundle-20260823/`) + CI bridges [32652931261](https://github.com/justcoding121/titanium-web-proxy/actions/runs/32652931261) @ `3f948409` | Cool c=64 TWP ~25k (tip ~20–23k); laptop YARP ~30k → cool TY ~0.85×. Trace @ c=64: p50 gap not exclusive CPU. | **CI miss**: Win H3→H1 **0.92× → ~0.87×** (13,391 / 15,444). Lin H3→H1 still leads (~1.11×). Lossy Lin H3 improved ~0.76×→~**0.89×** (278/314) but still <1.00×. **Reverted** (`2bf18d75`). |
| H2→H1 Memory ~5–9× YARP at RPS parity | Saturation RSS sampler + bag lifetime analysis | `ConcurrentBag<Task>` PendingSynthetics/Finalizations retained completed Tasks (session closures) for client H2 conn life; full SessionEventArgs per stream on IsFastPath | **`Http2PendingWork`** remove-on-complete; H2→H1 warm `TryRentPooled` + `HeaderBuilder` wire (H3→H1 analogue). Remeasure Block B Memory. Do not shrink windows / single-conn. |
| H3→H1 Win ~0.993× residual after one-pass QPACK | Cool A/B + gen0 on post-status path | Per-response `MemoryStream` QPACK builder + Latin-1 string round-trip + `new byte[]` tiny body | ThreadStatic **`ResponseBlockBuilder` rent**; span `AddHeader`; BufferPool body when `Available` covers CL. Bridges CI @ `0ff3673c` / [32685354747](https://github.com/justcoding121/titanium-web-proxy/actions/runs/32685354747): Win **1.12×** (27,046 / 24,085); Linux **1.09×**. |
| H3→H3 Win CI ~0.85× YARP; MITM Full÷Reverse ≪0.80 on H2/H3/H1 arms ([32960766249](https://github.com/justcoding121/titanium-web-proxy/actions/runs/32960766249)) | Cool paired A/B (`h3h3-dig/`) + `compare-product` MITM arms | H3→H3: per-frame QUIC I/O. MITM Full: probe-only fast path coupled product code to RPS harness header name; H2 `!wouldInjectVia` bail; H3 Via gate blocked preencoded relay with default pseudonym | **Landed v1:** `MitmCompressedRelayHelper` (`HeaderRelayBaseline` append-only diff, max 4 unique headers); H2/H3 append literals on static HPACK/QPACK blocks + Via as wire literal; H1 terminate-lite gate. Probe name stays in RpsLoadProbe harness only. Win spot Full÷Reverse @ c=64: H2 plain **0.858×**, H2 TLS **0.990×**, H3→H1 TLS **1.091×**, H3→H3 **0.999×**. GHA `compare-product` ×3 on `mitm/relay-publish` pending for wiki tables |
| H3→H3 Win CI ~0.85× YARP; MITM Full÷Reverse ≪0.80 on H2/H3/H1 arms ([32960766249](https://github.com/justcoding121/titanium-web-proxy/actions/runs/32960766249)) | Cool paired A/B (`h3h3-dig/`) + `compare-product` MITM arms | H3→H3: per-frame QUIC I/O. MITM Full: probe-only fast path coupled product code to RPS harness header name; H2 `!wouldInjectVia` bail; H3 Via gate blocked preencoded relay with default pseudonym | **Landed v1** @ `df172718`: `MitmCompressedRelayHelper` append-only (max 4 unique headers); H2 zero-copy append suffix; all MITM arms ≥ **0.70×** on GHA median ([33041445371](https://github.com/justcoding121/titanium-web-proxy/actions/runs/33041445371) ×3). **Landed v2:** `MitmStaticRebuildHelper` drop-only static rebuild (max 4 unique drops) + non-unique trailing append (second `Set-Cookie`); modify value / body still full re-encode. Three MITM tiers: **Lite** (unchanged relay), **Append/Strip-lite** (append or drop-only on static GET), **Full session** (modify/body/multi-edit). GHA remeasure pending on `mitm/relay-v2-publish`. |
| H3→H1 sticky ConcurrentBag TCP pool (bypass factory poolLock) | Cool tip-vs-sticky both orders @ c=32 (`cool-sticky-vs-tip-20260823/`) | Hypothesis: CI 4 vCPU multiplex tax on poolLock/queue | **Cool flat** (~1.07× both). Reverted. |
| H3→H1 Request/Response ConcurrentBag + QPACK ArrayPool EncodeResponse | Cool same-thermal tip-vs-pool @ c=32 (`cool-pool-qpack-20260823/`) | Hypothesis: HeaderCollection graph + QPACK `byte[]` gen0 under 32 wakeups | **Cool flat** (tip ~1.08×, pool ~1.06×). TWP absolute sometimes +high single digits; ratio not ≥+2%. Reverted. |
| H3→H1 FIN-drain overlap with origin TCP + message pool | Cool both orders (`cool-pool-overlap-20260823/`) | Hypothesis: hide Quic FIN read behind origin FillBuffer (do not skip drain) | **Cool miss** (order-noisy mean ≪ tip). Reverted. |
Expand Down
Loading
Loading