feat: session cache, explored bitmap and lock-free tile gate (#65)
The tile gate no longer takes dbLock or runs a SQL session JOIN per tile: a published in-memory view (server/sessions.nim) holds token hashes -> player/role and one explored bitmap per player. Sessions load from the DB at startup and are updated by join, key replacement and player removal in the same lock as the write; refreshed cells publish before the ack. The gate is one snapshot read (parse + session + bit test + redirect) over scalar data only, so a tile burst is answered while a mutation holds dbLock. Evidence: tests/tsessions.nim pins the cache/bitmap lifecycle and gate rule; tiles.test adds the lock-held burst and the revocation/restart seam; auth.test adds the LEAK_FAULT=sessioncache negative control (a stale entry makes the auth group fail); mutation c5 keeps the cache drop load-bearing. Explored wire and persistence untouched. Bench (devbox run bench, in-process): tile gate old 0.006 ms -> new 0.001 ms per request; incremental explored mark 0.001 ms; snapshot build 2.0 ms at 262144 cells (startup only).
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
# slice 9 (#24): the canonical tile URL and the "any explored cell allows" gate
|
||||
# c1: a tile is allowed without any explored cell | c2: every overlapping cell is required
|
||||
# c3: an out-of-grid coordinate is accepted | c4: a leading-zero coordinate is canonical
|
||||
# #65: c5 a revocation keeps the cached session
|
||||
# d3: scene.set accepts a patch with no field (slice 10, #25)
|
||||
# Parallel: MUTATION_JOBS (default nproc/4) jobs, each in its own temp copy + nimcache; output collected, printed in fixed order.
|
||||
# Tests run with FFF_MUTATION=1 (iteration counts ~/10, see tests/testutil.nim scaled()); only test files holding an expected
|
||||
@@ -208,6 +209,8 @@ run c1 "the tile gate ignores the explored set" server/tiles.nim 's/ if sc\
|
||||
run c2 "the tile gate needs every overlapping cell" server/tiles.nim 's/ if sc\.cellIndex(cx, cy) in explored: return true/ if sc.cellIndex(cx, cy) notin explored: return false/' "$TILE_GATE"
|
||||
run c3 "an out-of-grid tile coordinate is accepted" server/tiles.nim 's/^ x >= 0 and y >= 0 and x < tileCols(sc) and y < tileRows(sc)$/ x >= 0 and y >= 0/' "$TILE_RANGE"
|
||||
run c4 "a leading-zero tile coordinate is canonical" server/tiles.nim "s/ if raw\[0\] == '0' and raw.len > 1: return false/ discard/" "$TILE_ZERO"
|
||||
# #65: the in-memory session cache must drop a player's entry on revocation (server/sessions.nim)
|
||||
run c5 "a revocation keeps the cached session" server/sessions.nim 's/^ g\.view\.sessions\.del h$/ discard/' "revocation drops"
|
||||
# slice 10 (#25): scene.set needs at least one patch field (server/world.nim parseScenePatch)
|
||||
run d3 "scene.set accepts a patch with no field" server/world.nim 's/^ if not any: return none(ScenePatch)$/ discard/' "a patch with none is invalid"
|
||||
# #32: the rollback on a Defect, in both transaction helpers, and the one-ack decision
|
||||
|
||||
Reference in New Issue
Block a user