Skip to content

Reduce theme-fetch promise continuation latency during workbench startup #297

Description

@wieslawsoltes

Parent handshake issue: #289
Runtime scheduling context: #287 and #293
Workspace acceptance: #280 / #252
Related CSS work: merged #245 and #292

Problem

Unchanged Code OSS remote-workspace startup resolves the built-in light_vs.json theme through fetch(). WebScene's fetch body materialization and promise settlement are fast, but the promise microtask continuation holds the runtime for seconds while applying the theme. A protocol-writer timer that is already due cannot run until the required microtask checkpoint completes, delaying the 1.07 MB remote extension-host initialization send.

Timer arbitration cannot safely preempt this boundary: promise microtasks queued by a task must reach their checkpoint before the next task. The reusable owner is therefore the work performed by the theme-fetch continuation and its DOM/style bindings, not socket wakeup, wire throughput, response-body copying, promise settlement, or cross-source queue selection.

Exact retained evidence

Exact unchanged-Code trace inputs:

  • WebScene main base 1bd8596e3dc07a3281204504acad379eb1f6bc78
  • local query-gated observer commits a50fd344 and 7ad62971 (not pushed)
  • AppScene main package lineage 1420e227e52579a097e7ae52a2cadb41cf073e4d
  • exact Node 24.18.1
  • unchanged VS Code OSS 645f29cc3176500b4b5762ba887cf2a7f0ffdf2c

The dominant fetch task was:

  • URL: built-in extensions/theme-defaults/themes/light_vs.json
  • response: status 200, 7,407 body bytes, 10 headers
  • total drain_fetch_task: 2457.000 ms
  • task selection: 0.000 ms
  • ready future retrieval: 0.002 ms
  • response object/body/header construction: 0.011 ms
  • promise settlement: 0.001 ms
  • PerformMicrotaskCheckpoint: 2424.455 ms
  • recascade batch finish: 32.530 ms

The corresponding 50 ms protocol timer was overdue 2459.903 ms. Its competing-source histogram was fetch 2457.097 ms, async message 0.034 ms, window message 0.107 ms, V8 platform 0.002 ms. In the same run, protocol-send request 1789663793255 → native WebSocket.send entry 1789663796523 was 3268 ms; native send was 0.677 ms and its microtask 0.716 ms.

A 44,303-byte Seti icon-theme fetch also spent 266.624 ms in its promise microtask checkpoint and 6.368 ms finishing styles, while response preparation and settlement remained below 0.02 ms. This scaling reinforces the downstream continuation attribution.

Evidence: /private/tmp/vscode-252-fetch-phases-7ad62971.log, SHA-256 d1feb5b7970d56298ee80c2a49228dfc3060c4663dec3a2249b09e77c4d98b72.

Scope

First reduce the unchanged theme-fetch continuation into a product-neutral native/browser fixture and profile the synchronous JavaScript, DOM/CSS binding, cascade/layout, microtask, and scene-publication phases. Then optimize the smallest generic WebScene hot path. Preserve browser microtask checkpoint semantics; do not yield halfway through the microtask queue or add a Code OSS/theme special case.

Re-audit merged #292 before editing its DOM-listener/CSS paths. Keep #287/#293 scheduler candidates separate; they are proven generic fairness defects but did not qualify the product gate.

Acceptance

  • Query-gated profiling attributes the light_vs.json continuation across JavaScript execution, DOM/CSS bindings, recascade/layout, microtasks, and scene publication without changing product behavior.
  • A product-neutral fixture applies representative work from the exact 7,407-byte theme payload for at least 20 cold/warm cycles in Chromium and native WebScene.
  • Native continuation p95 is ≤ 250 ms and max ≤ 500 ms, with response construction and settlement individually ≤ 25 ms.
  • Promise ordering, run-to-completion, microtask checkpoint semantics, stylesheet/token application, computed styles, theme colors/icons, and error/rejection behavior match Chromium.
  • DOM nodes, selector/index work, scene count, task/wakeup counts, V8 heap, RSS, and retained listener/style state remain bounded through navigation and teardown.
  • Existing CSS/DOM contracts from Optimize structural CSS invalidation and DOM mutation checkpoints #245/Fix listener ownership and text-topology CSS work #292 and fetch, Worker/MessagePort/WebSocket/FileReader, idle-platform, and scheduler gates pass.
  • Unchanged Code OSS retains the exact remote root/provider/five children/five Explorer rows and completes remote Initialized plus first-child paint within Qualify remote workspace bootstrap, Explorer contents, and watcher refresh #252's two-second bound.

Activity

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

    bugSomething isn't workingvscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions