Skip to content

[lynx-perf-live 2] Make optional worklet machinery genuinely cold #44

Open

Description

@Huxpro

Classification

Performance/bundle enhancement for optional Lynx worklet machinery.

Evidence

Evidence: live-upstream residual audit.

Hypothesis

No-worklet applications should have no static import edge to registry, call-bridge, or dispatch machinery. The old bridge-slot patch changed module layout/hot dispatch enough to move runtime performance; a correct solution needs a compiler/capability-owned cold feature boundary rather than another receiver-level indirection.

Investigation

  1. Attribute which worklet modules remain reachable from each production slice after perf: bring Lynx renderer to ReactLynx parity octanejs/octane#693/perf: accelerate Lynx creation after first-screen adoption octanejs/octane#700 and why sideEffects/registration keeps them alive.
  2. Emit or select a worklet-capable feature entry only when compiled output actually contains worklets or useMainThreadRef calls.
  3. Keep the ordinary main receiver/install/dispatch path byte- and call-shape-neutral when the feature is absent.
  4. Preserve late chunks, mixed-version peers, first-screen worklets, thread calls, double-install diagnostics, and clean unsupported-message failures.

Acceptance

  • no-worklet main slice improves at least 2% gzip in both preview and IFR fixtures; background slice is byte-identical unless an itemized reason is accepted;
  • worklet-enabled fixtures retain byte/functionality parity and all thread-call/worklet tests;
  • ordinary CRUD, storms, startup/FCP, memory, and teardown show no >5% adverse decision cell in forward and reverse runs;
  • static source graph proves the absent feature has no import/re-export/side-effect edge;
  • per-slice frozen budgets prevent the dependency from returning.

Non-goals

Provenance

  • An agent authored this issue (agent-authored).

Activity

  1. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Upstream-ready implementation: octanejs#707

    Acceptance evidence:

    • no-worklet preview main gzip: 76,915 → 75,024 B (-2.46%)
    • no-worklet IFR main gzip: 81,995 → 79,980 B (-2.46%)
    • final retained production graph excludes main-worklets.ts and registry/call-bridge machinery when absent; compiler routes thread helpers to the cold module only when emitted
    • worklet-enabled Rspeedy fixture and all 338 Lynx tests pass
    • final base→candidate browser n=9: create +1.0%, update10th +1.2%, select -1.7%, updateStorm +2.3%, selectStorm +1.2%; reverse order also stayed within 5%
    • list teardown: 0 retained cells; scoped typecheck, format, sync, bundle budgets, and compiler tests pass

    Background exception itemization: raw program length stays exactly 271,737 bytes and semantic markers are identical. gzip changes 73,182 → 73,185 B and the encoded checksum changes only because the independently optimized main graph perturbs Rspack debug-metadata and one-character minifier locals; decoded comparison found no background source/command/semantic change. This is the issue's allowed itemized exception, documented in the PR.

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-authoredenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions