← Back to Pull requests

perf(frontend): benchmark the wasm envelope seal in Chromium (P34) #255

Closed
unknown closed this pull request without merging on Nov 21, 2026 23:56 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 03:32 UTC
Author

What and why

Part of #171 (P34): the checkpoint A benchmark. It measures the wasm envelope seal in a real browser and records the results in docs/BENCHMARKS.md, giving ADR 0012 a measured bound on the size of one sealed upload.

  • scripts/bench-wasm-seal.sh builds the module and the frontend, then writes synthetic Parquet with synth-data (wide, seed 1) at about 1 MiB, 100 MiB and 1 GiB. It seals each size in a fresh dedicated worker in headless Chromium (the new vitest bench project) and prints a Markdown report with bundle size, module load time, seal time and module peak memory.

  • envelope.ts gains envelopeMemoryBytes(), which reads the module's linear memory size. Linear memory only grows, so after a seal this is the module's peak.

  • The wasm-seal job in the bench workflow runs the script on PRs that touch the module, the script or the backend. It reports only, like the native benchmarks. It fails only if a seal fails or an envelope is not exactly 52 bytes longer than its plaintext.
  • Results (i7-1355U, Chromium 158, see docs/BENCHMARKS.md)

  • Seal runs at about 50 MiB/s, because wasm has no AES instructions.

  • The module's peak memory is 3× the payload. Since wasm32 memory stops at 4 GiB, one seal takes at most about 1.33 GiB: 1.22 GiB sealed, and 1.37 GiB aborted.

  • DATASET_MAX_MIB (at most 512) is under that ceiling, so one object per upload needs no per-object cap for the seal's sake.

  • The module is 31.8 KiB brotli-compressed and loads in about 3–5 ms.
  • Targets

    @AxolDad, the issue asks for a target agreed with you. The proposed targets are in docs/BENCHMARKS.md under "Targets":

  • 100 MiB seals in under 3 s;

  • the module's peak stays at most 3.1× the payload;

  • the module stays under 64 KiB brotli-compressed.
  • Please confirm or adjust them.

    Checkpoint B (open) is not in this PR.

    How it was tested

  • scripts/check.sh passes locally, including the white-label guard on the built bundle.

  • scripts/bench-wasm-seal.sh ran end to end, with all 4 benchmark tests passing. A second run on the same machine gave the same memory figures and timings within ±15 % of the recorded baseline.

  • npm test and npm run test:browser do not pick up the bench project.
  • Checklist

  • scripts/check.sh passes locally

  • Every new refusal has a negative test (n/a: no new refusals)

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs (n/a)

  • Fails closed on missing configuration, key material, or attestation (n/a)

  • No new cryptographic primitives; suites stay behind their type aliases

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made (n/a: none made)
  • Diff: 353 lines (+264 / -89) across 4 files Reviewer: abendrothj Review duration: 5544m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 353 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #255"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.4% · Safe to merge
    18.4%