Skip to content

[lynx-perf 4] Plan-aware wire: instantiate-by-plan-id instead of per-node create commands #5

Closed as not planned

Description

@Huxpro

Independent of [lynx-perf 2]/[lynx-perf 3]; assumes #1 landed (update path already minimal — this targets the mount/create path and the per-command constant). Current: create@10k = 4444ms vs vue-vdom 2133 / react 1717 (2.08×), ~160,000 commands (unchanged by #1).

The measured problem

The compiler already produces block-grade information: every host template is a hoisted universalPlan (structure tree + bindings/slot table) compiled into BOTH bundles (the MT slice carries the same plans for the first-screen renderer). The wire never uses it: mounting N rows ships per-node create/insert/update command objects which MT validates and applies node by node. The per-command volume (clone + staging + validation × 160k) is the excess; the LIS/keyed machinery itself is fine.

Honest expectation: vue-lynx's +b:c experiment showed create is PAPI-bound, not interpretation-bound — the win here is clone+validate+staging volume. Target the vdom tier (~2100–2600 on the reference host), not react's 1717 (that additionally needs code-staged MT create and a lighter runtime).

Change

  1. New command: instantiate(planId, instanceId, slotValues[]) — one command per plan instance (per Row), replacing that instance's per-node create/insert/update commands. Keyed mounts = one instantiate per item + existing LIS move/remove.
  2. Plan identity: build-time registry (module-stable planId, e.g. hash of plan JSON) shared by both slices. MT resolves planId → plan and materializes via the same plan interpretation the first-screen renderer uses — one materialization code path for first frame and runtime mounts.
  3. Fail-safe (precedent: vue-lynx's template-hash fail-safe): MT can't resolve a planId (HMR skew, lazy chunks) ⇒ per-plan fallback to per-node commands. Never hard-fail. Covered by a test that deliberately drops a plan from the MT registry.
  4. Optional, measure first: flat-array command packing (opcode + operands; precedent RL snapshotPatch / vue-lynx ops) behind a define — let the rig decide if clone savings justify it.

Constraints

  • Update-path commands unchanged; select/update10th must stay within noise.
  • Adoption/first-screen hydration must accept instantiate-mounted trees (same plan interpretation ⇒ same shapes; assert with the two-realm rig).

Acceptance (rig)

  • Deterministic: create@10k commands ~160k → ~10k+toolbar instantiates; commit bytes −50% or better.
  • create@10k wall-clock in the 2400–3000ms band; create@1k proportional.
  • FCP unchanged or better; fallback path tested.

Activity

  1. Huxpro commented on Aug 9, 2026

    @Huxpro
    OwnerAuthor

    Implemented in #12 (draft, stacked on #11). Measured outcome against this issue's acceptance:

    Deterministic rig (met):

    • create@10k: 160,000 → 10,000 wire commands (exactly one instantiate per row; 1.00× the new create_commands model floor, guarded in ratios.json — the pre-change head measures 16.0×).
    • create@1k: 16,000 → 1,000.
    • Create commit bytes: −69% (10.57MB → 3.31MB @10k), beating the −50% target.
    • Update path untouched: update10th/select/swap/storm counters byte-identical before/after.
    • Fallback tested: nothing-announced skew degrades to per-node commands (working DOM and taps), and an announced-but-unresolvable plan rejects the commit with a diagnostic. Protocol stays version 1; announcement rides the existing ready reply plus incremental plan-registry messages.

    Wall clock (not reached, with runtime proof of why):

    • create@10k measured 4669 ±277ms vs 4459 ±30ms baseline (2.08× vs 2.17× vue-vdom, all four cells re-run back-to-back) — unchanged within noise; the 2400–3000ms band is not reached.
    • Folding is provably active in the real Rspeedy dual bundles: a runtime probe of the profile web build counts 1,094 outbound commands for mount + create-1000 (per-node would be ~16,600). The issue's own caveat proved out — create is PAPI-bound on this host, and the 16× clone+validate reduction wasn't the wall-clock bottleneck. The remaining cost is per-node staging on the background plus expansion + per-node PAPI apply on main.
    • The honest path to the band is the react-tier work this issue scoped out: code-staged MT create (materializing the plan directly to PAPI with no intermediate command objects). The planId registry/announcement/expansion machinery from perf(lynx): plan-aware wire — fold provable plan instances into instantiate-by-plan-id commands ([lynx-perf 4]) #12 is the substrate that follow-up needs.
    • Item 4 (flat-array packing) measured-first and not taken: bytes already −69% and crossing volume isn't the bottleneck.

    Generated by Claude Code

  2. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Live-main audit (2026-08-11): superseded by octanejs#693 and octanejs#700. The old instantiate-by-plan wire reduced commands/bytes but expanded back into per-node work and did not move create wall time. Template programs/runs now execute certified dense hosts directly and own this architecture. Do not port the old plan-wire path.

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