ReviewOS

home-lang/home

Runtime transpiler: fast-path large whitespace-only virtual sources

#601
Closed chris opened this 10 days ago ·
10 days ago

Scope

Finish native admission of js/node/worker_threads/worker_threads.test.ts without changing the upstream test, fixture workload, or five-second deadline.

This supersedes the remaining Debug timing boundary recorded in #482.

Root cause

The bundler ParseTask already recognizes arbitrarily large whitespace-only JavaScript as an empty module. The runtime transpiler only applied that contract to sources shorter than 33 bytes, so the worker eval/Blob path sent each 100 MiB whitespace-only virtual source through the full JavaScript parser.

Required implementation

  • Apply the same empty-module contract to runtime eval, stdin, data, and Blob virtual sources.
  • Keep the canonical ASCII-whitespace predicate exact and make its scan efficient in Debug as well as optimized builds.
  • Add boundary coverage across vector blocks and mixed ASCII whitespace.
  • Promote the complete dedicated worker test directories only after the unchanged suite passes natively.

Evidence

Before the fix:

  • Home Debug: 33 pass / 1 timeout at the original five-second deadline.
  • The six-worker leak fixture took about 11.03 s.
  • Pinned Bun 4982b91e3702094330f3be3883354c52b8c01323: 34/34 in 1.269 s.

After the general runtime fix:

  • Home Debug strict native: 34/34 in 4.079 s.
  • Home ReleaseSafe strict native: 34/34 in 1.066 s.
  • Complete 75-file worker aggregate (17 dedicated tests + 58 Node parallel scripts), Debug and ReleaseSafe: 356 pass / 4 upstream TODO-skips / 0 fail / 0 unsupported.
  • Runtime units: 1,817 pass / 19 skip / 0 fail.

No upstream assertion, fixture workload, or deadline is changed.

10 days ago

Closed by 4233b8c16.

Implemented the general runtime fix rather than changing the corpus test:

  • Runtime virtual eval/stdin/data/Blob sources now use the same arbitrary-size whitespace-only empty-module contract as bundler ParseTask.
  • The canonical ASCII-whitespace predicate scans 32-byte vector blocks, with unit coverage for empty, tail, full-block, mixed-whitespace, and non-whitespace boundaries.
  • js/node/worker_threads/worker_threads.test.ts is now admitted natively, completing the exact 12-file js/web/workers and 5-file js/node/worker_threads test inventories.

Final evidence:

  • Pre-fix Home Debug: 33 pass / 1 timeout; six-worker fixture about 11.03 s.
  • Pinned Bun 4982b91e3702094330f3be3883354c52b8c01323: 34/34 in 1.269 s.
  • Post-fix Home Debug strict native: 34/34 in 4.079 s.
  • Post-fix Home ReleaseSafe strict native: 34/34 in 1.066 s.
  • Complete 75-file worker aggregate in both Debug and ReleaseSafe: 356 pass / 4 upstream TODO-skips / 0 fail / 0 unsupported.
  • Runtime units: 1,817 pass / 19 skip / 0 fail.
  • Debug build, ReleaseSafe build, Zig formatting, and diff checks passed.

No upstream test assertion, fixture workload, or deadline was changed.

Sign in to comment on this issue.