feat(m4): cap map images at Full HD and shrink on import (#85)

The owner fixed the map cap at 1920 px on the long side and 1080 px on the
short side (either orientation). fff-vtt import now shrinks a larger source
with ImageMagick Lanczos before tiling (alpha kept, proportions preserved,
no upscaling), prints `scaled WxH -> WxH`, and records the shrunk w/h; a
source at or below the cap is untouched, so the pixel-identity tests still
hold. A scene row already above the cap is not rewritten: the server logs
`map_above_cap` at startup and serve prints the re-import advice.

Docs: ADR-0023, DESIGN 3.3/5.3/8/11.1/13/14, TESTING 5.3/13, README,
HANDOFF-M4, client README. The M4 phone gate and the fogbench measurement
now use the Full HD maximum; the 16384 px / 262144-cell bench and test rows
stay as labelled server stress references. import-scale now proves a 16384²
input is shrunk to 1080x1080 (289 tiles at 64 px) quickly and bounded.

Part of #63, #85. #77 is blocked by this issue.
This commit is contained in:
2026-11-21 22:37:34 +01:00
parent 52ab50d765
commit a79d809394
22 changed files with 515 additions and 193 deletions
+9 -6
View File
@@ -1,6 +1,8 @@
## Vision and egress microbench: devbox run bench (nim c -d:release -r tools/bench.nim; log: results/bench.log).
## No timing code lives in server/: this harness times from outside with O(1) accumulators (sum, worst), no sample arrays.
## Targets (DESIGN 5.3 / 13 M2, PROPOSED): polygon + cells <= 0.451 ms avg on the prototype scene; polygon < 1 ms avg on 5k walls.
## Targets (DESIGN 5.3 / 13 M2, PROPOSED): polygon + cells <= 0.451 ms avg on the prototype scene; polygon < 1 ms avg on the 5k-wall stress scene.
## The product map maximum is Full HD (1920x1080, #85); the 16384 px and 262144-cell rows below are labelled
## stress references for the server, not the product target.
## The egress rows record the absolute averages the in-process gate (tests/tviews.nim, TESTING 5.3) deliberately does not assert.
import std/[json, monotimes, times, strformat, os, math, options, sets, tables]
import db_connector/db_sqlite
@@ -72,10 +74,10 @@ proc big(label: string, world: float) =
discard bench(&"1 move check (pathClear, cap-length step), {label}", 20000, proc(i: int) =
let o: Vec = (rng.uni(400, world - 400), rng.uni(400, world - 400))
sink += int(pathClear(walls, o, (o.x + 300, o.y), 20)))
if label == "5k sparse": target("polygon, 5k-wall scene", po, 1.0)
big("5k sparse", 16384)
big("5k dense", 4096)
echo "== egress (#28: 6 players x 40 encountered entries, 262144 explored cells) =="
if label == "5k sparse (stress)": target("polygon, 5k-wall stress scene", po, 1.0)
big("5k sparse (stress)", 16384)
big("5k dense (stress)", 4096)
echo "== egress (#28 stress: 6 players x 40 encountered entries, 262144 explored cells) =="
proc egressStore(cells: int): ref ContextStore =
var tokens: seq[TokenRec]
for i in 0 ..< 6:
@@ -136,7 +138,8 @@ discard bench("tile gate old: parse + SHA-256 + session JOIN + HashSet", 2000, p
discard bench("tile gate new: parse + SHA-256 + cache lookup + bitmap", 2000, proc(i: int) =
let h = sha256Hex(benchToken)
if gc.gateTile(h, "1", "v1", "9_9.png").allowed: inc sink)
# Explored ops: the snapshot build at the 16384 px size (512x512 cells) and the incremental mark.
# Explored ops: the snapshot build at a synthetic 16384 px stress size (512x512 cells) and the
# incremental mark. The product maximum is Full HD (2040 cells at cell 32, #85).
let bigScene = SceneRec(id: 1, name: "Scene", w: 16384, h: 16384, tileSize: 32, cell: 32,
visionRadiusDefault: 400, tokenRadiusDefault: 20, artVersion: 1,
nextWallId: 1, extra: newJObject())