Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .mocharc.parallel.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ module.exports = {
...base,
bail: false,
timeout: 30000,
// V8's default limit sits above `MARKO_TEST_WORKER_MEM`, so a worker hands its
// slice to a fresh process before collecting; a major GC is the cheaper trade.
"node-option": [...base["node-option"], "max-old-space-size=2048"],
require: [...base.require, "./scripts/test-parallel-worker.cjs"],
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
type: perf
impact: med
effort: high
site: packages/runtime-tags/src/__tests__/utils/bundle.ts › externalRuntimePlugin
---

# Measure optimize sizes without bundling the runtime into every fixture

The optimize dom build re-emits and tree-shakes the whole runtime for every
fixture, because `sizes.json` records minified chunk totals and those totals
only exist if the runtime sits in the chunk. It is the one fixture build that
cannot link the prebuilt runtime as an external, and it dominates what bundling
costs the suite.

Measuring a chunk's shared-runtime share once per process and adding it to the
fixture's own tree-shaken bytes would let that build take the external too.

Check: in `createBuilds`, extend `externalRuntimePlugin` to the optimize dom
build and time `pnpm run test:parallel`; the fixture `sizes.json` assertions are
what fail.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
type: perf
impact: low
effort: high
site: packages/runtime-tags/src/__tests__/utils/create-browser.ts › createBrowser
---

# Pool jsdom windows across fixtures

`createBrowser` builds a fresh `JSDOM` for each of a fixture's ssr and csr runs
and jsdom re-installs every Web IDL class onto the new realm each time, which
is ~10% of the test worker's main-thread inclusive cost. A pool recovers under
3% of wall, though, because the reset it needs is most of the cost it saves,
and the reset is hard to get right: clearing the realm's added globals (the
resume registry is a global named for the runtime id), replacing the document,
dropping the `importWithContext` module cache and cancelling tracked timers
still leaves fixtures reading each other's counters. Worth revisiting only with
a reset that is provably complete, since a leak is a cross-fixture correctness
bug rather than a slow test.

Check: `--cpu-prof` one worker of `node scripts/test-parallel.js` and read the
inclusive cost of `exports.createWindow`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
type: perf
impact: med
effort: high
site: scripts/test-parallel.js › packBins
---

# Schedule test-parallel slices dynamically

`packBins` assigns every slice up front and assumes each costs the same, so a
run finishes when its unluckiest worker does: on four cores the workers land
around 35s, 36s, 38s and 41s, and the last one sets the wall time. The spread
is fixture cost variance, not slicing granularity — raising `SLOT_TOTAL` from
`WORKERS * 16` to `WORKERS * 256` leaves it unchanged, since each worker
already runs ~280 fixtures. Recovering the tail needs workers to claim slices
as they free up rather than owning a fixed set, which the suites' `beforeEach`
skip hook could already express; the hard part is that mocha registers every
suite at load time, so a claim has to be cheap enough to run per suite.

Check: `taskset -c 0-3 node scripts/test-parallel.js` and compare the per-worker
times it prints.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
type: cleanup
impact: low
effort: medium
site: packages/runtime-tags/src/__tests__/utils/capture-console.ts
---

# `captureConsole` records through a process global

The no-argument `captureConsole()` swaps `globalThis.console`, so anything that
logs while a window is open is attributed to whichever fixture happens to be
rendering. Nothing does today — the jsdom path gets its own `virtualConsole`,
the compiler reports through diagnostics, and a fixture's bundles are awaited
before its window opens — but that is a set of separate guarantees rather than
one property, and each new concurrent logger has to rediscover it.

The server render already runs in a `vm` context (`importWithContext`), so it
could take a per-realm `console` the way the jsdom path does, and capture would
stop depending on what else is running.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
type: perf
impact: med
effort: high
site: packages/runtime-tags/src/__tests__/main.test.ts › ssrRunner
---

# Pipeline the next fixture build into the worker's idle time

A `--cpu-prof` of one `test:parallel` worker running `main.test.ts` alone
spends 32% of its wall time in `(idle)`: `createServerRunner` awaits rolldown,
whose work runs on native threads while the JS thread has nothing to do. With
one worker per core the other workers absorb some of that, but the run still
sits at ~80% core utilization, so the gap is the largest remaining bucket.

Building the next mode's (or fixture's) runner one step ahead of the tests that
consume it would overlap that wait with test work. What blocks it is that
`captureConsole()` swaps `globalThis.console`, so a build's compiler output
would land in whichever fixture is rendering (see the capture-console item).

Check: `node --cpu-prof --experimental-vm-modules node_modules/mocha/bin/_mocha
--config .mocharc.parallel.cjs packages/runtime-tags/src/__tests__/main.test.ts`
and read the `(idle)` share of self time.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var tags_child_default = _template("__tests__/components/tags-child.marko", (inp
let pending = Promise.resolve("hi");
_html(`<button id=tags>go</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-child.marko_0");
writeScope($scope0_id, { pending }, "__tests__/components/tags-child.marko", 0, { pending: "2:6" });
_scope($scope0_id, { pending }, "__tests__/components/tags-child.marko", 0, { pending: "2:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var tags_child_default = _template("b", (input) => {
let pending = Promise.resolve("hi");
_html(`<button id=tags>go</button>${_el_resume($scope0_id, "a")}`);
_script($scope0_id, "b0");
writeScope($scope0_id, { b: pending });
_scope($scope0_id, { b: pending });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var tags_child_default = _template("__tests__/components/tags-child.marko", (inp
let count = 0;
_html(`<button id=tags>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-child.marko_0");
writeScope($scope0_id, {
_scope($scope0_id, {
input_data: input.data,
count
}, "__tests__/components/tags-child.marko", 0, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
})
});
_script($scope0_id, "__tests__/template.marko_0");
writeScope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// components/tags-child.marko
var import_vdom = require_vdom();
const $template = "<!><!><!>";
const $walks = "b%c";
const $await_content__value = ($scope, value) => _text($scope["#text/0"], value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var tags_counter_default = _template("__tests__/components/tags-counter.marko",
let count = 0;
_html(`<button id=tags${_attr("data-parent", input.count)}>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-counter.marko_0");
writeScope($scope0_id, { count }, "__tests__/components/tags-counter.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/components/tags-counter.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var tags_counter_default = _template("b", (input) => {
let count = 0;
_html(`<button id=tags${_attr("data-parent", input.count)}>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_script($scope0_id, "b0");
writeScope($scope0_id, { f: count });
_scope($scope0_id, { f: count });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
_html(`<button id=tags>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_dynamic_tag($scope0_id, "#text/2", _marko_template, { count });
_script($scope0_id, "__tests__/template.marko_0");
writeScope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ var template_default = _template("a", (input) => {
_html(`<button id=tags>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_dynamic_tag($scope0_id, "c", _marko_template, { count });
_script($scope0_id, "a0");
writeScope($scope0_id, { d: count });
_scope($scope0_id, { d: count });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
_html(`<button id=tags>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_dynamic_tag($scope0_id, "#text/2", _marko_template, { value: "Hello World" }, 0, 0, 0);
_script($scope0_id, "__tests__/template.marko_0");
writeScope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ var template_default = _template("a", (input) => {
_html(`<button id=tags>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_dynamic_tag($scope0_id, "c", _marko_template, { value: "Hello World" }, 0, 0, 0);
_script($scope0_id, "a0");
writeScope($scope0_id, { d: count });
_scope($scope0_id, { d: count });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
}, "__tests__/template.marko_0/onValueChanged", $scope0_id)
}, 0, 0, 0);
_html(`<div id=tags-api>${_text_resume($scope0_id, "#text/1", received)}</div>`);
writeScope($scope0_id, {}, "__tests__/template.marko", 0);
_scope($scope0_id, {}, "__tests__/template.marko", 0);
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ var template_default = _template("a", (input) => {
}, "a0", $scope0_id)
}, 0, 0, 0);
_html(`<div id=tags-api>${_text_resume($scope0_id, "b", received)}</div>`);
writeScope($scope0_id, {});
_scope($scope0_id, {});
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_counter_default = _template("__tests__/components/tags-counter.marko",
let count = 0;
_html(`<button id=tags${_attr("data-parent", input.count)}>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-counter.marko_0");
writeScope($scope0_id, { count }, "__tests__/components/tags-counter.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/components/tags-counter.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_counter_default = _template("b", (input) => {
let count = 0;
_html(`<button id=tags${_attr("data-parent", input.count)}>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_script($scope0_id, "b0");
writeScope($scope0_id, { f: count });
_scope($scope0_id, { f: count });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var tags_mid_default = _template("__tests__/components/tags-mid.marko", (input)
_html("<span>deep body</span>");
}, $scope0_id));
_script($scope0_id, "__tests__/components/tags-mid.marko_0");
writeScope($scope0_id, { count }, "__tests__/components/tags-mid.marko", 0, { count: "2:6" });
_scope($scope0_id, { count }, "__tests__/components/tags-mid.marko", 0, { count: "2:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var template_default = _template("__tests__/template.marko", (input) => {
_html(`<button id=inc>inc</button>${_el_resume($scope0_id, "#button/0")}<div id=out></div>`);
_script($scope0_id, "__tests__/template.marko_0_greeting#3_count#4");
_script($scope0_id, "__tests__/template.marko_0");
writeScope($scope0_id, {
_scope($scope0_id, {
greeting,
count
}, "__tests__/template.marko", 0, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var template_default = _template("a", (input) => {
_html(`<button id=inc>inc</button>${_el_resume($scope0_id, "a")}<div id=out></div>`);
_script($scope0_id, "a0");
_script($scope0_id, "a1");
writeScope($scope0_id, {
_scope($scope0_id, {
d: greeting,
e: count
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
_dynamic_tag($scope0_id, "#text/2", _marko_template, { count });
_dynamic_tag($scope0_id, "#text/3", _marko_template, { count });
_script($scope0_id, "__tests__/template.marko_0");
writeScope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_scope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ var template_default = _template("a", (input) => {
_dynamic_tag($scope0_id, "c", _marko_template, { count });
_dynamic_tag($scope0_id, "d", _marko_template, { count });
_script($scope0_id, "a0");
writeScope($scope0_id, { e: count });
_scope($scope0_id, { e: count });
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_child_default = _template("__tests__/components/tags-child.marko", (inp
let count = 0;
_html(`<button id=tags>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-child.marko_0");
writeScope($scope0_id, { count }, "__tests__/components/tags-child.marko", 0, { count: "2:6" });
_scope($scope0_id, { count }, "__tests__/components/tags-child.marko", 0, { count: "2:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_child_default = _template("b", (input) => {
let count = 0;
_html(`<button id=tags>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_script($scope0_id, "b0");
writeScope($scope0_id, { c: count });
_scope($scope0_id, { c: count });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_child_default = _template("__tests__/components/tags-child.marko", (inp
let count = 0;
_html(`<button id=tags>${_text_resume($scope0_id, "#text/1", count)}</button>${_el_resume($scope0_id, "#button/0")}`);
_script($scope0_id, "__tests__/components/tags-child.marko_0");
writeScope($scope0_id, { count }, "__tests__/components/tags-child.marko", 0, { count: "2:6" });
_scope($scope0_id, { count }, "__tests__/components/tags-child.marko", 0, { count: "2:6" });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tags_child_default = _template("b", (input) => {
let count = 0;
_html(`<button id=tags>${_text_resume($scope0_id, "b", count)}</button>${_el_resume($scope0_id, "a")}`);
_script($scope0_id, "b0");
writeScope($scope0_id, { c: count });
_scope($scope0_id, { c: count });
_resume_branch($scope0_id);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ var template_default = _template("__tests__/template.marko", (input) => {
_html("Reset");
}, $scope0_id), 0, 0);
_html(`<div id=tags-api>${_text_resume($scope0_id, "#text/1", msg)}</div>`);
writeScope($scope0_id, {}, "__tests__/template.marko", 0);
_scope($scope0_id, {}, "__tests__/template.marko", 0);
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ var template_default = _template("a", (input) => {
_html("Reset");
}, $scope0_id), 0, 0);
_html(`<div id=tags-api>${_text_resume($scope0_id, "b", msg)}</div>`);
writeScope($scope0_id, {});
_scope($scope0_id, {});
_resume_branch($scope0_id);
}, 1);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// v:template.marko.hydrate-6.js
var v_template_marko_hydrate_6_default = () => init$1();
var v_template_marko_hydrate_6_default = () => init();

// v:template.marko.hydrate-5.js
var import_components = require_components();
Expand Down
Loading
Loading