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
gate(bench): the drawing-time ratio is a measurement again, not a criterion
yhhe8913a331000
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.ymlindex f1af43953..64fb33cb8 100644--- a/.github/workflows/nightly.yml+++ b/.github/workflows/nightly.yml@@ -71,7 +71,7 @@ jobs:path: build/wasm/wechat/retention-days: 3- # The four criteria that ask what a COMPILED system does on a host with no JIT+ # The three criteria that ask what a COMPILED system does on a host with no JIT# can only be answered against a template — and against THIS branch's, not a# release's: the host is half of what they measure, so answering with a# published binary would be answering about an engine this commit is not.diff --git a/bench/aot-native/README.md b/bench/aot-native/README.mdindex 49086dd3a..a8d80bd12 100644--- a/bench/aot-native/README.md+++ b/bench/aot-native/README.md@@ -206,9 +206,8 @@ different deltas, move different distances, and have no differential between the| `BENCH_SPRITES` | on | `0` drops the `Sprite`, which is most of the idle floor — needed to resolve a compiled system at all || `BENCH_BYSTANDERS` | 0 | extra entities with only a `Transform`, which no query matches: they grow the world without growing the matched set || `BENCH_MIN_RATIO` | 5 | `--gate` only: the ratio a fallback cannot pass |-| `BENCH_RENDER` | off, on under `--gate` | also run the render pair below |+| `BENCH_RENDER` | off | also run the render pair below || `BENCH_RENDER_ENTITIES` | 128000 | the pair's entity count |-| `BENCH_RENDER_MAX_RATIO` | 5 | `--gate` only: how much of the frame the drawing may be || `BENCH_MIN_BUSY` | 0.5 | the share of a frame's span that must be CPU for the span to be about the engine || `BENCH_KEEP` | off | keep the exported apps for poking at |@@ -219,10 +218,10 @@ draws, meshes and triangles — and a frame can honour every one of them while ctwice the CPU it used to, because a count says how many sprites were submitted andnothing says what submitting one cost.-So `--gate` also runs a **pair**: the same scene twice, differing only in whether its+So `BENCH_RENDER=1` runs a **pair**: the same scene twice, differing only in whether itsentities carry a `Sprite`. Both halves hold the same entities and run the same schedule,so the machine and the engine's own per-frame cost sit in the denominator, and only the-numerator carries the drawing. The assertion is the ratio, and the reason is the same one+numerator carries the drawing. The report is the ratio, and the reason is the same onethe AOT ratio has: a millisecond is a fact about the machine that measured it.```@@ -236,10 +235,19 @@ better with more entities — it gets *less of the ratio*. At 32,000 the healthyspanned 2.85–3.01 and a sabotage read 3.90, close enough to overlap. At 128,000 healthyreads 3.65–4.21 and the same sabotage 6.97.-That sabotage is where the ceiling of 5 comes from: submitting every sprite twice, which-is the shape of a per-sprite cost that grew. It takes 59 ns/sprite to 115 and the pair-past the ceiling on both runs, while three healthy runs pass. Both directions, on the-same machine, on the same tree.+That sabotage is where a ceiling of 5 came from: submitting every sprite twice, which+is the shape of a per-sprite cost that grew. It took 59 ns/sprite to 115 and the pair+past the ceiling on both runs, while three healthy runs passed. Both directions, on the+same machine, on the same tree — on one day.++**It was a release criterion until 2026-09-02, and is not one now.** The first run on a+Linux runner read 5.37; the same commit read 5.06 and 5.17 on the machine above, and the+commit that set the ceiling, rebuilt the same day, read 4.78 at the same 120 ns/sprite.+The per-sprite cost had not moved between the two commits; what had moved was the+machine — 59 ns/sprite in August, 120 in September, on identical code — and the healthy+band with it, from 3.65–4.21 to 4.78–5.17, across the ceiling. A ratio whose denominator+is a 4 ms frame is a fact about the machine after all, only a smaller one, and a gate+that flips on the day it is run is not a gate. The pair stays as a measurement.The pair also has to *be* a pair — the half with sprites must draw and the half withoutmust not. Two halves that both drew nothing would read 1.0x and pass, having measureddiff --git a/bench/aot-native/frame-bench.mjs b/bench/aot-native/frame-bench.mjsindex c9970808f..85775c1ea 100644--- a/bench/aot-native/frame-bench.mjs+++ b/bench/aot-native/frame-bench.mjs@@ -26,10 +26,9 @@* `bench/aot-frame/project/src/systems.ts` — one source for both benchmarks, so a* ratio measured here and one measured there are about the same code.*- * The same clock answers a second question under `--gate`: what a frame spends- * DRAWING. Counts bound how much a frame submits and say nothing about what- * submitting it cost, so a pair of scenes differing only in whether they carry a- * `Sprite` puts a ceiling on the time — see the README.+ * The same clock can also say what a frame spends DRAWING: a pair of scenes+ * differing only in whether they carry a `Sprite`, opt-in with BENCH_RENDER=1.+ * Measured and reported, not gated — the README says what was tried and why.** node bench/aot-native/frame-bench.mjs* BENCH_ENTITIES=20000 BENCH_BODIES=thin,heavy node bench/aot-native/frame-bench.mjs@@ -100,20 +99,12 @@ const RENDER_ENTITIES = Number(process.env.BENCH_RENDER_ENTITIES ?? 128000);* holds, and every number in the report is that wait — see MIN_BUSY's uses.*/const MIN_BUSY = Number(process.env.BENCH_MIN_BUSY ?? 0.5);-/** Run the pair. Always under `--gate`; opt in with BENCH_RENDER=1 to explore. */-const RENDER = GATE || process.env.BENCH_RENDER === '1';/**- * How much of the frame the drawing may be — set from a SABOTAGE, not from- * headroom over today. Submitting every sprite twice takes 59 ns/sprite to 109;- * healthy runs read 3.65-4.21 and that one 5.94. A ceiling of 4 was tried at- * 32,000 entities, where the same sabotage read 3.90 and passed.- *- * On a CPU rasterizer the span pays to rasterize the sprites too; the host says- * so (`adapter` in the bench line) and the report repeats it. No ceiling of its- * own: the runner's first reading, 5.37 (2026-09-02), was a regression this GPU- * also shows (5.06 at 122 ns/sprite), which a derived ceiling would have hidden.+ * Run the pair. Opt-in only: it was a release criterion with a 5x ceiling until+ * 2026-09-02, when the SAME code read 4.78 one day and 5.06–5.17 the next on the+ * machine that set it — the pair's ratio moves with the machine, not the engine.*/-const RENDER_MAX_RATIO = Number(process.env.BENCH_RENDER_MAX_RATIO ?? 5);+const RENDER = process.env.BENCH_RENDER === '1';/*** Entities carrying NO component: the size of the WORLD, separated from the size@@ -528,18 +519,12 @@ if (render.drawing && render.holding && !unmeasured(render.drawing) && !unmeasurconst holding = render.holding.cpu.p50;const ratio = drawing / holding;const nsPerSprite = ((drawing - holding) * 1e6) / RENDER_ENTITIES;- // Said, not judged by a rule of its own: a CPU rasterizer pays for the sprites- // inside this span too, and a reading there has to be read as one.+ // A CPU rasterizer pays for the sprites inside this span too; say so.const onCpu = render.drawing.adapter === 'cpu';console.log(`\ndrawing: ${RENDER_ENTITIES} sprites make the frame ${ratio.toFixed(2)}x the one that `+ `only holds them (${holding.toFixed(2)} ms -> ${drawing.toFixed(2)} ms, `+ `${nsPerSprite.toFixed(0)} ns/sprite, ${render.drawing.draws} draw(s)`+ `${onCpu ? ', rasterized on the CPU' : ''})`);- if (GATE && !(ratio <= RENDER_MAX_RATIO)) {- console.error(`✗ drawing: the frame is ${ratio.toFixed(2)}x the one that only holds the same `- + `entities, over the ${RENDER_MAX_RATIO}x ceiling — submitting a sprite got dearer`);- bad++;- }}if (bad > 0) process.exit(1);diff --git a/tools/releaseGate.mjs b/tools/releaseGate.mjsindex 3de662e18..e8000bdcc 100644--- a/tools/releaseGate.mjs+++ b/tools/releaseGate.mjs@@ -143,16 +143,6 @@ export const CRITERIA = [needs: ['bench/aot-native/frame-bench.mjs', 'src/esengine/aot/AotHost.hpp','native/host/bindings/AotBindings.cpp'],},- {- id: 'a-frame-pays-for-what-it-draws',- says: 'the CPU a frame spends drawing is bounded, not only the draws it makes',- // Counts were the only ceiling a frame had: `sprite-scale-cost` and its- // siblings hold draws, meshes and triangles, and a frame can honour all three- // while costing twice the CPU. A same-machine ratio, for the reason above.- answeredBy: 'node bench/aot-native/frame-bench.mjs --gate',- needs: ['bench/aot-native/frame-bench.mjs', 'native/host/Bench.cpp',- 'src/esengine/renderer/plugins/SpritePlugin.cpp'],- },{id: 'compiled-systems-compute-what-the-interpreter-computes',says: 'a packaged compiled system moves the world exactly as the interpreted one does',