A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
perf(gate): the release list answers in a quarter of the time, and the flagship walks in seconds
yhh62f10b539c57
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.ymlindex 64fb33cb8..14ceda27a 100644--- a/.github/workflows/nightly.yml+++ b/.github/workflows/nightly.yml@@ -135,21 +135,39 @@ jobs:path: native-template-linux.tgzretention-days: 3- # 27 of the 31. The runner names the four it cannot answer from here and the+ # 26 of the 33. The runner names the ones it cannot answer from here and the# four nobody can automate, so a green job is never read as a green release.+ #+ # One job per SHARD of the list, not one job for the list: run in a row the+ # 26 took 94 minutes, and 73 of those were two criteria. A shard is whole by+ # command (naming golden-packages takes the verify-golden run and every+ # criterion it answers), and `--except` takes what the named shards did not,+ # so a criterion added tomorrow runs in `rest` rather than nowhere.linux:- name: Exit criteria (linux)+ name: Exit criteria (linux, ${{ matrix.shard }})runs-on: ubuntu-latestneeds: [build-emscripten, linux-template]- # A template that failed to build costs four criteria, not twenty-seven: they+ # A template that failed to build costs three criteria, not twenty-six: they# report a machine that cannot answer, and the rest of the list still does.if: always() && needs.build-emscripten.result == 'success'+ strategy:+ fail-fast: false+ matrix:+ include:+ - shard: flagship+ criteria: --only flagship-plays-through+ - shard: golden+ criteria: --only golden-packages+ - shard: perf+ criteria: --only performance-ceilings+ - shard: static+ criteria: --only static-gates+ - shard: rest+ criteria: --except flagship-plays-through,golden-packages,performance-ceilings,static-gatesenv:ESTELLA_NATIVE_TEMPLATES: ${{ github.workspace }}/.native-templates- # 90 was measured against criteria that failed in seconds. Answering them- # costs what the work costs: golden alone is 32 minutes, and the run that- # first got this far was cut at 90 with the flagship still going.- timeout-minutes: 150+ # The longest shard is golden at about a quarter of an hour.+ timeout-minutes: 60steps:# verify-legacy reads examples out of RELEASE TAGS (git archive v0.20.0 …),@@ -219,7 +237,7 @@ jobs:libasound2-dev libpulse-dev libfontconfig1-dev libcurl4-openssl-dev- name: Run the exit criteria- run: node tools/run-release-gate.mjs --host linux+ run: node tools/run-release-gate.mjs --host linux ${{ matrix.criteria }}# every-pixel-gate-runs, whose second half needs a GPU: a Linux runner ships no# graphics driver and every webgpu run there died in requestDevice. Thediff --git a/tools/launchers/play-through.mjs b/tools/launchers/play-through.mjsindex 4c102319a..0860c6e4e 100644--- a/tools/launchers/play-through.mjs+++ b/tools/launchers/play-through.mjs@@ -166,7 +166,16 @@ async function main() {});await win.loadURL(base);- const exec = (js) => win.webContents.executeJavaScript(js);+ // Where the wall time goes, by what was asked of the page: a route that+ // takes 40 minutes on a runner is a driver question before it is an engine one.+ const spentOn = { probe: [0, 0], step: [0, 0], path: [0, 0], other: [0, 0] };+ const exec = (js, kind = 'other') => {+ const t = performance.now();+ return win.webContents.executeJavaScript(js).finally(() => {+ spentOn[kind][0] += performance.now() - t;+ spentOn[kind][1]++;+ });+ };// The handle appears as soon as the host builds it, which is before the first// scene has spawned anything — asking then is asking an empty world.@@ -200,13 +209,11 @@ async function main() {return;}- // Read on a frame boundary. Poked from outside the loop, a read can land- // between the systems that despawn something and the ones that replace it,- // and every such read is a world nobody was ever in.- const probe = (names) => exec(- `new Promise((r) => requestAnimationFrame(() => r(window.__estellaCooked.probe(${JSON.stringify(names)}))))`,- );- const pathTo = (goal) => exec(`window.__estellaCooked.pathBetween("Lyra_Player", ${JSON.stringify(goal)})`);+ // Read where `step` left the world: it resolves on a frame boundary, and the+ // driver holds the clock. Waiting for requestAnimationFrame first cost a+ // second per read in a hidden window — 407 s of a 412 s walk whose steps took 3.+ const probe = (names) => exec(`window.__estellaCooked.probe(${JSON.stringify(names)})`, 'probe');+ const pathTo = (goal) => exec(`window.__estellaCooked.pathBetween("Lyra_Player", ${JSON.stringify(goal)})`, 'path');// Every goal the route names, before a step is taken: a leg whose goal never// existed would otherwise report as "already done" and the run would fail// later, somewhere else, for a reason that is not the reason.@@ -262,7 +269,7 @@ async function main() {while (spent < timeout && frames < BUDGET && waited < WAIT_CAP) {const state = await probe([leg.goal, 'Lyra_Player']);// Nothing is true about a world that is halfway through being replaced.- if (state.transitioning) { await exec(stepScript([], STEP, null)); waited += STEP; frames += STEP; continue; }+ if (state.transitioning) { await exec(stepScript([], STEP, null), 'step'); waited += STEP; frames += STEP; continue; }if (state.scene === leg.area) sawArea = true;// The leg is over when the area it was aiming for has been left behind:// walking into a door IS the arrival, and the door is gone by the time@@ -280,7 +287,7 @@ async function main() {// it costs the run a pickup it never took.let gone = true;for (let i = 0; i < 3 && gone; i++) {- await exec(stepScript([], 4, null));+ await exec(stepScript([], 4, null), 'step');spent += 4;frames += 4;gone = !(await probe([leg.goal])).at[leg.goal];@@ -325,10 +332,10 @@ async function main() {console.log(` ${label} @${spent}: at ${Math.round(me.x)},${Math.round(me.y)} `+ `aim ${Math.round(aim.x)},${Math.round(aim.y)} (${plan.length} waypoints) keys ${keys.join('+') || 'none'} gap ${Math.round(gap)}`);}- await exec(stepScript(keys, STEP, leg.swing ? 'Space' : null));+ await exec(stepScript(keys, STEP, leg.swing ? 'Space' : null), 'step');} else {// Between areas: the next scene has not handed out its entities yet.- await exec(stepScript([], STEP, null));+ await exec(stepScript([], STEP, null), 'step');waited += STEP;frames += STEP;continue;@@ -358,6 +365,8 @@ async function main() {console.log(`${ok ? '✓' : '✗'} ${path.basename(DIR)} — ${done.length}/${route.legs.length} legs, `+ `${frames} frames, ended in ${final.scene ?? '(nothing)'}, errors=${errors.length}`);if (failure) console.log(` ${failure}`);+ const secs = (k) => `${(spentOn[k][0] / 1000).toFixed(0)}s/${spentOn[k][1]}`;+ console.log(` wall: step ${secs('step')}, probe ${secs('probe')}, path ${secs('path')}, other ${secs('other')}`);for (const e of errors.slice(0, 5)) console.log(` ${e}`);app.exit(ok ? 0 : 1);}diff --git a/tools/releaseGate.mjs b/tools/releaseGate.mjsindex e8000bdcc..b4f3f7c25 100644--- a/tools/releaseGate.mjs+++ b/tools/releaseGate.mjs@@ -42,20 +42,20 @@ export const CRITERIA = [{id: 'golden-packages',says: 'every golden project packages and launches on every target it declares',- answeredBy: 'node tools/verify-golden.mjs --tier release',+ answeredBy: 'node tools/verify-golden.mjs --tier release --jobs 3',needs: ['tools/verify-golden.mjs', 'tools/goldenProjects.mjs','tools/launchers/launch-export.mjs', 'tools/launchers/launch-minigame.mjs'],},{id: 'package-matches-editor',says: 'a packaged game shows what the editor showed',- answeredBy: 'node tools/verify-golden.mjs --tier release',+ answeredBy: 'node tools/verify-golden.mjs --tier release --jobs 3',needs: ['tools/frameCompare.mjs'],},{id: 'package-answers-input',says: 'a packaged game visibly answers the input its project declares',- answeredBy: 'node tools/verify-golden.mjs --tier release',+ answeredBy: 'node tools/verify-golden.mjs --tier release --jobs 3',needs: ['tools/launchers/inputScript.mjs'],},{diff --git a/tools/run-release-gate.mjs b/tools/run-release-gate.mjsindex 4255ee4b4..f0609c7ae 100644--- a/tools/run-release-gate.mjs+++ b/tools/run-release-gate.mjs@@ -16,6 +16,7 @@* node tools/run-release-gate.mjs # run them* node tools/run-release-gate.mjs --plan # what would run, and what cannot* node tools/run-release-gate.mjs --only golden,aot+ * node tools/run-release-gate.mjs --except flagship,golden # the rest*/import { spawnSync } from 'node:child_process';import path from 'node:path';@@ -29,14 +30,25 @@ const flag = (name) => {return i >= 0 ? argv[i + 1] : null;};const ONLY = flag('only')?.split(',').map((s) => s.trim()).filter(Boolean) ?? null;+// The complement, for the shard that takes everything the named ones did not:+// a criterion added tomorrow lands here rather than in no job at all.+const EXCEPT = flag('except')?.split(',').map((s) => s.trim()).filter(Boolean) ?? null;// Where this runner is standing. A criterion says which host can answer it; the// default is a plain Linux runner, which is 27 of the 31.const HOST = flag('host') ?? 'linux';const runnable = CRITERIA.filter((c) => c.answeredBy);+// Whole by COMMAND: five criteria share one verify-golden run, and naming one+// of them names the run — a shard that took the command answers all five, and+// the shard that left it out answers none of them.+const commandsOf = (names) => new Set(runnable+ .filter((c) => names.some((o) => c.id.includes(o))).map((c) => c.answeredBy));+const taken = ONLY ? commandsOf(ONLY) : null;+const left = EXCEPT ? commandsOf(EXCEPT) : null;const automated = runnable.filter((c) => (c.host ?? 'linux') === HOST)- .filter((c) => !ONLY || ONLY.some((o) => c.id.includes(o)));+ .filter((c) => !taken || taken.has(c.answeredBy))+ .filter((c) => !left || !left.has(c.answeredBy));/** Answerable, but not from here — named below, never silently absent. */const elsewhere = runnable.filter((c) => (c.host ?? 'linux') !== HOST);const manual = CRITERIA.filter((c) => c.manual);@@ -55,7 +67,8 @@ for (const c of automated) {}console.log(`release gate ${RELEASE}: ${automated.length} criteria in ${jobs.length} command(s)`- + ` on host ${HOST}` + (ONLY ? ` (--only ${ONLY.join(',')})` : ''));+ + ` on host ${HOST}` + (ONLY ? ` (--only ${ONLY.join(',')})` : '')+ + (EXCEPT ? ` (--except ${EXCEPT.join(',')})` : ''));if (argv.includes('--plan')) {for (const j of jobs) console.log(` ${j.ids.join(', ')}\n ${j.run}`);diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjsindex 9793455f9..3e700f6e7 100644--- a/tools/verify-golden.mjs+++ b/tools/verify-golden.mjs@@ -16,7 +16,8 @@* node tools/verify-golden.mjs --tier nightly --only platformer,spine-demo* node tools/verify-golden.mjs --tier pr --shots <dir>*/-import { spawnSync } from 'node:child_process';+import { spawn, spawnSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';import { mkdirSync, rmSync, readFileSync, existsSync } from 'node:fs';import path from 'node:path';import { atTier, projectDir, parityFor, interactFor, audioFor, suspendFor, safeAreaFor, atlasFor, webPixels, launchTimeoutFor, ROOT } from './goldenProjects.mjs';@@ -68,6 +69,52 @@ const deferred = projects.flatMap((g) => g.targets.filter((t) => !OWNED.has(t)).console.log(`golden ${TIER}: ${projects.length} project(s), ${pairs.length} pair(s) here`+ (deferred.length ? `, ${deferred.length} left to the platform verifiers` : ''));+/**+ * `--jobs N`: the projects, N at a time, each worker this script over its share.+ * The release tier's seventeen took 33 minutes in a row with three cores idle.+ * A project stays whole (a worker's `--only` is by id); shares are balanced by+ * what a project asks for, not by count — celestial-heights alone is a third.+ */+const JOBS = Math.max(1, Number(flag('jobs', '1')) || 1);+if (JOBS > 1 && !argv.includes('--worker') && projects.length > 1) {+ const weight = (g) => g.targets.filter((t) => OWNED.has(t)).length+ * (1 + [interactFor(g), audioFor(g), safeAreaFor(g), atlasFor(g)].filter(Boolean).length + (suspendFor(g) ? 3 : 0));+ const bins = Array.from({ length: Math.min(JOBS, projects.length) }, () => ({ ids: [], load: 0 }));+ for (const g of [...projects].sort((a, b) => weight(b) - weight(a))) {+ const bin = bins.reduce((least, b) => (b.load < least.load ? b : least));+ bin.ids.push(g.id);+ bin.load += weight(g);+ }+ const own = new Set(['--only', '--jobs']);+ const passthrough = argv.filter((a, i) => !own.has(a) && !own.has(argv[i - 1]));+ const outcomes = await Promise.all(bins.map((bin, i) => new Promise((resolve) => {+ const tag = `[${i + 1}/${bins.length}]`;+ const child = spawn(process.execPath,+ [fileURLToPath(import.meta.url), ...passthrough, '--worker', '--only', bin.ids.join(',')],+ { cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'] });+ // Relayed as they come, tagged: a worker's line is only readable if it says+ // whose it is, and a runner staring at nothing for ten minutes kills the job.+ let rest = '';+ const relay = (chunk) => {+ rest += chunk;+ const lines = rest.split('\n');+ rest = lines.pop();+ for (const l of lines) console.log(`${tag} ${l}`);+ };+ child.stdout.on('data', relay);+ child.stderr.on('data', relay);+ child.on('close', (code) => {+ if (rest) console.log(`${tag} ${rest}`);+ resolve({ tag, code, ids: bin.ids });+ });+ })));+ const failed = outcomes.filter((o) => o.code !== 0);+ console.log(`\ngolden ${TIER}: ${bins.length} worker(s) over ${projects.length} project(s) — `+ + (failed.length ? `${failed.length} did not pass` : 'all packaged and launched'));+ for (const f of failed) console.log(` ✗ ${f.tag} exit ${f.code}: ${f.ids.join(', ')}`);+ process.exit(failed.length ? 1 : 0);+}+/** What the project declares: the shape it is authored for, and the scene a* package will ship as its entry. */function manifestOf(id) {