Skip to content

[Lynx M2] 用可验证的布局身份减少 adoption 重放与 snapshot 工作 #287

Closed

Description

@Huxpro

总路线:#282(承接 #281)。所属 milestone:Lynx ceiling M2 — 首屏可交互与稀疏更新。

问题与假设

旧 benchmark#50 的 rows1k startup commit-ACK 约 43.4s 是 adoption/settlement 边界,不是 FCP,且不是当前 head 的复测。目标同时缩短 first paint→ready 和首次 native tap→frame,避免只把 capture 移出 FCP。

依赖 #283、#278、#284。#277 的 frame rung 是独立较小工作,可先交付;本 issue 针对 row-scale adoption 的剩余 CPU、描述、比较和临时对象。

设计

研究 Vue Vapor 的 deterministic allocator / adoption,借鉴可证明身份而不照搬“删掉 snapshot 就等价”。Octane 的条件 hooks、动态 range、initial props、refs/effects、render-phase state、portal/list、并发更新使无条件 replay identity 不成立。

先列出 eligible first-screen shape 的证明边界:同 module/layout digest、初值/分支 shape、id allocation domain 与 epoch。用紧凑 program/run adoption manifest 复用已绘制 host 身份;必要动态状态仍跨界。对不满足证明的子树维持现在的 snapshot/repair 与清晰原因。

避免“两边各推导一遍且都错”的校验:身份契约来自 #284,独立 native element 身份、事件与状态断言负责观测。按 ①manifest + mismatch/repair,②删除已证明多余描述/比较 两条小 PR 交付。

验收

  • paint → capture/announce → adopted → ready 各边界和 first tap latency 同时测;同一初始树无重复 host create,BTS replay 的必要组件 setup 与用户 side effect 不能被删。
  • tap/snapshot/inbound commit/sync-ready/第二次 render/unmount/close 在每个 gap 中均只 capture 一次,旧回调不可操作新 root;沿用 perf(lynx): describe the first tree after the frame it describes #273/perf(lynx): #273's default setTimeout rung fires before the first frame on LepusNG #277 fence。
  • props/data 到达顺序、动态 text/range、不同 realm 环境、mismatch、拒绝/abort、重复 mount 全覆盖。无需快路径的应用不付整树额外扫描。
  • 结构传输按 programs/runs,必要数据按实际动态状态增长;冷 FCP、ready、首次交互、settled CPU、GC/retention 和 bundle 联合报告。

通用合并与证据契约

  • 保持 Octane 的 hooks、refs/effects、原生事件、Suspense/Activity/portal、reject/abort 与 cleanup 语义;适用模式必须覆盖。共享两条路径时使用同一语义实现,并加独立的用户可观察断言,不能只做 differential 对比。
  • 每个优化 PR 带 baseline/candidate 的精确 SHA、生产 bundle hash、机制命中/回退原因、同窗口 AB/BA 原始样本及成本归属;profile 负责解释,未插桩生产产物负责 headline。未测到的收益标为 hypothesis。
  • 先拿到相关 owner 数据,再实现一个机制一条 PR;正确性与 current-head CI 通过才算交付。记录对冷启动、另一线程、GC、内存和 bundle 的成本转移。

由 agent 根据 #281 的后续规划请求创建。

Activity

  1. Huxpro commented on Sep 7, 2026

    @Huxpro
    OwnerAuthor

    Slice 1/2 merged: proof-bearing program manifests

    PR #297 merged into new-lynx at 99576f6ea7196d79a8f71e0c93e002e986584267 after the exact head passed all 26 CI jobs.

    What landed:

    • the pre-negotiation first batch retains a compact addressed program manifest beside its unchanged expanded commands;
    • the main thread validates program address, placement, host/listener layout, count, and dynamic values before adoption;
    • absent or unequal proof preserves the existing mismatch/repair path, and unsupported peers never receive the manifest;
    • only the first adoption batch can pay for the proof.

    Mechanism evidence: 5/5 production-profile first screens at both 1k and 10k reported one manifest run, one match, and adopt. The uninstrumented PAPI A/B remained neutral/noisy (1k 120.4 vs 119.4 ms; 10k 787.5 vs 794.1 ms), with exactly the same 17,113/170,113 host calls and two flushes in both revisions.

    This is deliberately not counted as a speedup. The cost ledger records Web +11,656 B, Lynx +10,406 B, and a provisional +70.2 ms 10k paint-to-settled median in the sampling build. Slice 2 must use this proof to remove the redundant expanded description and per-program-node comparison, repay the temporary debt, and rerun ready/interaction/GC/bundle gates before #287 closes.

    Report and raw samples: https://github.com/Huxpro/octane/tree/new-lynx/docs/reports/lynx-issue287-program-manifest

  2. Huxpro commented on Sep 7, 2026

    @Huxpro
    OwnerAuthor

    Slice 2 merged in #298 (ccc61b0f6a50f17cdf159fa07b15c1d1e0209449). This deletes the expanded first-tree program stream on the eligible adoption wire path and uses a proof-bearing addressed run plus compact ACK, while preserving the expanded in-memory batch for repair/compatibility.

    Exact-head evidence (8d834fbcbb0bd7095e85e0330dc256f569e345e2, native control ae58d5ab638f3e203a75fa0441087931cbd5773c differing by one early return):

    • Web shipping FCP, AB/BA n=5/cell: 1k 142.6 vs 145.1 ms (1.018x), 10k 843.7 vs 821.6 ms (0.974x). Intervals overlap and directions disagree, so no FCP claim.
    • Web 10k attribution: adoption main frames 437.9 -> 135.0 ms; prepare 238.2 -> 99.4 ms; apply 93.8 -> 38.0 ms; paint-to-settled 1047.9 -> 477.1 ms.
    • Native 1k AB/BA n=5/cell: commands 10,068 -> 69; program comparisons 4,028 -> 28; ACK+complete 973,504 -> 203 B; main apply 4570 -> 3778 ms. Cold FCP 1003 vs 994 ms and background-to-second-frame 605 vs 605 ms remain neutral.
    • First native Clear preserved exact 1000 -> 0 state, identical 7,000 commands and 163,613-byte ACK; tap-to-second-frame 2308 vs 2325 ms and main apply 961 vs 960 ms show no large transfer into the first interaction.
    • Full current-head CI run 34127872458 passed, including Lynx compatibility, Node 24 shards, browser/heavy integration, React parity, publish validation, lint/typecheck, and provenance.

    Full raw evidence and protocol: docs/reports/lynx-issue287-program-compaction/README.md.

    #287 remains open. Next gates are explicit: repay the +12,008 B Web / +11,504 B Lynx temporary bundle debt, delete the remaining per-host native ownership transfer that leaves apply at 3.78 s, and collect same-window forced-GC retention through hand-over/update/unmount/close before rerunning ready gates.

  3. Huxpro commented on Sep 7, 2026

    @Huxpro
    OwnerAuthor

    Ownership slice merged in #299.

    Exact 1k Android mechanism A/B at commit 6993c08c476a33fe801ff8477644531ced295306:

    • native prepared.apply(): 4072 [4063–4098] ms -> 3 [3–3] ms
    • first Clear main apply: 1012 [1008–1016] ms -> 279 [277–280] ms with the same 7,000 commands and exact pre/post state
    • ownership proof: 1 run / 4,000 hosts / no fallback in every candidate sample
    • cold FCP intervals overlap and remain neutral
    • exact-head CI is fully green

    Report and raw evidence: https://github.com/Huxpro/octane/blob/new-lynx/docs/reports/lynx-issue287-program-ownership/README.md

    #287 intentionally remains open. Remaining gates are forced-GC retention across hand-over/update/unmount/close and repayment of the temporary shipping bundle debt (+16,849 B Web / +15,411 B Lynx versus the slice-1 baseline).

  4. Huxpro commented on Sep 7, 2026

    @Huxpro
    OwnerAuthor

    Final retention/size slice merged in #300.

    Exact head 23cce7609e4c702dd0a29f614d77d31e24bf6834; merge commit 168eaca0751e2002b087cab3192c542206c8066b; exact-head CI run 34144185577 passed every job, including the four Node 24 shards, browser/heavy integration, Lynx compatibility, typecheck, lint, publish validation, and provenance.

    Closure evidence:

    • Shipping bundles versus the slice-1 baseline: Web 582,545 -> 579,114 B (-3,431 B, -0.59%), Lynx 564,273 -> 560,035 B (-4,238 B, -0.75%). Exact SHA-256: Web 218adcb5f37353a47b0cf3b1d42c724b477cfdeb5a60c79659dc29aa7b57a68e; Lynx 2875ca60e84772d1b9223507bf25e081b27e96d0c2d5b843654e3e0371e93e62.
    • Forced-GC lifecycle, Chromium 149, n=5: adoption owns one live run / 4,000 hosts; sparse update promotes one host and leaves 3,999 adopted; unmount reaches 0 live runs / 0 hosts; close releases about 3.25 MiB. No ownership-retention leak is claimed.
    • Exact-code Android native n=5: cold first screen remains neutral; adoption prepared.apply() is 3 [3–3] ms with 69 commands and a 203 B compact reply; first Clear preserves exact 1,000 -> 0 state and the same 7,000 commands, with 290 [287–291] ms apply; teardown reports 0 live runs / 0 hosts.
    • Production diagnostics are compact stable OL001–OL483 codes; full source/development diagnostics remain recoverable. The temporary bundle debt is fully repaid.
    • The attribution-only production profile retains diagnostic anchors without changing shipping bytes or hashes; unmatched MTS share is 31.5% [30.5–32.6], below the unchanged 40% gate.

    Full protocol, raw JSON, provenance, limitations, and reproduction commands: https://github.com/Huxpro/octane/blob/new-lynx/docs/reports/lynx-issue287-retention-size/README.md

    All explicit #287 gates are closed; marking complete.

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

    agent-authoredenhancementlynx

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions