Viterbi optimization comparison¶
Curated source-specific evidence, not a new run or qualification of current source. Dates, measurements, failure outcomes and original source identifiers retain their recorded meaning. Old tags/assets have been retired and original commits may no longer resolve after the privacy rewrite. Where identifiers were sanitized earlier, the original hardware/run association cannot be independently recovered from the public derivative. Current acceptance lives in the roadmap.
Recorded and operator-accepted 2026-10-11 at d61cf03 / documentation
ab4f5fa. Baseline code: b276cea518ddb9ab5f225653a9ce4f07432ba626;
tracking head: f02bf79107bc9fdeeffa605e54a94e8145c4c1fa. The later
CPU comparison uses this optimized baseline.
Decision and production scope¶
Recommendation: retain the narrowly scoped patch. Seven alternating warmed pairs show 20.41% ± 0.31 percentage points less complete native CPU, range 20.13–20.86%. Separately, actual browser memory64 workers show 12.37% ± 0.15 points less processing wall time, range 12.18–12.64%. No promotion claim is based on an isolated microbenchmark or CPU percentage. All promotion gates passed without material memory, block-spike, continuity or decoding regressions. These were agent qualification results; the operator subsequently accepted this completed patch and authorized the separate bounded follow-up.
Only HritReceiver::Impl::viterbi_decode changes: an immutable 128-byte encoder
table for the existing polynomials and four exact integer costs per soft pair.
All transitions/path metrics remain evaluated in their original order. Strict
<, unreachable handling, final-state selection, survivors, traceback, warmup,
hard disagreements, ASM/NRZ-M/randomization/RS, timing and bound evidence stay
unchanged. No trellis restructuring, SIMD/NEON, FIR, threads, queues, dependencies,
SDK, runtime policy or deployed legacy-browser changes. Phase 4 is unauthorized.
Frozen builds and environment¶
Baseline was archived before production edits, rebuilt separately, and reproduced
the installed decoder hash exactly. Signed candidate code commit:
d61cf03de9e0a528e0b606cfa40d81a8306281e3 (OpenPGP verification G).
Current receiver source hash:
e31d4ed29027ba075a76d3424efac1a3add524cff361b81edd3099aaceba0c57.
Measured candidate binary remained identical after adding test-only trace detail.
Pi 5 Cortex-A76/aarch64, four cores, 7.9 GiB RAM, Debian Trixie,
kernel 6.18.50+rpt-rpi-2712; g++ 14.2.0-19. Both native builds/harnesses use
-O2 -std=c++20 -Wall -Wextra -pthread, no fast-math/PGO/architecture tuning.
Only the benchmark process was pinned to CPU 3. Live baseline decoding continued.
No global CPU policy change. Isolated SDK remains 4.0.23, legacy 3.1.69.
| Artifact | SHA-256 |
|---|---|
| Frozen scalar receiver source | 8d6ed9e4694216724830dcdbba4f1a29d1b8a1a4715490649f329eef4b6a109d |
| Installed/rebuilt baseline native decoder | 6d7f03284c08ab6e547b51c5b48d7551c0775b675feff307e67129b01ceef886 |
| Candidate native decoder | 9541bc612f847031ec42d1ea55671335ca10aa43f7f1647a317663e77ea01ff1 |
| Baseline benchmark executable | 2e9f51940f0a5b8fb66a35c9826d50a0ea92079e4a6d582dd1a8e31b8f7c03c2 |
| Candidate benchmark executable | 9d4c861ceb9ce282a7909161d6e8b2623fd99fc4d780a8dae227d37cd0607b1f |
| Baseline memory64 receiver | 1952710d63027eba09f52244c2ced0b883727154202b65dd7c2882b3c7b4737e |
| Candidate memory64 receiver | e417e5acfaf22225e3da54151a4a650f6e1654a45a18009e227deab7e9c2c2d9 |
| Separate memory64 differential artifact | 6121662349f823d3c8d6b11bd9483641af1653b9f1de1167aec6d810f470523d |
Uninstrumented new-path WASM 32,265 → 32,353 bytes, i64 memory/pointer ABI
and exact hash/import/export allowlists inspected. These are qualification
artifacts, not a deployment to the legacy browser path. Native nm identifies
128 bytes of read-only encoder data, no audit/scalar-reference symbols. Survivors remain
8,224×64 bytes; costs use a 16-byte local array, not a new heap allocation.
Executed correctness evidence¶
Frozen scalar reference
retains independent parity/branch arithmetic and the original loop. It never
uses the candidate table/helper. Instrumentation exists only in separate native,
sanitized and receive-audit.wasm targets, not the production hot path.
- All 128 mappings, 65,536 soft pairs × four costs exhaustively agree.
- Every step's 64 metrics, reachable/unreachable transition, strict-improvement write/tie decision, written/untouched survivor, final state, pre-ASM/RS decoded bytes and hard disagreements agree.
- Nine saturated/neutral/alternating/noisy soft vectors explicitly fail ASM; clean/corrected/uncorrectable/offset IQ supplements include a real RS rejection. Rejected candidates are compared before RS can conceal Viterbi differences.
- Actual local ARM64 Chromium 154.0.8037.92 ran 113,383,822 differential checks, 105 candidates, 863,520 steps, 1,619,137 scalar ties, 262,272 arithmetic checks and 847 audit-worker checks (845 uninstrumented). Seccomp 2/NoNewPrivs 1; no CDP, experimental flags, sandbox bypass or wasm32.
- Independent IQ preserves 92 ordered frames / 17 corrected symbols, hash
70e147554060f5be9aa117737a6061fcc3f54f46accd58b3f9608862e8450677. Native/browser compare every ordered byte to unchanged legacy decoding. Every lane agrees with the frozen native oracle: nonzero corrections only at zero-based frames 10[1,0,0,1], 36[0,0,0,1], 55[4,4,2,4]. - Baseline/candidate native manifests match bytes, per-lane corrections, hard disagreements and completion cursors. Audited 65,536-/1,022-byte chunk and sanitizer manifests also match exactly; instance/reset/discontinuity/bounds, clean/corrected/failed/offset cases and ASan/UBSan/leak checks passed.
- Shared contract 4,083, browser glue 127 and tooling 11 checks passed. Gateway protected-queue regressions and mock HTTP/IPv4/TLS/IPv6/auth/concurrency/handoff integration passed. Hosted results are separately recorded below.
Independent source: Lucas Teske's GOES sample index,
GOES-16 2017-01-17 16:25:08 UTC / 5 MS/s. The unchanged cached 33,554,432-byte
prefix hash is b34eadddd172d8713be686d29b28541fe86fa3158bdf17f9b57a4ba48530a326.
No full download/new live recording. Raw/generated payloads stay ignored.
Native complete-pipeline measurement¶
Harness includes the
unchanged native service source and invokes its actual
Decoder::process/publish/snapshot; the service entrypoint is never invoked.
No SDR/socket/listener or acquisition authority. Both variants use identical
harnesses/settings, chunks and output treatment.
Existing fixture conversion: signed 16-bit IQ → CU8 high byte; 16,777,194 bytes / 8,388,597 complex samples / 1.6777194 source seconds. A test-only 5-MS/s fixture adapter exercises the existing channelizer without relaxing installed job validation or changing the live 2.4-MS/s configuration.
Timing includes copying/validation, residual/NCO/FIR channelization, full demod/sync/Viterbi/NRZ-M/RS, evidence/hash, canonical record encode/decode/zero/ disposal, counters and serialized snapshots (one per fixture's first source-time second). Offline replay does not exercise kernel IPC/network; live checks do. Load/conversion/construction/filter setup/compilation/warmup are excluded.
Warm twice, then seven alternating pairs, 12 replays per measured run: 1,104 frames, 1,116 verified/disposed records, 1,763,628 wire bytes, 12 snapshots, 100,663,164 source samples. All fixed diagnostic objects agree, including carrier/ timing/power/lane totals and 1,298 hard disagreements per replay. No output failures/drops. Means ± sample SD across seven runs:
Run UUIDs and actual decode-UTC times legitimately differ; agreement concerns stable diagnostics, ordered payload/evidence/cursors and record counts/lengths, not an artificially identical runtime envelope hash.
| Metric | Baseline | Candidate |
|---|---|---|
| CPU seconds / source second | 0.75639 ± 0.00209 | 0.60197 ± 0.00097 |
| CPU/source range | 0.75399–0.75922 | 0.60056–0.60343 |
| Processing speed / real time | 1.32205 ± 0.00358× | 1.66132 ± 0.00270× |
| Source throughput | 6.610 MS/s | 8.307 MS/s |
| User cycles / source sample | 362.211 ± 0.983 | 288.215 ± 0.431 |
| User instructions / source sample | 913.859 ± 0.001 | 691.536 ± 0.001 |
| Block p50 | 2.43945 ± 0.00309 ms | 2.43954 ± 0.00481 ms |
| Block p95 | 9.52586 ± 0.04732 ms | 6.69504 ± 0.01133 ms |
| Block p99 | 9.65569 ± 0.04618 ms | 6.83112 ± 0.03229 ms |
| Maximum block, per-run mean | 10.57496 ± 1.00462 ms | 7.22704 ± 0.33394 ms |
| Worst observed block | 12.65287 ms | 7.97754 ms |
| Peak RSS, range | 21,552–21,600 KiB | 21,552–21,584 KiB |
Native throughput improves 25.66%. The median stays essentially unchanged:
non-frame blocks still do identical DSP. Expensive frame blocks improve. Observed
gain is well beyond noise, with no material memory or spike regression.
Temperatures approximately 64–69 °C, clocks 2.400 GHz, throttled 0x0;
PMU time-enabled equals time-running, no multiplexing. PMU excludes kernel;
thread CPU includes system time. Context switches/faults/load/startup/sensors are
retained in build/viterbi-evidence/native-benchmark.json. RSS includes test input.
Allocation call counts were not instrumented; no new Viterbi heap allocation
is established by inspection. Offline IPC lag/queue is not manufactured as zero.
File loading took 60.19–82.14 ms per process, excluded from processing;
constructor setup summed 10.36–10.90 ms across 12 instances, also excluded.
Whole-process resource accounting reports 2,351–2,355 minor / zero major faults;
these include setup/input pages, not a measured steady-state allocation rate.
Involuntary context switches were 168–180 baseline / 134–139 candidate.
Competing live decoding remained roughly 0.75 cores in both recorded-input
series; load and thermal/clock readings were sampled before and after each run.
Paired results (native CPU/source-second; browser gain is independently measured worker wall time). All seven native and seven browser pairs improved:
| Pair / execution order | Native baseline | Native candidate | Native CPU reduction | Browser wall reduction |
|---|---|---|---|---|
| 1 · baseline → candidate | 0.75399 | 0.60217 | 20.14% | 12.48% |
| 2 · candidate → baseline | 0.75627 | 0.60202 | 20.40% | 12.64% |
| 3 · baseline → candidate | 0.75706 | 0.60343 | 20.29% | 12.39% |
| 4 · candidate → baseline | 0.75507 | 0.60228 | 20.23% | 12.38% |
| 5 · baseline → candidate | 0.75879 | 0.60056 | 20.85% | 12.27% |
| 6 · candidate → baseline | 0.75429 | 0.60243 | 20.13% | 12.27% |
| 7 · baseline → candidate | 0.75922 | 0.60088 | 20.86% | 12.18% |
No isolated Viterbi timing is used as the acceptance benchmark.
Actual browser memory64 results¶
Seven alternating warmed pairs, two replays/run, same local ARM64 Chromium,
data/chunks and hash/ABI-verified artifacts. Ordered bytes, all lane corrections,
32 exact metric selectors and zero bounded output drops checked every run.
Data/compilation/setup excluded. This measures channelizer+receive/FEC+bounded
JS/WASM copies/drain, not native records/IPC. performance.now() reports
worker wall time; per-worker CPU/PMU and browser-process peak RSS are unavailable.
| Metric | Baseline | Candidate |
|---|---|---|
| Wall seconds / source second | 1.03765 ± 0.00374 | 0.90925 ± 0.00196 |
| Processing speed / real time | 0.96373 ± 0.00346× | 1.09982 ± 0.00237× |
| Block p50, mean | 3.9893 ms | 3.9807 ms |
| Block p95, mean | 11.8821 ms | 9.5764 ms |
| Block p99, mean ± SD | 11.9607 ± 0.0431 ms | 9.6729 ± 0.0420 ms |
| Worst observed block | 22.370 ms | 9.970 ms |
| Linear memory, every run | 16 MiB | 16 MiB |
12.37% paired wall-time reduction, not a native-derived CPU estimate. This qualifies this Pi/browser/workload, not all browsers or multi-stream capacity. Actual >4-GiB addressing is separately pending Phase 12.
Before/after profiles and remaining hotspots¶
Payload-free 199-Hz user-cycle IP-only sampling, 30 replays each: baseline 7,596 samples, candidate 6,070, zero lost samples. No stack/register/ user-buffer capture. Sampling includes startup/load (<1% of these longer runs), unlike the processing stopwatch. Normalize each symbol's summed sample periods by 251,657,910 source samples. Self-cycle estimates, not substage timers:
| Hotspot | Before share | After share | Approx. cycles/source sample, before → after |
|---|---|---|---|
| Viterbi/survivors/traceback/hard check | 48.14% | 36.42% | 174.54 → 105.57 |
| Demod/AGC/carrier/SRRC | 23.18% | 28.68% | 84.04 → 83.12 |
| Channelizer/residual/NCO/FIR | 18.25% | 21.20% | 66.18 → 61.44 |
| Symbol/timing recovery | 5.16% | 7.16% | 18.72 → 20.76 |
| Four RS lanes | 1.80% | 2.16% | 6.54 → 6.25 |
| Input/mean checks + dispatch | 2.11% | 2.76% | 7.65 → 8.00 |
| PicoSHA block samples | 0.33% | 0.25% | 1.19 → 0.72 |
Viterbi normalized sampled cost falls about 39.5%. Demod's larger share
does not mean it slowed: absolute cost is essentially flat. Unchanged channelizer/
timing differences are sampling variability, not claimed improvements/regressions.
Inlining/skid and small buckets limit attribution; the PicoSHA bucket alone is
not the price of all records/copies/diagnostics. Raw profiles/symbol reports stay
ignored under build/viterbi-evidence/{baseline,candidate}-profile.{data,txt}.
Ranked follow-ups — proposals ONLY¶
Benefits are untested estimates, not measured savings, and are not additive. Every item requires separate approval; none was implemented.
- Remaining Viterbi transitions: 36.42%, ~105.57 cycles/source sample.
viterbi_decodestill visits 128 transitions and copies 64 metrics/step. Paired-predecessor/butterfly organization might save 20–35% of this stage, 7–13% whole pipeline. Integer/tie/unreachable/traceback order risks are high. Require frozen per-transition reference, exhaustive/rejected/independent evidence, native/memory64/sanitizers and alternating full-pipeline benchmarks. - Channelizer FIR/locality: 21.20%, ~61.44 cycles/source sample for the whole
component, not FIR alone.
hrit_channelizer.cpp::filter_at/processuses serial tap sums/ring accesses. Aligned/contiguous products or native vectors might yield 2–7% whole pipeline. Reduction/FMA changes can alter soft symbols/ frame acceptance; require summation-policy review, impulse/passband/DC/offset/ timing and broader noisy IQ, native/memory64 byte/evidence qualification. - Demod/SRRC organization: 28.68%, ~83.12 cycles/source sample, including
internal DSP AGC/carrier/RRC; hardware AGCs stay off.
process_samplealready pairs symmetric taps. Profile instruction locations before arithmetic-preserving I/Q/coefficient locality work; 1–5% whole pipeline speculative. Do not remove timing hypotheses or change inverse-sqrt/recovery precision. Require per-sample/ soft-symbol and downstream integer differential tests and independent noisy IQ. - Survivor packing: 526,336 bytes/instance inside the Viterbi bucket; isolated CPU share unmeasured. Compact bits may improve cache locality but add read/ modify/write work. 0–3%, possibly negative estimated benefit. Portability, bit order, bounds, unwritten states and lifetime require sanitizer/trace tests.
- Records/hash/copies/diagnostics/IPC: small sampled buckets (PicoSHA 0.25%, not all record work). Measure allocations/call counts if future delivery makes this material. Bounded reusable scratch might save under 1–2%, not proven. Memory protection, ownership/cancellation and hash coverage risks outweigh current evidence for a rewrite. Keep encode/verify/disposal and validation.
Reproducible commands and evidence¶
From repository root; freeze the baseline before candidate builds:
mkdir -p components/rfsentry-core/build/viterbi-baseline-source
git archive b276cea518ddb9ab5f225653a9ce4f07432ba626 \
components/rfsentry-core components/rfsentry-decoder components/rfsentry-api \
| tar -x -C components/rfsentry-core/build/viterbi-baseline-source
RFSENTRY_GOES_OTA_WAV=/path/to/hash-verified-prefix.wav \
components/rfsentry-core/tools/test.sh
./scripts/node-toolchain.sh run node \
components/rfsentry-core/tools/viterbi-benchmark.mjs build
./scripts/node-toolchain.sh run node \
components/rfsentry-core/tools/viterbi-benchmark.mjs measure
./scripts/node-toolchain.sh run node \
components/rfsentry-core/tools/viterbi-benchmark.mjs profile
./scripts/node-toolchain.sh run node \
components/rfsentry-core/tools/local-browser.mjs receive-benchmark
Browser measurement needs the frozen module/descriptor at
build/viterbi-evidence/baseline-receive.wasm and
build/viterbi-evidence/baseline-receive-artifact.json; saved before editing.
To reproduce later, run archived baseline tools/build.mjs receive with
CORE_EMSDK pointing to the existing pinned SDK, then copy its verified artifacts;
never relabel candidate bytes as baseline. Measurement defaults seven pairs,
12 replays; bounded VITERBI_PAIRS/VITERBI_REPEATS optional. PMU/profile uses
local sudo; browser needs neither sudo nor CDP. No global policy changes.
Limits¶
These are the recorded native/browser comparisons, not current-head results. Browser wall time is not CPU/PMU or peak RSS; profile attribution and queue/lag maxima are sampled. Live peaks are run-cumulative. >4-GiB execution, wider browsers and aggregate multi-stream capacity were not qualified. Deployment restart loss is separate from steady-state continuity; later delivery features do not retroactively change this experiment.