Skip to content

test(macro-js): strengthen cross-invocation isolation coverage - #607

Merged
Teakowa merged 1 commit into
mainfrom
perf/macro-quickjs-setup
Oct 19, 2026
Merged

Teakowa merged 1 commit into
mainfrom
perf/macro-quickjs-setup

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Refs #595

Tests only; no production change. Investigating #595 showed that no JavaScript lifecycle change is worth making (see the conclusion on the Issue). While doing so the cross-invocation isolation contract from #6 and #295 was exercised more fully than the existing tests do, and those cases are kept: memory-limit recovery, stack-limit recovery, deadline re-arming, a per-invocation console sink, a 32-iteration consecutive sweep, and intrinsic and prototype reset. They pass on origin/main.

Reviewer question: keep only the cases that are not already covered by existing macro_js tests; drop any that duplicate them.

cargo fmt --check, cargo clippy --workspace --all-targets -D warnings and cargo test --workspace pass.

Add regression tests pinning the isolation contract for the QuickJS
lifecycle investigation: memory-limit and stack-limit recovery across
invocations, interrupt-deadline re-arming after an aborted call,
per-invocation console sink rebinding, a 32-iteration consecutive
invocation sweep, and builtin-intrinsic reset (Object.prototype,
Array.prototype.push, vect, Date.now).

Measurement on Bastion (src/main.opy, zh-CN, 8 warm release runs via
the throwaway opy-compile-prof harness) shows only one JavaScript
invocation per compile: the post-compile hook (~25-50 ms of actual
script evaluation inside JS_Eval). The script macros in
title/title-cn.opy are defined but never expanded. Per-invocation
engine setup is ~0.4-1.6 ms total; of that, JS_NewContext (~54 us) is
inherent to a fresh context per invocation, and only JS_NewRuntime +
JS_FreeRuntime (~27 us) is shareable. A thread-local shared JSRuntime
with fresh JSContext per invocation and a post-teardown JS_RunGC was
implemented and verified byte-identical output (sha256
7f53ffa8cf71f600259d329d780f0fc00933bfcb7414b60cb14ea63606546c54);
warm median moved from ~288 ms to ~292 ms, inside run-to-run spread.
No lifecycle change clears the materiality bar, so production code is
unchanged; the profiling attribution (~45 ms) conflated JS_Eval script
execution with engine setup.

Refs #595
@Teakowa
Teakowa merged commit cd3a758 into main Oct 19, 2026
6 checks passed
@Teakowa
Teakowa deleted the perf/macro-quickjs-setup branch October 19, 2026 12:45
@e54-bot e54-bot mentioned this pull request Oct 19, 2026
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.

2 participants