Skip to content

At 30k rows the "wire-free" first screen ships 42 MB to the background #231

Open

Description

@Huxpro

The anomaly

From #39's three-entry run (results/runs/2026-08-28T00-56-44-…-octane-sync-v0147-residual-web.json), startup-suite wireToBtsBytes — bytes crossing MTS→BTS during the startup window — for our entries against upstream:

scale hux (pre-sync) hux (post-sync) upstream
0 21,601 18,710 18,680
1,000 1,755 1,676 1,674
10,000 1,646 1,624 1,627
30,000 42,841,644 36,960,444 1,688

At 1k and 10k the inverted handoff is doing exactly what #163 C2e promised — the adoption crosses ~1.7 KB, same as upstream's handshake. At 30k, ~1.4 KB per row crosses to the background: the shape and size of a full per-node first-tree description. wireToMtsBytes@30k stays at 274 bytes, so nothing was repainted — whatever crossed was consumed as a successful handoff, meaning some scale-triggered condition routes the 30k first screen onto a describe-and-ship path that 1k/10k never touch. The measurable damage in the same run: FCP@30k is 6–8% behind upstream (8,192 ms vs 7,716 ms) while 0/1k are at parity or ahead — plus whatever this costs on device, where 40 MB through the ContextProxy is not a rounding error.

Why this is worth a real root-cause, not a shrug

  • It is a cliff, not a slope: identical mechanism at 10k, different mechanism at 30k. Cliffs mean a threshold or a fallback predicate, and un-root-caused fallback predicates are how "wire-free adoption" quietly stops being true in production shapes.
  • It may be one bug wearing three costumes. chore: sync new-lynx with upstream octane v0.1.47 (d5175ca8) #229 flagged two other unexplained anomalies in the same runs: heapMtsAfterClear drifting 1.46×→1.58× upstream, and the pre-sync build's first create never completing in second position in a shared browser. A ~40 MB message (and whatever retains it, or its send buffer) is a plausible common root for heap drift and realm poisoning both. Check the linkage before treating them as three issues.

Orders

  1. See the message. Reproduce a 30k first screen in the lynx-table harness with the wire instrumented (the transport codec makes this one dump: capture the MTS→BTS traffic during startup, log message type and size per message). One look answers whether it is the first-tree snapshot describe(), a lifecycle payload, profiling leakage, or something else entirely.
  2. Find the flip. Bisect row count between 10k and 30k for the first scale where the bytes explode. The flip point identifies the predicate: a size/host-count threshold, a compact-ACK or incremental-handoff degradation, a capture path that declines and falls back to description shipping, or a native-list/topology shape that only forms at that scale. Read the predicate in source and name it — the number alone is not the answer.
  3. Fix or justify. If it is a fallback that no longer needs to exist (the C2e inversion plus D-train machinery may have obsoleted the path that ships descriptions), delete the route and let the regression suite say what still needed it. If the fallback is load-bearing for a real shape, make its trigger precise and its payload proportionate — a fallback that ships O(page) bytes must at minimum say so in a diagnostic rather than fire silently. Either way, add the regression the anomaly earned: a wire-byte budget assertion in the harness for the startup window at a scale above the flip point, so a reintroduction cannot land quietly.
  4. Close the loop on the cousins. After the fix, re-measure heapMtsAfterClear and re-try the second-position sequence on the fixed build. If they move, say the three were one; if they don't, they become their own probes (tracked in The create residual: attribute it, tax-test it, then extend compiled programs to steady-state mounts (E-train) #230's attached-probes section).

Oracle

wireToBtsBytes@30000 back in the KB class in the harness's startup window; FCP@30k re-measured against upstream on the #39 protocol (same host, one physical run, order-controlled); no regression at 1k/10k; the adoption/first-screen suites — nested programs, declines, visibility, the whole comparator surface — pass unmodified.

Activity

  1. Huxpro commented on Aug 28, 2026

    @Huxpro
    OwnerAuthor

    Orders 1–2: it is a race, it is not ours, and the payload is used as a boolean

    Three of this issue's premises do not survive its own run file. Reporting before fixing, per the disagreement rule.

    The per-rep samples

    wireToBtsBytes is reported as a median. The samples behind the four startup@30000 medians:

    entry wireToBtsBytes samples big reps
    a-octane-hux (pre-sync) [42841644, 42841649, 42841642, 42841643, 42841647] 5/5
    octane (upstream v0.1.47) [36960349, 1688, 1676, 1682, 36960364] 2/5
    octane-sync (post-sync) [36960444, 36960441, 36960447, 1687, 36960451] 4/5

    So:

    1. It is not a fork defect. Upstream ships 36,960,349 B on the same workload, in 2 of 5 reps. The issue's upstream = 1,688 B column is the median of a bimodal sample — three small reps outvoted two 37 MB ones. Post-sync and upstream agree to within 100 bytes (36,960,44x vs 36,960,3xx) when both fire, which says they are shipping the same description.

    2. It is a cliff in the aggregate only. Per rep it is bimodal — 1.7 KB or 37 MB, same build, same scale, same page. That is a race, not a threshold, so there is no row count to bisect and no size predicate to find. Row count matters only because it sets how long the window stays open.

    3. The trigger is visible in the same records. wireToMtsBytes@30000 moves with it, positionally, with no exceptions:

      entry wireToMtsBytes wireToBtsBytes
      octane [256, 60, 60, 60, 256] [36960349, 1688, 1676, 1682, 36960364]
      octane-sync [257, 257, 257, 60, 257] [36960444, 36960441, 36960447, 1687, 36960451]

      Every rep that received ~200 B extra inbound shipped ~37 MB outbound; every rep that received 60 B shipped 1.7 KB. The extra inbound is a correlated main-ready-request reaching the main thread while it still holds the first-tree journal.

    The mechanism, in source

    main-thread.ts:1334 — the snapshot rides any correlated ready reply, and only the uncorrelated announcement (request 0) is free:

    const snapshot =
      request === LYNX_READY_ANNOUNCEMENT_REQUEST || firstTreeSnapshotSent || firstTree === null
        ? null
        : firstTree.snapshot;

    firstTree is set on every successful synchronous first screen (main-thread.ts:1977) and released at 1453 when adoption completes. So the race is between adoption releasing the journal and the background's correlated request arriving. At 30k the main thread is inside an ~8 s paint, which holds the window open long enough that the request usually lands first — hence "only at 30k", on both sides of the fork.

    LynxFirstTreeSnapshot carries nodes: readonly LynxFirstTreeNodeSnapshot[], one entry per physical node, so the reply is O(tree) with no bound: ~350 B/node at benchmark scale.

    What the background does with 37 MB

    transport.ts:765:

    const adoptingFirstTree = message.firstTree !== undefined;

    That is the only read of the field anywhere in packages/lynx/src. Nothing inspects nodes, roots, plan, or version; adoptingFirstTree exists to suppress capabilities for the first batch so it preserves main's first-screen IDs. The whole per-node description is structured-cloned across the wire to communicate one bit — and protocol.ts:1747 then pays a full O(tree) assertFirstTreeSnapshot validating it on receipt.

    Order 1 in the lynx-table harness: it does not reproduce there

    Five browser runs of the startup window, per-message type/bytes via __OCTANE_STAGE_WIRE__, all KB-class with no Octane protocol message at all — only web-core lifecycle chatter:

    build 10k 30k
    dist-rows (universal) 1,498 B 1,636 B
    dist-mtsprogram-rows 1,598 B 1,509 B
    dist-block-rows (BENCH_CORE=block BENCH_BLOCK_MODE=scoped) — 1,669 B
    this repo's own entries/octane-sync/dist 1,512 B 1,506 B

    The last row is the exact artifact that logged 36,960,444 B in the #39 run. At FCP 5.5–7.8 s against the run's 8.2 s, so not a host-speed difference — the harness simply lands on the lucky side of the race, which is what a 1-rep probe of a bimodal variable does. A single-sample reproduction was never going to be the right instrument here; the run file's samples arrays were.

    Where Order 3 lands

    Not "delete the route": the bit it carries is load-bearing, and ID preservation for the first background batch is exactly the kind of obligation that must not be approximated away. But the payload is not load-bearing at all. The fix is to make the payload proportionate to the one bit the receiver reads, keeping the full description only for a peer that negotiated at a rung predating the inverted handoff — and to add the wire-byte budget assertion so a reintroduction cannot land quietly.

    Doing that next, with the budget regression, on fix/lynx-first-screen-wire-cliff.

    Order 4, adjusted

    heapMtsAfterClear and the second-position poisoning are worth re-checking against a fixed build for a reason stronger than "same neighbourhood": a 37–43 MB structured clone landing in the background realm during startup is a plausible common cause for both, and it now has a known trigger to hold or release on demand rather than wait for.


    Generated by Claude Code

  2. Huxpro commented on Aug 28, 2026

    @Huxpro
    OwnerAuthor

    Order 3: the fix, and the budget that keeps it

    #233 (draft, stacked on #229's head).

    What changed

    main-ready now states the painted first screen as a fact instead of a
    description:

    export const LYNX_FIRST_TREE_PRESENCE_READY_REQUEST_BASE = 2 ** 45;
    // …
    readonly firstTreePainted?: 1;

    A background whose readiness request is tagged at that rung gets the bit. The
    main thread picks the encoding from the peer's rung, and every downstream branch
    now turns on whether the reply announces a first tree rather than on which
    encoding carried it.

    The description route is kept. A peer below the rung is still sent the whole
    snapshot, because for it presence is the key — the bit alone would tell it no
    first screen happened at all, and it would rebuild the page over the command
    path with fresh IDs. That is the load-bearing obligation from the Order 1/2
    report, and it is not approximated away; it is written at the constant's
    definition site and pinned by a test that drives a peer below the rung and
    asserts it still receives all 401 nodes. Both directions of version skew are
    therefore safe, and the two spellings are mutually exclusive on the wire so a
    receiver never has to decide which one wins.

    A second win the issue did not ask for

    firstTree.snapshot is built on first read (#148). The presence path never
    reads it, so a first screen that hands off this way never allocates a
    description of itself either
    — the saving is main-thread allocation as well as
    wire bytes.

    The budget regression, in two places

    • packages/lynx/tests/first-screen-ready-wire.test.ts — the reply is
      byte-identical at 50 and 400 rows and under 512 B. Not "smaller": it has
      stopped being a function of the page. Red-verified by breaking
      announcesByPresence, which fails 2 of its 3 cases.
    • benchmarks/lynx-table/first-screen-selectors.mjs — a 4,096 B
      main-to-background budget over the whole first screen, with the offending
      wireTrace dumped on failure. Measured mts->bts=468B on both handshake arms
      at rows=1000.

    That second one closes the gap this issue fell through. The ops suite has
    reported bytes since it existed; the first screen reported only counts, on the
    reasoning that a screen the direct applier paints sends no commands. True of the
    background-to-main direction, and silent about the other one — which is where
    the 37 MB was.

    Order 4

    Not in #233. Next, against the fixed build.


    Generated by Claude Code

  3. Huxpro commented on Aug 28, 2026

    @Huxpro
    OwnerAuthor

    Order 4 — the fix at the cliff scale, and three corrections

    All measurements same machine, single run, #39 protocol.

    The cliff is gone, measured at 30,000 rows

    benchmarks/lynx-table/first-screen-selectors.mjs --scales 1000,30000 on the fixed head:

    rows selectable nodes arm mts→bts
    1,000 4,029 before-render 468 B
    1,000 4,029 after-render 468 B
    30,000 120,029 before-render 470 B
    30,000 120,029 after-render 470 B

    Two bytes across a 30× tree. Against the pre-fix browser harness at the same scale (startup/wireToBtsBytes, median of 5): octane-sync 36,960,444 B, a-octane-hux 42,841,644 B, upstream octane 1,688 B.

    Correction 1 — the budget I shipped does not guard this

    I claimed in the code that its job was "to catch a payload that scales with the tree". It cannot. I instrumented dispatchReady and both arms of that harness report firstTreeNull=true: they render from the background, so the main thread applies commands and never captures a first tree. There is no description on that wire to bound. The proof: I dropped the background below the presence rung and re-ran — still 470 B, because neither arm has a description to send either way.

    Fixed in 73882702a. The check stays, because it does bound something real — the rest of the handshake must not become a function of the page by any route — but the comment now says that is its scope and names where the description's own budget lives: first-screen-ready-wire.test.ts drives a real main-thread paint, pins the reply byte-identical across an 8× tree and under 512 B at the presence rung, and proves that budget can fail by dropping a peer below it and watching the same reply grow past 4×. That test is the wire-byte regression this fix ships with; the bench number above is corroboration, not the guard.

    Correction 2 — I withdraw my own common-cause hypothesis

    My Orders 1–2 comment proposed the 37 MB startup clone as a plausible common cause for heapMtsAfterClear and the second-position stall. The same run file refutes it. startup/wireToBtsBytes at 10,000 rows:

    entry bytes
    octane 1,627
    a-octane-hux 1,646
    octane-sync 1,624

    The clone only fires at 30k. heapMtsAfterClear is measured at 10k, where no clone happens. Different defect.

    Also worth recording: the cliff is not a sync regression. The pre-sync block core is worse (42.8 MB vs 37.0 MB). Both block-core builds have it; upstream does not.

    The retention, named, and split by cause

    CDP heap-snapshot probe: one browser per entry, harness-identical readiness, create 10,000 → clear → HeapProfiler.collectGarbage → Runtime.getHeapUsage → takeHeapSnapshot, aggregated by constructor self size. It reproduces the harness:

    entry harness heapMtsAfterClear probe Δ
    octane 7,300,040 B 7,284,328 B 0.22%
    a-octane-hux 10,647,692 B 10,644,140 B 0.03%
    octane-sync 11,547,096 B 11,566,908 B 0.17%

    octane-sync over upstream octane, +4,282,580 B:

    constructor delta instances
    array: +3,146,680 B 370 → 381
    native:system / ExternalStringData +652,047 B 294 → 30,285
    string:row +480,000 B 1 → 10,001
    array:(object elements) +398,844 B 829 → 780

    Using the pre-sync block core as the control splits that in two:

    • array: +3.15 MB is the block core's, not the sync's. a-octane-hux carries +3,146,388 B of it too. Present since v0.1.36. ~315 B/row.
    • New at the sync: +924,152 B. string:row 1 → 10,001 (+479,968 B, exactly one per row), ExternalStringData 19,857 → 30,285 (+184,050 B, ~one more per row), array:(object elements) +135,568 B across only +3 arrays — three arrays each grew ~45 kB.

    So the v0.1.47 sync adds ~92 B/row of per-row strings that survive teardown, on top of a separate ~315 B/row of arrays that predates it. Repeated across three runs the numbers reproduce to four significant figures.

    Limit: I aggregated by constructor self size, which names what is retained, not who holds it. Naming the holder needs a dominator/edge walk.

    Correction 3 — I withdraw the second-position stall

    Seven runs, fresh browser per entry:

    order second entry
    octane → octane-sync (shared browser) stalled
    octane → octane-sync (fresh browser) stalled
    octane → octane-sync (fresh browser) completed
    octane-sync alone completed
    octane-sync → octane completed
    a-octane-hux → octane-sync completed
    octane → a-octane-hux completed

    2/3 in one ordering and 0/5 elsewhere looked pair-specific until the third run of that same ordering completed. With a fresh browser per entry over a static file server, no application state carries between entries — the only carryover is host state. I can't call this a framework defect on this evidence, and it is consistent with #230's note that the post-sync build survives the sequence. I'm not spending more runs on it.

    Handoff to #230

    The retained per-row strings (exactly 1/row) and #230's per-host handles acknowledgement (~1,742 B/row) are both per-host and both outlive teardown. That is a hypothesis, not a finding, and #230 Order 2's compact-v1 A/B will settle it for free: if forcing compact-v1 also drops heapMtsAfterClear, one fix closes both; if it doesn't, the retention needs its own owner. I'll report the answer on #230 either way.


    Generated by Claude Code

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