Skip to content

fix(v8): bound foreground work at each JavaScript checkpoint - #101

Closed
theduke wants to merge 1 commit into
split/napi-08-metered-wasmfrom
split/napi-09-checkpoint-fairness
Closed

theduke wants to merge 1 commit into
split/napi-08-metered-wasmfrom
split/napi-09-checkpoint-fairness

Conversation

@theduke

@theduke theduke commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

A foreground V8 task can post its successor while it runs. Draining until the queue becomes empty allowed this chain to monopolize one checkpoint, delaying the guest event loop and streamed responses during major GC.

Process one ready foreground task per checkpoint and report admitted/pending work so control returns to the guest between successive tasks. Preserve microtask/finalizer ordering and teardown draining. A deterministic standalone V8 process posts a self-repeating task and verifies that one checkpoint returns with work pending.

This is a scheduling change with no public API additions. The standalone regression owns V8 initialization/disposal to avoid contaminating the shared native test environments.

Stack and provenance

#93 → #94 → #95 → #96 → #97 → #98 → #99 → #100 → #101

Part 9 of the audited split of #84, reconstructed on current main eac0a13fa65a4d6103864d875ed76ab7efb1816e. Review against split/napi-08-metered-wasm; predecessor branches are required. Original PR #84 remains unchanged. The stack preserves newer main host-JS behavior and deliberately excludes the unused frozen 0.0.1 ABI adapter.

Validation

Build/run napi_v8_foreground_checkpoint_test (foreground_checkpoint_fairness) and the native promise runner (test_35_promise).

The CMake test is named napi_v8.foreground_checkpoint_fairness, so the existing make test-napi workflow selects it alongside the promise runner. Final branch CI is pending. No additional local execution was performed after the user requested tests stop.

Latest-main rebase

Rebased the dependency stack onto eac0a13fa65a4d6103864d875ed76ab7efb1816e after main merged PR #92. This preserves unsigned guest IDs, pointers and lengths, bounded result/argv writes, host-JS buffer failure cleanup and the high-pointer/high-ID regressions. Conflicts received independent native and host-JS source review. All historical local results above predate this rebase; no local tests or builds were run for it, as requested. Updated-head validation belongs to CI and may be pending. This PR keeps its prerequisite branch as its base to preserve the focused diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant