# Entity poses: priority accumulator, batched quantised deltas, per-entity delay Round `net-batch`, 2026-10-27: step (b) of `docs/net-entity.md` §10, plus the owner's per-entity display delay. Scratch, scripts and raw runs: `logs/net-batch/` (`runs/`, `an/`, `owner/`). ## Answer - **Built** (branch `net-batch`): one `EntityPoses` message per look tick per session, quantised (1/32 v, smallest-three rotation) and delta-coded against the last pose sent to that session (`common/src/pose-codec.ts`); a priority accumulator under a per-session byte budget (`server/src/net/pose-sync.ts`); and a per-entity display delay, a shared jitter term plus the entity's own interval term (`client/src/net/entity-interp.ts`). - **Deleted:** `EntityPos` (one 49/53-byte message per entity), the 30 / 10 / 1 Hz pose distance bands and `posBroadcastNextMs`, the outbox's 48-message cap (`DEFAULT_OUTGOING_BUDGET`; the outbox now carries only `core/look`, under the same byte budget), the byte-exact `posLastSent` dedupe, and the interpolator's steady-stream vote rule (`NEED_GAP_MAX_MS`) with its single shared delay. Look messages (`core/look`) are unchanged: folding them in would not be simpler (they have their own settle/deadband logic and are few). - **Bytes:** 51 B per update → **5.3–7.7 B** (pile-huge 5.9–6.4, island 7.1–7.7, live, including the header and the WebSocket frame). Pile-huge sends **2.8–4.2 k updates/s instead of 0.8–1.3 k** for **⅓–½ of the bytes** (17–24 KiB/s mean against 38–66). - **Rate:** moving pile bodies get a one-tick median gap and p95 **70–190 ms** at every distance, instead of p95 215–435 ms (near and mid, the cap) and ~1000 ms (far, 1 Hz); island far bodies go from 1 Hz to 30 Hz. Far bodies' frozen frames **39–58 % → 0–16 %**, their step error **2.1–4.4 → 0.2–2.8**. - **Near-body delay** (the owner's per-entity delay): the roller **118 → 60 ms** on the LAN, 147 → 106 at 40 ms / 1 %, 221 → 195 at 100 ms / 2 %; pile-huge near bodies 162–178 → 104–134 ms. - **CPU:** server look tick (entity state, pile-huge, two sessions) p50 1.9 → 1.1 ms, p99 5.0 → 4.3–4.8; client interpolation unchanged (0.03–0.06 ms/frame p50) plus 1.5–2.1 ms/s of decoding. - **Touching bodies render at different times:** median 1–16 ms apart, p95 40–113 ms, p99 90–233 ms (§5.6). - **Owner decisions (§7):** the budget (0.5 vs 1.0 Mbit/s; provisional 1.0), rotation bits (10 vs 12; provisional 12), the interval term's slew rates, and the local-sim lane's transitions (§6). ## 1. Step 1: how much do mid-band bodies inflate the near delay? (main e50ca77c) **Question.** Step a's interpolator has one playback clock: every entity renders at `server time − D`, D the p99 of every sample's needed delay (lateness + its gap). The 10 Hz mid band votes ~100 ms gaps, so D covers them; does that make near (30 Hz) bodies wait for the mid band? **Method.** - Server: main e50ca77c plus the throwaway trace (branch `net-entity` 63db5d18, cherry-picked onto a detached worktree `net-batch-base`, not pushed), fresh per run. - Network: a private veth pair (`logs/net-batch/netns.sh`): the server runs in its own network namespace, the headless recorders (`scripts/net-entity/entclient.ts`, 60–75 s) on the host. netem on both ends, delay and jitter per direction, loss on the server→client side, a pfifo child (no reordering), offloads off (MTU-size packets). No shared interface or sysctl was touched. Conditions: **LAN** (no netem) and **40 ms ±10, 1 %** (20 ± 5 ms each way, 1 % loss). - Scenes: `surface-gi-motion` with the viewer at the roller (226, 120, 60); `pile-huge` with a viewer at spawn (0, 200, −400, no body within 96 v) and one at the pile's edge (0, 100, −200). - Votes: every sample's needed delay, computed exactly as `EntityInterp.push` does (only a steady stream votes: gap and previous gap ≤ 250 ms), labelled by the band of the body at that sample (distance to the viewer: near < 96 v, mid < 384 v, far). From 15 s. - Chosen delay: the recorded arrivals replayed through main's real `EntityInterp` at 60 Hz frames, once with every sample and once with only near-band samples (the counterfactual "only near bodies moving": same near arrivals, mid and far withheld). `logs/net-batch/an/step1.ts`. **Votes per band (ms, p50 / p95 / p99; bodies that moved; votes).** | run | near | mid | far | all p99 | |---|---|---|---|---| | roller, LAN | 48 / 53 / 99 (1 body, 702) | 115 / 120 / 122 (2, 666) | no votes (1) | 121 | | roller, 40 ms / 1 % | 51 / 61 / 109 (1, 1181) | 117 / 134 / 167 (2, 503) | no votes (1) | 149 | | pile-huge spawn, LAN | — (0) | 109 / 141 / 188 (107, 30 273) | 14 votes (258) | 188 | | pile-huge spawn, 40 ms / 1 % | — (0) | 122 / 182 / 218 (82, 33 054) | 5 votes (225) | 218 | | pile-huge edge, LAN | 43 / 74 / 150 (12, 11 307) | 109 / 138 / 158 (170, 53 800) | 8 votes (180) | 156 | | pile-huge edge, 40 ms / 1 % | 60 / 141 / 185 (6, 5 138) | 123 / 177 / 201 (139, 61 777) | 8 votes (168) | 199 | **Chosen delay (ms, p5 / p50 / p95 over the run from 15 s).** | run | all bodies (today) | near bodies only | inflation (p50) | |---|---|---|---| | roller, LAN | 116 / 119 / 122 | 50 / 52 / 59 (the 50 ms floor) | **+67 ms** | | roller, 40 ms / 1 % | 125 / 150 / 184 | 73 / 106 / 186 | **+44 ms** | | pile-huge edge, LAN | 138 / 152 / 221 | 136 / 150 / 204 | +2 ms | | pile-huge edge, 40 ms / 1 % | 180 / 197 / 240 | 144 / 166 / 450 | +31 ms | **Finding.** - **In a light scene the mid band sets the near delay.** The roller's own stream needs ~52 ms on the LAN (it sits on the 50 ms floor) and ~106 ms at 40 ms / 1 %; the mid band's 100 ms gaps lift the shared delay to 119 / 150 ms. The near body is rendered 44–67 ms later than its own stream needs: more than the network itself costs at 40 ms RTT. - **In a busy scene the near bodies are starved too.** At pile-huge the 48-message cap holds near-band bodies to mid-band rates (near votes p99 150–185 ms), so near-only would choose ~the same delay (150 vs 152 on the LAN). The bands are not what sets the delay there; the cap is. That is rate, which the accumulator below addresses. - Far bodies (1 Hz) do not vote (the 250 ms steady-stream rule), so they never inflate the delay; they hold and catch up instead. - So a delay split into a shared jitter term and a per-entity interval term (§2.3) buys the near body ~45–65 ms on a light scene at the same smoothness, and nothing by itself in a starved busy scene until the rate problem is fixed. ## 2. What changed ### 2.1 Wire (`common/src/pose-codec.ts`) `[type 0x93][stampMs u32][rotBits u8][count varint]`, then per entity, ids ascending: `[idDelta varint][flags u8]` and - a **key** record (no baseline: scope entry, reconnect): three zigzag varints of the absolute position at 1/32 v and a packed rotation; - or a **delta**: the changed position axes as zigzag varints (flag bits per axis), and, if the rotation changed, its three component deltas (same largest index) or the packed rotation, whichever is smaller; - `STAMP`: header stamp − this pose's stamp (ms), when it differs; - `HELD`: stamp − `heldUntilMs`, on the first pose after a rest the session saw (the wake semantics of step a, kept). Smallest-three: the largest component's index (2 bits) and the other three at `rotBits` bits over [−1/√2, 1/√2]; 4 bytes packed at 10 bits, 5 at 12. The quantised integers are the pose: the server compares them to dedupe and codes the next delta from them, the client renders exactly their dequantisation (`dequantizePose`), and a record's baseline is committed only when the socket accepted the message (TCP: sent = acked). Positions are absolute integers (exact to 2^53), so world scale costs nothing. ### 2.2 Server: priority accumulator (`server/src/net/pose-sync.ts`) - Every non-static entity is quantised once per tick (`PoseFrame`). Per session, an in-scope entity whose quantised pose differs from its baseline is a candidate; an unchanged one costs nothing. - **Priority** (physical only): `(radius + 8) / max(distance, 32)` × a boost `1 + 4·e^(−age/0.5 s)` since the body's last event: woke from a rest, a contact-tap impact within 32 v, held by the drag tool, or any player's avatar within touching distance. The boost decays: no step. - **Accumulator:** a candidate's accumulated priority grows by priority × tick seconds; candidates go in descending order until the first that does not fit, and a sent one restarts from zero. An unsent body keeps accumulating: nothing starves. - **Budget:** a token bucket per session at `STATE_BUDGET_MBIT` (message bytes; banks two ticks). The look flush spends first, the pose batch takes the rest. - Unconstrained, every changed pose goes every tick. Constrained, a body's rate is proportional to its priority: smooth in distance (§5.5). ### 2.3 Client: per-entity delay (`client/src/net/entity-interp.ts`) - **Shared jitter term J:** each batch votes `(arrival + O) − header stamp`, O the server-time estimate (max of stamp − arrival over 2 s); J = p99 over 2 s, clamped to [0, 300] ms. All poses share one socket, so this is measured across all of them. - **Per-entity interval term I_e:** the longest of the entity's last 8 gaps between samples. A gap counts only if the body moved > 0.1 v at > 1 v/s across it: the server sends a pose only when its quantised value changes, so a creeping body arrives with long, nearly motionless gaps; counting them gave near pile bodies 210 ms delays and put touching bodies 0.5–0.9 s apart (first measurement, fixed before the tables). - Each entity renders at `server time − (J + I_e)`, total clamped to [50, 1000] ms. J moves by the shared clock's time scaling (≤ 5 % slow, ≤ 2 % fast) as before; each I_e moves toward its target at the same bounds. So an entity's render time is continuous with a rate in [0.90, 1.04], and a body coming nearer or going farther changes its delay gradually (2 % of real time when shrinking: 100 ms takes 5 s). - Far bodies sent at a few Hz now interpolate instead of holding and catching up; beyond 1000 ms intervals they still hold. ## 3. Method (step 5) - **Builds:** main e50ca77c + the throwaway trace (detached worktree `net-batch-base`, not pushed) against `net-batch` + the same trace (branch `net-batch-meas`: the merge branch plus measurement commits marked NOT FOR MERGE; the recorder decodes `EntityPoses`, and an `ltd` trace row times the look tick's entity-state work). - **Network:** §1's private netns veth (server in the namespace, recorders on the host), LAN, **40 ms ±10, 1 %** and **100 ms ±10, 2 %** (50 ± 5 ms each way, 2 % loss server→client). CUBIC, nazrin's defaults; no sysctl touched. - **Scenes and viewers:** pile-huge with two sessions (spawn (0, 200, −400) and edge (0, 100, −200)); realistic-island-16 with one viewer over an island (−320, 80, −380); surface-gi-motion at the roller. 75 s per run (60 s roller). - **Variants:** main; `STATE_BUDGET_MBIT` 1.0 and 0.5 at 12-bit rotations in every condition; 10-bit rotations at both budgets on the LAN. A second LAN repetition of main, 1.0 and 0.5 on pile-huge. - **Scores** (`logs/net-batch/an/score.ts`): the recorded arrivals replayed at 60 Hz through the real interpolator of the build that made them; step error (RMS per-frame motion error / mean per-frame motion) and frozen frames against the server's per-step truth on the wire's stamps, per body, for up to 40 moving bodies per distance bin (band by the body's median distance: near < 96 v, mid < 384 v, far); the delay column is the interpolator's own delay for that body (main: the shared delay). Pile and island from 6 s (the collapse is the motion), roller from 15 s, 100 ms / 2 % from 25 s (the region-stream cold start holds realtime state 2–7 s old for the first 5–20 s on CUBIC, differently each run; `docs/net-latency.md` §3). - **Intervals:** client arrival gaps of one body across which it moved > 0.1 v at > 1 v/s (a sub-quantum creep is not a starved stream). - **Noise:** pile-huge is chaotic and its live run differs every time. Step error moves by ±0.5–1.0 between repetitions of the same build (main 1.3–2.8 mid, branch 1.0–2.5): read motion columns as ranges, not rankings between the two budgets. ## 4. Step-1 question, answered by the split delay | scene, condition | main: shared delay p50 | branch: the near body's delay | near body, branch: step error / frozen | |---|---|---|---| | roller, LAN | 118 | **60** | 0.15 → 0.10 / 0 % | | roller, 40 ms / 1 % | 147 | **106** | 0.18 → 0.18 / 0 % | | roller, 100 ms / 2 % | 221 | **195** | 0.19 → 0.22 / 1 % | | pile-huge edge, LAN (2 runs) | 162 / 178 | **119 / 134** (1.0), 104–106 (0.5) | 2.7 / 1.7 → 1.9 / 2.8 (1.0), 1.0 / 1.9 (0.5) | | pile-huge edge, 40 ms / 1 % | 204 | **146** (1.0), 154 (0.5) | 2.1 → 1.9 / 1.8 | On a clean link the near body now waits for its own stream (one tick plus jitter, the 50 ms floor + ~10), not for the mid band; under loss the shared jitter term dominates and the gain shrinks to 25–40 ms. ## 5. Measurements: main vs branch Cells "a / b / c" are p50 / p95 / p99 unless stated. Motion cells: step error / frozen frames / the interpolator's delay (ms). ### 5.1 pile-huge, edge viewer (two sessions on the server) Columns: pose bytes on the wire per second (mean, p95 and max of 1 s windows; + 2 B WebSocket header per frame); pose updates received per second; bytes per update; moving-body intervals by band; motion by band; the offset between touching bodies' delays (§5.5); the server look tick's entity-state CPU (`tickLooks` + look flush + `tickPositions`, both sessions). | condition | variant | pose KiB/s mean (p95, max) | updates/s | B/update | interval near / mid / far p50/p95/p99 ms | near: step err / frozen / delay | mid | far | contact offset p50/p95/p99 ms | server tick ms p50/p99 | |---|---|---|---|---|---|---|---|---|---|---| | LAN | main | 63.9 (70.6, 71.8) | 1280 | 51.1 | 38 / 215 / 385 · 101 / 272 / 383 · 997 / 1021 / 1034 | 2.70 / 6 % / 162 | 2.76 / 8 % / 162 | 2.92 / 39 % / 162 | — | 1.94 / 5.05 | | LAN | 1.0 Mbit/s | 19.4 (70.0, 77.3) | 3191 | 6.2 | 35 / 100 / 167 · 34 / 102 / 175 · 35 / 103 / 175 | 1.93 / 6 % / 119 | 1.46 / 9 % / 95 | 1.62 / 10 % / 92 | 7 / 100 / 228 | 1.10 / 4.34 | | LAN | 0.5 Mbit/s | 23.6 (59.9, 63.7) | 4090 | 5.9 | 34 / 86 / 139 · 34 / 87 / 151 · 35 / 106 / 151 | 0.99 / 8 % / 106 | 0.95 / 6 % / 102 | 1.00 / 7 % / 105 | 16 / 96 / 184 | 1.18 / 4.79 | | LAN | main (rep 2) | 65.9 (71.4, 73.7) | 1322 | 51.1 | 101 / 305 / 352 · 102 / 247 / 364 · 1000 / 1018 / 1024 | 1.69 / 3 % / 178 | 1.68 / 7 % / 178 | 3.85 / 41 % / 178 | — | 2.01 / 6.13 | | LAN | 1.0 Mbit/s (rep 2) | 22.7 (45.4, 51.2) | 3708 | 6.3 | 64 / 193 / 241 · 56 / 190 / 241 · 47 / 191 / 241 | 2.79 / 11 % / 134 | 2.47 / 15 % / 120 | 2.77 / 15 % / 114 | 1 / 67 / 151 | 1.24 / 10.57 | | LAN | 0.5 Mbit/s (rep 2) | 19.3 (59.6, 62.5) | 3290 | 6.0 | 34 / 72 / 139 · 35 / 114 / 162 · 35 / 139 / 173 | 1.87 / 6 % / 104 | 1.36 / 10 % / 102 | 1.32 / 9 % / 109 | 16 / 98 / 227 | 1.18 / 4.46 | | 40 ms ±10, 1 % | main | 65.4 (70.8, 74.1) | 1312 | 51.1 | 111 / 276 / 373 · 108 / 292 / 389 · 1002 / 1043 / 1073 | 2.06 / 4 % / 204 | 1.62 / 9 % / 204 | 2.90 / 43 % / 204 | — | 1.57 / 4.94 | | 40 ms ±10, 1 % | 1.0 Mbit/s | 17.3 (66.1, 80.3) | 2776 | 6.4 | 36 / 106 / 196 · 36 / 107 / 196 · 36 / 107 / 196 | 1.86 / 9 % / 146 | 1.42 / 12 % / 146 | 1.49 / 12 % / 146 | 2 / 66 / 128 | 0.99 / 4.58 | | 40 ms ±10, 1 % | 0.5 Mbit/s | 18.7 (59.3, 62.2) | 3098 | 6.2 | 35 / 116 / 170 · 35 / 126 / 170 · 36 / 136 / 185 | 1.81 / 8 % / 154 | 1.23 / 10 % / 147 | 1.56 / 9 % / 150 | 16 / 113 / 233 | 1.06 / 5.33 | | 100 ms ±10, 2 % | main | 61.1 (72.0, 97.9) | 1225 | 51.1 | 56 / 175 / 189 · 97 / 169 / 237 · 998 / 1126 / 1447 | — | 0.23 / 0 % / 275 | 3.44 / 58 % / 275 | — | 1.46 / 2.37 | | 100 ms ±10, 2 % | 1.0 Mbit/s | 17.6 (21.4, 22.8) | 3421 | 5.3 | 31 / 108 / 156 · 33 / 70 / 160 · 32 / 68 / 160 | — | 0.18 / 1 % / 201 | 0.26 / 4 % / 201 | 16 / 84 / 196 | 1.09 / 2.85 | | 100 ms ±10, 2 % | 0.5 Mbit/s | 11.9 (17.2, 19.4) | 2299 | 5.3 | 33 / 66 / 159 · 32 / 73 / 165 · 32 / 73 / 159 | 0.10 / 1 % / 229 | 0.15 / 1 % / 229 | 0.33 / 1 % / 224 | 16 / 69 / 150 | 1.00 / 2.11 | ### 5.2 pile-huge, spawn viewer (no body within 96 v) | condition | variant | pose KiB/s mean (p95, max) | updates/s | B/update | interval near / mid / far p50/p95/p99 ms | near: step err / frozen / delay | mid | far | contact offset p50/p95/p99 ms | server tick ms p50/p99 | |---|---|---|---|---|---|---|---|---|---|---| | LAN | main | 40.2 (62.8, 70.3) | 805 | 51.2 | 102 / 364 / 386 · 101 / 242 / 382 · 999 / 1027 / 1037 | — | 1.34 / 12 % / 174 | 3.29 / 44 % / 174 | — | 1.94 / 4.88 | | LAN | 1.0 Mbit/s | 19.3 (68.0, 77.4) | 3189 | 6.2 | 43 / 102 / 150 · 35 / 78 / 139 · 35 / 77 / 139 | — | 1.03 / 8 % / 92 | 1.25 / 9 % / 92 | 9 / 101 / 233 | 1.10 / 4.10 | | LAN | 0.5 Mbit/s | 23.6 (59.4, 62.8) | 4085 | 5.9 | 47 / 141 / 150 · 34 / 102 / 141 · 35 / 109 / 150 | — | 1.40 / 10 % / 107 | 1.42 / 8 % / 111 | 16 / 95 / 183 | 1.18 / 4.79 | | LAN | main (rep 2) | 44.6 (67.8, 70.2) | 892 | 51.2 | 111 / 371 / 380 · 101 / 271 / 371 · 1000 / 1017 / 1026 | — | 2.19 / 12 % / 181 | 4.38 / 42 % / 181 | — | 2.01 / 6.13 | | LAN | 1.0 Mbit/s (rep 2) | 22.7 (44.9, 55.3) | 3707 | 6.3 | 89 / 238 / 272 · 60 / 199 / 272 · 45 / 183 / 243 | — | 2.21 / 18 % / 119 | 2.33 / 16 % / 109 | 1 / 67 / 151 | 1.25 / 10.55 | | LAN | 0.5 Mbit/s (rep 2) | 19.3 (59.6, 62.5) | 3290 | 6.0 | 40 / 138 / 167 · 34 / 105 / 167 · 35 / 137 / 170 | 1.93 / 4 % / 99 | 1.43 / 9 % / 102 | 2.32 / 7 % / 107 | 16 / 96 / 227 | 1.18 / 4.46 | | 40 ms ±10, 1 % | main | 46.2 (63.5, 73.3) | 925 | 51.2 | 103 / 435 / 460 · 102 / 311 / 419 · 1001 / 1048 / 1083 | — | 1.73 / 10 % / 209 | 3.22 / 43 % / 209 | — | 1.57 / 4.94 | | 40 ms ±10, 1 % | 1.0 Mbit/s | 17.3 (69.1, 80.3) | 2776 | 6.4 | 61 / 161 / 172 · 37 / 120 / 170 · 36 / 111 / 170 | — | 1.29 / 11 % / 129 | 1.48 / 10 % / 140 | 1 / 66 / 125 | 0.99 / 4.58 | | 40 ms ±10, 1 % | 0.5 Mbit/s | 18.7 (58.7, 64.0) | 3092 | 6.2 | 44 / 136 / 174 · 36 / 127 / 167 · 36 / 131 / 173 | — | 1.33 / 12 % / 150 | 1.20 / 10 % / 156 | 16 / 114 / 233 | 1.06 / 5.33 | | 100 ms ±10, 2 % | main | 37.8 (43.4, 47.0) | 757 | 51.1 | — · 98 / 171 / 227 · 1002 / 1078 / 1167 | — | 0.85 / 9 % / 321 | 2.26 / 55 % / 321 | — | 1.46 / 2.37 | | 100 ms ±10, 2 % | 1.0 Mbit/s | 17.6 (21.1, 22.1) | 3423 | 5.3 | — · 33 / 73 / 162 · 33 / 67 / 158 | — | 0.20 / 1 % / 225 | 0.25 / 3 % / 199 | 16 / 84 / 198 | 1.09 / 2.85 | | 100 ms ±10, 2 % | 0.5 Mbit/s | 11.9 (17.6, 19.4) | 2299 | 5.3 | — · 32 / 72 / 163 · 32 / 73 / 162 | — | 0.12 / 0 % / 206 | 0.24 / 4 % / 205 | 16 / 71 / 150 | 1.00 / 2.11 | ### 5.3 realistic-island-16, viewer over one island The island scene moves only during the drops (scheduled actions do not fire on the live server), so its motion rows are a handful of bodies. | condition | variant | pose KiB/s mean (p95, max) | updates/s | B/update | interval near / mid / far p50/p95/p99 ms | near: step err / frozen / delay | mid | far | contact offset p50/p95/p99 ms | server tick ms p50/p99 | |---|---|---|---|---|---|---|---|---|---|---| | LAN | main | 2.6 (21.8, 27.6) | 53 | 51.0 | 33 / 36 / 132 · 100 / 135 / 236 · 996 / 1006 / 1405 | — | 0.28 / 0 % / 78 | 2.06 / 58 % / 78 | — | 0.81 / 1.50 | | LAN | 1.0 Mbit/s | 4.1 (22.2, 39.9) | 592 | 7.1 | 33 / 36 / 66 · 33 / 36 / 38 · 33 / 36 / 38 | — | 0.19 / 0 % / 59 | 0.21 / 0 % / 73 | 1 / 66 / 100 | 0.71 / 1.18 | | LAN | 0.5 Mbit/s | 4.8 (39.6, 58.8) | 637 | 7.7 | 33 / 51 / 72 · 34 / 51 / 87 · 33 / 51 / 72 | 0.46 / 1 % / 107 | 0.36 / 2 % / 93 | 0.32 / 1 % / 94 | 9 / 76 / 185 | 0.94 / 3.51 | | 40 ms ±10, 1 % | main | 3.0 (19.2, 30.4) | 60 | 51.0 | 33 / 55 / 141 · 101 / 169 / 232 · 999 / 1018 / 1294 | — | 0.26 / 0 % / 88 | 2.14 / 59 % / 88 | — | 0.77 / 1.45 | | 40 ms ±10, 1 % | 1.0 Mbit/s | 4.3 (24.1, 40.6) | 604 | 7.2 | 33 / 44 / 95 · 33 / 44 / 88 · 33 / 44 / 91 | — | 0.23 / 0 % / 126 | 0.23 / 2 % / 126 | 0 / 50 / 91 | 0.67 / 1.18 | | 40 ms ±10, 1 % | 0.5 Mbit/s | 5.1 (23.4, 39.0) | 762 | 6.8 | 33 / 43 / 88 · 33 / 42 / 94 · 33 / 42 / 96 | 0.14 / 0 % / 116 | 0.29 / 0 % / 119 | 0.22 / 1 % / 119 | 13 / 68 / 132 | 0.70 / 1.38 | | 100 ms ±10, 2 % | main | 10.8 (15.0, 15.4) | 217 | 51.1 | 31 / 73 / 143 · 99 / 175 / 199 · 996 / 1085 / 1130 | 0.07 / 0 % / 251 | — | — | — | 0.81 / 1.32 | | 100 ms ±10, 2 % | 1.0 Mbit/s | 1.1 (1.8, 2.5) | 137 | 8.2 | — · 32 / 74 / 154 · 32 / 78 / 160 | — | — | — | 2 / 66 / 99 | 0.64 / 0.92 | | 100 ms ±10, 2 % | 0.5 Mbit/s | 1.2 (2.1, 2.2) | 165 | 7.5 | — · — · 33 / 60 / 157 | — | — | 0.28 / 0 % / 190 | 33 / 83 / 117 | 0.64 / 1.06 | ### 5.4 The roller (surface-gi-motion), near band | condition | variant | pose KiB/s mean (p95, max) | updates/s | B/update | interval near / mid / far p50/p95/p99 ms | near: step err / frozen / delay | mid | far | contact offset p50/p95/p99 ms | server tick ms p50/p99 | |---|---|---|---|---|---|---|---|---|---|---| | LAN | main | 1.9 (2.0, 2.1) | 38 | 51.0 | 33 / 34 / 36 · 100 / 102 / 103 · 998 / 1005 / 1005 | 0.15 / 0 % / 118 | — | — | — | 0.11 / 0.20 | | LAN | 1.0 Mbit/s | 0.6 (0.8, 0.8) | 65 | 10.2 | 33 / 34 / 35 · 33 / 34 / 35 · 33 / 34 / 35 | 0.10 / 0 % / 60 | — | — | — | 0.11 / 0.19 | | 40 ms ±10, 1 % | main | 1.8 (2.0, 2.1) | 37 | 51.0 | 33 / 41 / 93 · 100 / 110 / 147 · 1001 / 1005 / 1005 | 0.18 / 0 % / 147 | — | — | — | 0.08 / 0.15 | | 40 ms ±10, 1 % | 1.0 Mbit/s | 0.6 (0.8, 0.8) | 65 | 10.2 | 33 / 41 / 78 · 33 / 41 / 78 · 34 / 40 / 42 | 0.18 / 0 % / 106 | — | — | — | 0.08 / 0.14 | | 100 ms ±10, 2 % | main | 1.8 (2.1, 2.2) | 37 | 51.0 | 33 / 74 / 163 · 100 / 189 / 227 · 1006 / 1098 / 1098 | 0.19 / 0 % / 221 | — | — | — | 0.08 / 0.16 | | 100 ms ±10, 2 % | 1.0 Mbit/s | 0.6 (0.8, 0.8) | 65 | 10.2 | 32 / 64 / 160 · 32 / 64 / 160 · 32 / 63 / 163 | 0.22 / 1 % / 195 | — | — | — | 0.08 / 0.14 | **Reading.** - **Bytes.** The pile-huge drop at all-bodies-moving peaks at 77–87 KiB/s (0.63–0.71 Mbit/s) on the branch: the 1.0 Mbit/s budget never binds there, and 0.5 binds for 6–7 s of the collapse (below). Main's stream sat at 64–66 KiB/s for 1.3 k updates/s, held there by the 48-message cap. Per update: 51 → 5.9–6.4 B (pile), 7.1–7.7 B (island), 10 B (roller: few bodies per batch, so the header weighs more). - **Rate.** Main's bands show as 33 / 100 / 1000 ms medians, with the cap stretching near and mid p95 to 215–435 ms. On the branch a moving body's median gap is one tick at every distance. Its p95 (70–190 ms on pile-huge even when the budget is not binding) is the server: during the collapse physics runs below real time (pile-huge ~0.6×), so some ticks have no new step for a body. - **Motion.** Far bodies: frozen frames 39–58 % → 0–16 %, step error 2.1–4.4 → 0.2–2.8. Mid and near pile bodies: 1.3–2.8 → 1.0–2.8, within the run-to-run noise (rep 2 of the 1.0 run is the worst branch row and had its own collapse); contact-rich motion at 30 Hz with linear interpolation still misses bounces (`net-entity` §4.3). The island's far bodies: 2.1 → 0.2. - **100 ms / 2 %** from 25 s: the branch's far and mid bodies 2.3–3.4 → 0.2–0.3; main's cold-start stall was longer in its runs (§3), which is why that window starts late. ### 5.5 Smoothly with distance: intervals while the budget binds Seconds whose pose bytes reached 85 % of the 0.5 Mbit/s budget (the accumulator choosing), intervals by distance bin: | run | sat s | <96 | 96–192 | 192–384 | 384–768 | ≥768 | |---|---|---|---|---|---|---| | m-b05-pile-lan-edge | 6 | 46 / 83 / 86 | 42 / 83 / 86 | 47 / 82 / 89 | 60 / 108 / 143 | 60 / 143 / 176 | | m-b05-pile-lan-spawn | 7 | 39 / 83 / 87 | 40 / 83 / 99 | 40 / 81 / 99 | 47 / 100 / 132 | 56 / 138 / 149 | | m-b05-isl-lan-isl | 3 | 37 / 66 / 87 | 37 / 66 / 87 | — | 37 / 66 / 87 | 37 / 68 / 87 | | m-b05-pile-w40-edge | 7 | 40 / 128 / 185 | 39 / 130 / 254 | 41 / 139 / 254 | 56 / 160 / 254 | 61 / 165 / 223 | | m-b05-pile-w40-spawn | 6 | 39 / 109 / 127 | 38 / 109 / 181 | 38 / 106 / 181 | 46 / 115 / 181 | 59 / 145 / 222 | | m-b05-isl-w40-isl | 4 | — | — | — | — | — | | m-b10-isl-w40-isl | 1 | — | — | — | — | — | | m-b05-pile-w100-edge | 4 | — | — | — | — | — | | m-b05-pile-w100-spawn | 6 | — | — | — | — | — | | m-b10-pile-w100-spawn | 1 | — | — | — | — | — | | m-b05-isl-w100-isl | 3 | — | — | — | — | — | | m-b10-isl-w100-isl | 1 | — | — | — | — | — | The interval grows smoothly with distance (p50 39–47 ms under 384 v, 47–61 ms beyond; p95 81–83 → 100–165 ms), with no step at 96 or 384 v. Main's bands put 33 / 100 / 1000 ms steps at exactly those distances. ### 5.6 Bodies at different delays (touching bodies) Pairs of bodies rendered moving within 72 v of each other (centres; dice are 64 v), every 6th frame: the difference of their delays, and that difference × their relative speed (how far apart in voxels the time offset puts them). Main has one delay for every body (offset 0, by construction). - b10 pile-lan-edge: offset 7 / 100 / 228.3 ms, slip 0 / 0.075 / 0.412 v (162764 pair-frames) - b10 isl-lan-isl: offset 0.7 / 66.3 / 100 ms, slip 0 / 0.12 / 0.912 v (20556 pair-frames) - b05 pile-lan-edge: offset 16 / 95.8 / 183.8 ms, slip 0.002 / 0.21 / 1.938 v (210927 pair-frames) - b05 isl-lan-isl: offset 8.8 / 76 / 184.5 ms, slip 0.025 / 2.277 / 6.761 v (29455 pair-frames) - b10 pile-w40-edge: offset 2.3 / 66 / 128 ms, slip 0 / 0.083 / 0.6 v (126717 pair-frames) - b10 isl-w40-isl: offset 0.3 / 50 / 90.5 ms, slip 0 / 0.28 / 2.31 v (19164 pair-frames) - b05 pile-w40-edge: offset 16 / 112.7 / 233 ms, slip 0.002 / 0.457 / 3.629 v (160066 pair-frames) - b05 isl-w40-isl: offset 13 / 68 / 132 ms, slip 0.002 / 0.496 / 2.709 v (29357 pair-frames) - b10 pile-w100-edge: offset 16 / 84 / 195.5 ms, slip 0.002 / 0.053 / 0.143 v (125548 pair-frames) - b10 isl-w100-isl: offset 2 / 66 / 99 ms, slip 0 / 0.041 / 0.109 v (621 pair-frames) - b05 pile-w100-edge: offset 16 / 69.3 / 150 ms, slip 0.002 / 0.05 / 0.136 v (69743 pair-frames) - b05 isl-w100-isl: offset 33 / 83 / 117 ms, slip 0.016 / 0.085 / 0.156 v (3076 pair-frames) - Median 1–16 ms; p95 40–113 ms; p99 90–233 ms. As a displacement: median ≤ 0.03 v, p95 0.06–0.5 v (island 0.1–2.3 v, where few fast bodies dominate), p99 0.3–7.9 v. - The offset comes from interval terms differing: two touching bodies have nearly the same priority, but they are sent in different ticks, one may have just woken (its gaps not yet counted) and the slewed interval terms lag their targets by up to seconds. The large-p99 cases are a fast body passing a slower one. - A shared interval term per contact island (an island id on the wire, or the client grouping bodies by proximity) would make touching bodies coherent; it is not built (§7, decision 4). ### 5.7 CPU - **Server**, the look tick's entity-state work (pile-huge, two sessions): p50 1.9–2.0 → 1.1–1.2 ms, p99 5.0–6.1 → 4.3–4.8 ms (one 10.6 ms p99 in rep 2 of the 1.0 run); island 0.8 → 0.7 ms. Fewer, larger messages cost less than 1.3 k per-entity messages through the outbox. - **Client**, replaying the recorded arrivals in Bun (the interpolator only; in the browser `partRegistry.updateTransform` per changed body dominates, `net-latency` §11): - pile-huge: 0.033 / 0.127 ms (main) → 0.038–0.058 / 0.13–0.14 ms per frame p50 / p99; pose sink calls per frame p50 150 → 134–204 (more bodies interpolate instead of holding, so this is the browser cost that grows: at net-latency §11's ~1.5–2 µs per call, ≲ 0.1 ms); - decoding the batches: 1.5–2.1 ms per second (0.04–0.06 ms per batch p50, 0.19–0.22 p99); - island: 0.001 → 0.003 ms per frame p50. ## 6. Design (not built): a local-simulation lane for touched bodies (step d) Step d simulates the bodies a player touches on that client (`physics-rs` in wasm, `docs/net-entity.md` §7, §10 d) and shows them at ≈ zero delay, with server corrections. With the per-entity delay of §2.3 a lane is not a new render path: it is an entity whose delay is ≈ 0 (rendered at the client's present) instead of `J + I_e`, fed by the local simulation instead of the pose buffer. The hard parts are the two transitions, and the bodies at the boundary. **Entering the lane (grab, or the avatar walks into a body).** The body's local simulation starts from its newest server sample, advanced to the present by the local step (the same physics, ≈ one delay of motion). Rendered time jumps forward by its delay (~60–150 ms on clean links, §4). - E1 *blend*: render `lerp(interp(t − D), local(now), w)`, `w` 0 → 1 over ~D. No speed change; for ~D the body is a mix of two times (a ghosted path if it moves fast). - E2 *fast-forward*: slew its delay to 0 at an elevated, bounded rate (e.g. +50 % speed for 2D). The body visibly speeds up for ~0.2 s. - E3 *enter only at rest*: a resting body's pose is the same at every delay, so its delay can be switched instantly with nothing visible. A grab of a resting body (the common case) is invisible; a grab of a moving body falls back to E1. Recommendation: E3, else E1. **Leaving the lane (release; the hard one).** The body goes from the present back to the delayed timeline, i.e. back in time by D. - L1 *slow-motion*: slew its delay from 0 to `J + I_e` at the bounded rate (5 % today: 2 s to grow 100 ms). Continuous, but the thrown body moves 5 % slow for seconds, and while it does it is at a different time from every body it hits. - L2 *hold the lane until the timelines meet*: keep simulating the released body locally for D after release, then hand over to the server stream when its delayed timeline reaches the release moment; the difference (local vs server divergence over one RTT + D) is absorbed by the existing render-only error offset (τ 80 ms). No time warp; one small correction that decays. - L3 *stay in the lane until it rests*: keep the released body (and what it hits, below) locally simulated, reconciled to server state by a decaying error offset (Fiedler's 0.95–0.85 per frame), until it comes to rest; at rest its delay switches to the delayed timeline invisibly (as E3). No time warp and no hand-over pop; the cost is the local island's CPU while thrown bodies settle (a few seconds, ≤ ~20 bodies, `docs/net-entity.md` §10 d) and longer exposure to divergence for a long throw. - L4 *cap*: L3, but when the local island exceeds its body budget the oldest released body leaves by L2. Recommendation: L3 with L4's cap; L2 as the simple first build. **The boundary.** Lane bodies (present) touching non-lane bodies (D in the past) are rendered D apart: a thrown die hits a pile body that is shown where it was ~100 ms ago. Options: - B1 *island membership*: the lane is the local island — held body, bodies in contact with it or with the avatar, and their contact neighbours (what §10 d already proposes); a body joins on contact (E3/E1) and leaves at rest (L3). The offset then exists only across the island edge, where bodies are not touching. - B2 *delay field*: make each body's delay a smooth function of its distance from the lane (0 inside, `J + I_e` beyond ~1–2 body sizes), which needs present-time poses — i.e. local simulation — for every body in the ramp: B1 with a soft edge. - B3 *accept it*: the measured offset between touching remote bodies today is 1–16 ms median / 40–113 ms p95 (§5.6); a lane's D is 60–200 ms. Recommendation: B1; B2 only if the edge shows. **What the per-entity delay already gives step d.** Each entity has its own render time (`EntityInterp.entityRenderTime`) with a bounded rate, so a lane is "delay 0 + a different sample source" for that entity, and the error offset already makes source switches continuous. The server side needs nothing new for E/L/B; the priority boost for held and touched bodies (§2.2) already sends them every tick, which keeps the corrections small. ## 7. Owner decisions (defaults are provisional) 1. **Per-client state budget (`STATE_BUDGET_MBIT`).** Provisional **1.0**. | | 0.5 Mbit/s | 1.0 Mbit/s | |---|---|---| | binds on pile-huge | 6–7 s of the collapse (peak 63–64 KiB/s) | never (peak 77–87 KiB/s = 0.63–0.71 Mbit/s) | | binds on island-16 / roller | 2–4 s of the drop / never | ≤ 1 s / never | | intervals while binding (pile, LAN) | p50 39–61 ms, p95 81–165 ms, rising with distance | — | | mean pose bytes | 12–24 KiB/s | 17–23 KiB/s | | pile motion step error, near / mid / far (LAN, 2 runs × 2 viewers) | 1.0–1.9 / 1.0–1.4 / 1.0–2.3, frozen 6–10 % | 1.9–2.8 / 1.0–2.5 / 1.2–2.8, frozen 6–17 % | Motion is within run-to-run noise between the two: at 0.5 the pile's far bodies run at ~15–20 Hz during the collapse and that is not measurably worse. 0.5 is Teardown-like headroom for many players on one uplink; 1.0 means pile-huge never waits. Either is 3–5× less than main's ~0.55 Mbit/s cap-limited stream per update delivered. 2. **Rotation precision (`POSE_ROT_BITS`).** Provisional **12**. | | 10 bit | 12 bit | |---|---|---| | angle error p50 / p99 / max | 0.087° / 0.159° / 0.236° | 0.022° / 0.040° / 0.061° | | on a 64 v die's corner, p50 / max | 0.08 / 0.23 v | 0.02 / 0.06 v | | B/update, same records re-encoded: pile-huge / island / roller | 5.14 / 6.51 / 9.99 | 5.90 / 7.04 / 10.01 | | live LAN runs (different motion) pile / island | 5.5–5.9 / 7.0–7.4 | 5.9–6.2 / 7.1–7.7 | 12 bits costs +7–15 % bytes; 10 bits leaves a resting body up to a quarter voxel off at its corners (static, so it never shimmers, but a die resting against a wall can show a sliver). 3. **The interval term's slew** (new with the per-entity delay). It uses the shared clock's bounds: +5 % (delay grows) / −2 % (shrinks). A body whose rate drops (it went far, or the budget started binding) takes ~4.7 s to grow from 66 to 300 ms and holds/catches up meanwhile; one whose rate rises takes 5 s per 100 ms to come back down. Faster bounds (e.g. ±10 %) halve both but show as a visible 10 % speed change while they run. Provisional: unchanged (5 % / 2 %). 4. **Touching bodies at different delays** (§5.6, median ≤ 16 ms, p95 ≤ 113 ms). Accept, or build a shared interval term per contact island (needs an island id on the wire or a client proximity grouping). 5. **The local-simulation lane's transitions** (§6): recommended E3/E1 on entry, L3 (+L4 cap) on release, B1 at the boundary; L2 as the simple first build. 6. **Constants that are physical rather than owner calls**, listed for review: the priority's 32 v distance floor and 8 v radius pad; the event boost 4× decaying with τ 0.5 s; the touch margin 8 v and impact reach 32 v; the interval term's 8-gap window and 0.1 v / 1 v/s motion floor; the total delay clamp [50, 1000] ms and the jitter cap 300 ms. ## 8. Tests, gates, hygiene - `bun run check` clean; `bun run test`: **TOTAL: 2074 pass, 0 fail across 38 shards**, no Bun panics. `bun run lint`: the same 6 warnings as main. - New / rewritten tests: `common/src/pose-codec.test.ts` (quantisation bounds at 10 and 12 bits, key + delta round trips with stamp wrap and held, a delta without a baseline is rejected, a small move costs 3 B), `server/src/entities/replication-budget.test.ts` (every changed pose every tick while the budget allows, nothing for an unchanged one; the accumulator shares a tight budget by priority and starves nothing; a held body outranks an equally distant one; stamp and `heldUntilMs`), `client/src/net/entity-interp.test.ts` (each entity's delay follows its own interval and changes at the slew rate; render clocks within the combined slew bounds; the step-a behaviours), `outgoing.test.ts` on byte budgets. All at tuned defaults. - No surface-GI gate run (no renderer change). Every run: nothing held `/tmp/gi-gate*.lock`; netem only on this round's private veth pair; no sysctl or shared interface touched; servers under `systemd-run --scope` (10 G), ports 3941; the netns and its veth were removed afterwards. - Throwaway measurement code: branch `net-batch-meas` (the merge branch + the `net-entity` trace, an `EntityPoses`-decoding recorder and the `ltd` tick timer; NOT FOR MERGE) and the unpushed detached worktree `net-batch-base` (main + the same trace). Scripts: `logs/net-batch/` (`netns.sh`, `run.sh`, `mx.sh`, `an/step1.ts`, `an/score.ts`, `an/tables.ts`, `an/rotbits.ts`).