Skip to content

[lynx-perf 5] Validation diet: full structural checks in dev, envelope-only in production #6

Closed as not planned

Description

@Huxpro

Independent; compounds with [lynx-perf 4] (fewer, bigger commands) and helps FCP. Post-#1, per-command validation cost only matters where command counts remain large: create/mount batches and the first hydration commit.

The measured problem

Pre-#1 stage timers on a ~30k-command batch @10k rows: MT inbound validate 62ms + prepareLynxHostBatch staging/semantic checks 266ms — both scale with command count. BG-side selfcheck ≈0.1ms (already cheap, leave it). The defensive posture has real value — the cross-realm validator caught the octanejs#459-class bug — but in production, on a correct build, per-command structural validation only ever answers "valid". FCP also pays: the first hydration commit validates the entire tree's commands (FCP@10k ≈ 1090ms vs vue band 795–949, historical same-host).

Change

  1. Split validation: (a) envelope validation at the boundary — type/version/root/realm-safe shape of the message object — always on; (b) per-command structural validation — behind the existing dev/build define: on in dev and in the vm two-realm rig, off in production.
  2. Production fail-stop is preserved by the existing apply-time try/catch + fault path (applyFailed → faulted root). Add the invariant as a test: a corrupt command in production mode produces a loud fault, never silent corruption.
  3. In prepareLynxHostBatch, separate "semantic validation" from "staging work" so the define removes only checks, never behavior. Report the split in the __OCTANE_LYNX_PROFILE__ hook (prepareCheckMs vs prepareStageMs).

Constraints

Acceptance (rig, production build)

Activity

  1. Huxpro commented on Aug 9, 2026

    @Huxpro
    OwnerAuthor

    Implemented in #13 (draft, stacked on #12). Measured outcome vs this issue's acceptance, on the deterministic rig instrument (whole-run @10k, prod build, medians of 3 back-to-back reps):

    • Prepare ≥3× faster: met — 3.8× (11,239ms → 2,947ms). Inbound validate dropped ~90× (331ms → 3.7ms), ack ~1.2×. Every deterministic counter byte-identical (174 commits / 87 paced / 304,416 commands), 25 ratio guards pass unchanged.
    • FCP@10k ≥100ms better: not met — unchanged within noise (Lynx-for-Web BENCH_AUTOROWS=10000 probe: first text 5,614 → 5,546ms, full rows 5,910 → 5,848ms, spreads ±250ms). Structural reason: the rig's first screen is main-thread-rendered, so commit validation was never on the FCP critical path — the removed walks run post-FCP (background commits, ack, adoption). FCP belongs to [lynx-perf 7] [lynx-perf 7] Receiver diet: shrink the MT slice, spend it on FCP #8.
    • Dev suites green with validation on: met (full lynx dir, 27 files / 300 tests, two-realm rig).
    • Prod fault-not-UB: met — new validation-diet.test.ts runs the real dual-thread pipeline with NODE_ENV=production modules: real scenes behave identically, and corrupt commits (structural corruption, duplicate ids, malformed envelope) all reject loudly with the DOM untouched.

    Scope notes: cloneProps and all record-existence/attach-state checks stay unconditional (behavior, not validation); the split is reported as prepareCheckMs inside the profile hook (production reports 0 by construction, prepareMs − prepareCheckMs is the shared staging cost).


    Generated by Claude Code

  2. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Live-main audit (2026-08-11): no current owner; old driver path superseded. octanejs#700's real-browser profile attributes only about 2.9 ms to validation and 1.5 ms to preparation out of roughly 303 ms. Retain the dev-deep/prod-fast principle and profiling counter, but do not port the old validation diet without a new live-main profile proving a material owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions