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
bench(net): the interest baseline, re-taken on the composed world path
esengine8391a01b7bc4
diff --git a/bench/replication-interest/README.md b/bench/replication-interest/README.mdindex 726a791da..cc801902f 100644--- a/bench/replication-interest/README.md+++ b/bench/replication-interest/README.md@@ -108,6 +108,33 @@ the full scan entity for entity. The build is 93% of what is left, so anincremental index is worth designing — but it is now a question aboutmaintaining a structure, not about whether locality helps.+## Confirmation on the authoritative world-space path++The numbers above were taken while `defaultPosition` still read the authoring+`position`. It reads the composed `worldPosition` now, and a server composes+before it samples — so the baseline is re-taken on the path that actually ships.+Same point, 100k entities and 32 connections, 1% visible, 1% movement:++| | total | one core | ensure | build | radius | posReads | distTests |+|---|---|---|---|---|---|---|---|+| B | 51,460,116 | **5146%** | 25,597 | — | 51,384,591 | — | 3,200,000 |+| C1 | 1,976,888 | **198%** | 25,683 | 1,810,169 | 89,044 | **100,000** | **83,273** |++C1 was 184% against local positions and is 198% against composed ones: reading a+different field of the same builtin projection, as expected. The ratio holds.++Three things are asserted rather than assumed:++- **The measured path really is the composed one.** Each run builds a child five+ units right of a parent at 100 and refuses to start unless it reads 105.+- **Positions are still read once per snapshot.** `posReads` is 100,000, not+ 100,000 × 32 — routing through the composed field did not turn it back into a+ per-connection read.+- **Composing is O(1) when nothing moved.** With movement at 0%, `ensure` costs+ 144 µs per simulated second — 0.01% of a core — against 25,297 at 1% movement.+ A 176× gap is the epoch gate working: it neither misses an invalidation nor+ invents one.+## What this does not cover- Arms A and B were first measured with position in a script component, whichdiff --git a/bench/replication-interest/arm.mjs b/bench/replication-interest/arm.mjsindex a8c69dd86..34e6745de 100644--- a/bench/replication-interest/arm.mjs+++ b/bench/replication-interest/arm.mjs@@ -51,6 +51,28 @@ const RADIUS = VISIBLE >= 1const R2 = RADIUS * RADIUS;const MOVE_COUNT = Math.round(ENTITIES * MOVEMENT);+// The composed world transforms exist because something asked, not because a+// frame happened. A server asks here, before it samples.+world.ensureTransformsComposed();++// The measured path is the composed one, not a local-space lookalike: a child of+// a parent at 100, five to its right, has to read 105.+{+ const p = world.spawn();+ world.insert(p, ctx.Pos, { position: { x: 100, y: 0, z: 0 } });+ const c = world.spawn();+ world.insert(c, ctx.Pos, { position: { x: 5, y: 0, z: 0 } });+ world.setParent(c, p);+ world.ensureTransformsComposed();+ const composed = world.tryGet(c, ctx.Pos)?.worldPosition?.x;+ if (composed !== 105) {+ process.stderr.write(`sentinel: composed child x = ${composed}, want 105\n`);+ process.exit(1);+ }+ world.despawn(c);+ world.despawn(p);+}+const stats = newStats();const previous = new Map();for (let c = 0; c < CONNECTIONS; c++) previous.set(c, new Set());@@ -64,6 +86,11 @@ let movedTotal = 0;function sampleOnce(measuring) {const t0 = process.hrtime.bigint();+ // What a server does before an interest snapshot. With no transform mutation+ // since the last one this is the epoch comparison and nothing else.+ const et = process.hrtime.bigint();+ world.ensureTransformsComposed();+ if (measuring) stats.ns.ensure += process.hrtime.bigint() - et;const mt = process.hrtime.bigint();const candidates = [...ctx.entities];if (measuring) {diff --git a/bench/replication-interest/workload.mjs b/bench/replication-interest/workload.mjsindex b80f34b85..89e1b8ebb 100644--- a/bench/replication-interest/workload.mjs+++ b/bench/replication-interest/workload.mjs@@ -58,7 +58,7 @@ export function defineComponents(sdk) {export function newStats() {return {ns: {- materialize: 0n, build: 0n, anchor: 0n, radius: 0n, owner: 0n,+ materialize: 0n, ensure: 0n, build: 0n, anchor: 0n, radius: 0n, owner: 0n,enter: 0n, leave: 0n, removeFilter: 0n, dirtyFilter: 0n,},visited: {@@ -117,8 +117,9 @@ export function applyMovement(world, ctx, tick, count) {return moved;}-/** What `defaultPosition` does: a builtin read, then the position field. */-const positionOf = (world, Pos, e) => world.tryGet(e, Pos)?.position ?? null;+/** What the shipped `defaultPosition` does: a builtin read, then the COMPOSED+ * world position — the authority a server now has. */+const positionOf = (world, Pos, e) => world.tryGet(e, Pos)?.worldPosition ?? null;/*** Arm A: exactly what ships. Anchors are found by scanning the whole candidate