H12: Build the next match's island on a worker thread
When a match's results begin, Match starts the next match's Simulation on a WorkerThreadPool task (its seed is fixed by then) and collects it when the lobby opens. The same task plans the island's tide levels (Simulation.plan_tide) and runs a prepare_next hook, which ServerLoop uses to build the bots' NavGrid and BotWorld for the island. All of these read only the new simulation, so the results are the ones the main thread would have made: tests compare the state hash, terrain, solids, props, tide levels and navigation with fresh ones, and the ten-matches test still matches its references. A Match freed while its task runs waits for it. Measured: a 24-bot server paced in real time through the results, lobby, countdown and 3 s of the next drop has a worst tick of 5.4 ms; it was 1.8 s. In the 24-client soak at 2% loss, moving the island alone left a 0.82 s tick (the bots' navigation) and moving that too left 74 ms at the next match's start (planning the tide), which this also moves. The soak hasn't been run again since that last step. Closes #79 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -56,6 +56,8 @@ var hit_history: HitHistory = HitHistory.new()
|
||||
|
||||
## Player entity ID -> { command tick -> PlayerCommand }
|
||||
var _pending: Dictionary = {}
|
||||
## The tide levels plan_tide() worked out, or empty.
|
||||
var _planned_levels: PackedFloat32Array = PackedFloat32Array()
|
||||
## How many entries of props.destroyed have been checked for crate loot.
|
||||
var _destroyed_checked: int = 0
|
||||
## Player entity IDs, ascending.
|
||||
@@ -154,11 +156,20 @@ static func crate_spill_points(prop_set: PropSet) -> Dictionary:
|
||||
## Starts the tide's schedule from this tick.
|
||||
func start_tide() -> void:
|
||||
if island != null:
|
||||
tide = Tide.new(tick, SafeGround.new(ground).plan_levels())
|
||||
plan_tide()
|
||||
tide = Tide.new(tick, _planned_levels)
|
||||
else:
|
||||
tide = Tide.new(tick)
|
||||
|
||||
|
||||
## Works out the island's tide levels now, if it hasn't been done, so start_tide() is
|
||||
## quick. They depend only on the island, so the server does this on the worker that
|
||||
## builds the next match's island; anything that changes the ground first must not.
|
||||
func plan_tide() -> void:
|
||||
if island != null and _planned_levels.is_empty():
|
||||
_planned_levels = SafeGround.new(ground).plan_levels()
|
||||
|
||||
|
||||
## Height of the water surface over a point: the sea level where the flood reaches,
|
||||
## Flood.NO_WATER where it doesn't. On a test ground, the sea level everywhere.
|
||||
func water_level_at(point: Vector3) -> float:
|
||||
|
||||
Reference in New Issue
Block a user