Mod-path CPU spans and a monotonic mod clock (#147 step 3.1)

Host-side per-tick CPU spans of tick_mods (ground answers, world rays/
sections, snapshot, the WASM tick wall time, model prep, output), gated by
HORIZON_MOD_CPU_PROFILE=1 like the fuel profile and bounded like FrameStats.
Each record carries the game tick and the frame index it ran in, so the bench
can join the spans with the frame/CPU/GPU trace; stats reports per-span
percentiles and stats raw the per-tick records, cleared by stats reset/bench.

game.monotonic-nanos (API level 32): a monotonic clock a mod reads to time its
own phases, never simulation time. Additive to the game interface, so older
mods still link; api_level and the generated reference updated.

Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
2026-11-21 12:13:01 +03:00
parent 3428a571bd
commit d073783f55
6 changed files with 170 additions and 2 deletions
+1
View File
@@ -128,6 +128,7 @@ A block along the player's view.
| `world-id` | `func() -> option<string>` | Which world is open (AirDef fork): `world:<folder>` for a saved world, `server:<address>` on a server; none on the title screen. Mods keep their state apart by it. |
| `world-seed` | `func() -> option<s64>` | The open saved world's seed (AirDef fork, API level 25): with the folder name it tells a new world from an old one that had the same name. None on the title screen and on a server. |
| `raycast` | `func(distance: f32) -> option<hit>` | The first block along the player's view (fluids pass), up to `distance` blocks (at most 1024; past the loaded chunks, across the distant terrain when LOD Distance is on), as of this tick. None when nothing is hit, and on the title screen. |
| `monotonic-nanos` | `func() -> u64` | Nanoseconds on a monotonic clock (AirDef fork, API level 32): for timing a mod's own work, never simulation time. It only ever rises while the game runs; a mod must not feed it into combat decisions. |
## `chat`