Repository navigation
FL2, first part: a world's vehicles drawn at scale, in both holons - #1489
Merged
Merged
Conversation
Each world entity was a scene node of its own: a box look is six boxes and a group, so 200 vehicles were 1400 actors. On arigl, 200 kinematic vehicles at 3.6x took 61 ms a frame (19 of runtime, 42 to 46 of drawing), and 800 took seconds. cvc::gl::ariadne::entity_view (entity_view.h) is the view of a set of entities, whatever feeds it: - set_entities (who each is: archetype, fleet, team, colours, look, size); - promote, from the camera and the ids followed; - then pose and draw each frame. Its bodies layer draws the entities it takes as one mesh per archetype and LOD rung: - a fitted model gets four rungs (#1358's swarm rungs; decimate_mesh moves to mesh_lod.h and the swarm uses it there), a box look one; - each copy is posed in 3-D, normals too, and culled on the frustum's sides. Near and far are left out: the renderer fits them to what it draws, and an unposed rung is a point, so a far plane fitted to it cut away the entities about to be drawn. Promotion and layers: - promote (8) are drawn as their own nodes by vehicle_view: the followed (a camera's track.target, vehicles.watch, the vehicle a client drives), then the nearest. An incumbent keeps its node until another is a fifth nearer. - a layer of at most threshold (32) promotes them all, so small worlds look as before; - type: entity_layer (of: all | { fleet } | { archetype } | { team }, lod:, promote:, threshold:) declares a layer. With none, an implicit layer covers every entity. Two feeds, the local and the server-side holon: - a scene's own world: update_entity_view in tick_scene. Poses come from the physics binding's group of the chassis bodies (bind_group), between steps, whether the frame steps the world or #1475's world_worker holon does; - a relay's entities on a client: room_view::update_entities, from the entities section and the client's entity_playout poses. sync_vehicle_markers draws only the promoted, and adds or removes nodes as promotion changes. A boat, a mesh file look without fit, or an entity no layer takes keeps its own node. Test cvcgl_ariadne_entities (37 checks, 5 repeats): the implicit layer, follow, keep, the threshold, of:, the world on a worker, and the room. Locally, cvcgl_ariadne_labels, _scenes, _realize, _swarm, _physics and cvcgl_room_view also pass. arigl, 200 kinematic at 3.6x with --world-thread, alternating runs: - 8 ms a frame (2.4 runtime, 5.4 to 6.6 drawing), against 61 with threshold: 100000 (each its own node); - 800 take 8 ms of drawing. Their world, at 16 to 18 ms a frame, is now the cost. Not yet: the other layers (flags, goals, trails, path, belief, dots, targets, follow, headlights), of: { fleet } on a client (the room's identities carry no fleet), and swarm_layer moving here (FL3).
transfix
added a commit
that referenced
this pull request
Nov 24, 2026
…rld on a worker), and FL2's first part (a world's vehicles drawn at scale) (#1475) * Fleets: a placed vehicle keeps its fleet and its index in that fleet's navigator A tick at 2000 kinematic vehicles with summary keys looked a vehicle's fleet up 28,000 times (14 a vehicle), each a search of the fleets by the key's parts, about twice FL1a's plain find (#1449 left it), and searched its navigator's ids for its index about as often. - fleet_of(): a placed entity's fleet is set and cleared with its navigator id (place, remove_from_fleet, a failed placing, the world gone). A fleet outlives its vehicles in it, and an entity's key doesn't change while it is placed. An entity not placed is searched for as before. - index(): kept on the entity until an agent comes or goes in that fleet (a fleet's agents_rev, bumped at each add_agent and remove_agent; an index past a removed one drops by one). - Debug builds assert both against the search. The scene world, holon, holon sync and server document suites pass with the asserts on in a Release build. Timed in one process on a busy machine (a whole tick's A/B was lost in its noise): a search took 124 to 141 ns and the kept fleet 3 to 6 ns; an index 102 to 122 ns and kept 5 to 8 ns. The roadmap's 3.1 has it. * Fleets' D3 as OW7's first part: a drawn host's world steps on a worker, in a local holon A drawn host stepped its scene world (physics and the fleets' navigators) on the frame's thread: at 3.6x 60 Jolt vehicles took two thirds of a core, 800 kinematic ones all of it. D3 (FLEETS_AND_NIGHT_ROADMAP.md) moves it off; Joe chose to build it as OW7's first part, the world in a local server-role holon (ARIADNE_WORLDS.md 18.2). A holon has no thread of its own, so the worker is new: - cvc::ariadne::world_worker attaches a SceneWorld to a server-role holon of its own (physics on, holon_config_at the world's rate) and runs a thread that keeps the holon's lockstep clock tick for tick behind the host's, one quantum at a time, so the world takes the steps the host's own follow() would. The host holds lock() for its frame; the worker takes it per step and lets a waiting host go first. A step that throws stops it (error()); lag()/behind() say how far it is behind; wait_caught_up() is for tests and captures. - SceneWorld::set_deferred: follow() then only steps. It runs no sync() and writes no key (a state subscriber runs on the thread that writes) and calls the worker's capture after each step; the host calls publish_due() (sync and the telemetry) under the lock. A restart anchors the world on the holon's clock again at once, since the host's clock may be back past where it was before the worker looks (the test caught that). - SceneClockDriver::hold(): a world more than max_lag (0.25 s) behind holds the clock, so it runs slower than its speed, as on the frame's thread, rather than further behind. - cvcGL: AriRuntime::set_world_thread starts a worker for the main scene's world at the next frame and holds its lock through frame() (input, pump, tick_scene); tick_scene publishes what the worker ran and draws from the poses it captured. The adapter owns the worker and stops it before a reload or clear replaces the world. arigl run --world-thread turns it on; snapshots, --terminal, wasm, the headless hosts, the gym and arisrv are unchanged. No holon.h change (coordinated with the One World session, #1444, on dev.tx.wtf). Tests: AriadneWorldWorker.StepsTheWorldAsTheHostsFollowWould (24 kinematic + 4 Jolt vehicles through a restart: the same poses bit for bit as the host's follow, the keys written on the host's thread; 30 repeats), cvcGL test_world_worker_drawn (bodies and their drawn pose as the frame's own follow leaves them). The scene world (114), holon, holon sync, server document and cvcGL physics suites pass. On arigl with 200 kinematic vehicles at 3.6x, alternating runs: 58.3 ms a frame against 66.4 on the frame's thread, the world at 3.6x both ways; the rest of the frame is drawing 200 vehicles (FL2). * D3: how far a world may lag its clock is a setting, the same on every host A scene's clock: { max_lag: <s> } sets how far its world may fall behind its clock: seconds of world time at 1x, growing with the speed as the clock's catch-up does (by ceil(speed) past 1x), more than 0 and at most 10 s (cvc::sim_catchup_valid). It was a fixed 30 quanta in world_worker, which is 0.25 s only at 120 Hz. - On a worker (arigl --world-thread), it is how far the world may trail its clock before the host holds the clock: world_worker::options::max_lag is now seconds (cvc::kSimCatchup by default), max_lag_quanta() scales it with the leader's speed, and a value that is no catch-up is refused, so the world stays on the frame's thread. - On the frame's thread (every single-threaded host, native or browser: arigl without the flag, the browser, snapshots, the headless AppRuntime), it is the catch-up one frame may run: SceneClockDriver sets the clock's stall guard from it when it binds (world_clock::set_max_steps_per_advance, new, which keeps the tick, and cap_scales_with_rate). Unset, the clock keeps the guard its host gave it, so no existing document changes. - world_worker::available() is false in single-thread wasm. The worker tests skip there, and the browser's arigl says once that it steps the world on the frame's thread when given --world-thread. - sim_tick.h: kSimCatchupMax, sim_catchup_valid, sim_catchup_quanta(_at), and sim_clock_config takes the catch-up. Tests: WorldClockTest.TheStallGuardChangesInPlace, SimTickTest.ACatchUpIsWholeQuantaAndGrowsWithTheSpeed, AriadneScene.ClockBlockTakesAMaxLag, AriadneSceneWorld.TheScenesMaxLagIsTheCatchUpAFrameMayRun and AriadneWorldWorker.TheWorldMayTrailItsClockByMaxLag. Docs: ARIADNE.md (--world-thread), WORLD_CLOCK_API.md, ARIADNE_WORLDS.md section 18.2. * FL2, first part: a world's vehicles drawn at scale, in both holons (#1489) Each world entity was a scene node of its own: a box look is six boxes and a group, so 200 vehicles were 1400 actors. On arigl, 200 kinematic vehicles at 3.6x took 61 ms a frame (19 of runtime, 42 to 46 of drawing), and 800 took seconds. cvc::gl::ariadne::entity_view (entity_view.h) is the view of a set of entities, whatever feeds it: - set_entities (who each is: archetype, fleet, team, colours, look, size); - promote, from the camera and the ids followed; - then pose and draw each frame. Its bodies layer draws the entities it takes as one mesh per archetype and LOD rung: - a fitted model gets four rungs (#1358's swarm rungs; decimate_mesh moves to mesh_lod.h and the swarm uses it there), a box look one; - each copy is posed in 3-D, normals too, and culled on the frustum's sides. Near and far are left out: the renderer fits them to what it draws, and an unposed rung is a point, so a far plane fitted to it cut away the entities about to be drawn. Promotion and layers: - promote (8) are drawn as their own nodes by vehicle_view: the followed (a camera's track.target, vehicles.watch, the vehicle a client drives), then the nearest. An incumbent keeps its node until another is a fifth nearer. - a layer of at most threshold (32) promotes them all, so small worlds look as before; - type: entity_layer (of: all | { fleet } | { archetype } | { team }, lod:, promote:, threshold:) declares a layer. With none, an implicit layer covers every entity. Two feeds, the local and the server-side holon: - a scene's own world: update_entity_view in tick_scene. Poses come from the physics binding's group of the chassis bodies (bind_group), between steps, whether the frame steps the world or #1475's world_worker holon does; - a relay's entities on a client: room_view::update_entities, from the entities section and the client's entity_playout poses. sync_vehicle_markers draws only the promoted, and adds or removes nodes as promotion changes. A boat, a mesh file look without fit, or an entity no layer takes keeps its own node. Test cvcgl_ariadne_entities (37 checks, 5 repeats): the implicit layer, follow, keep, the threshold, of:, the world on a worker, and the room. Locally, cvcgl_ariadne_labels, _scenes, _realize, _swarm, _physics and cvcgl_room_view also pass. arigl, 200 kinematic at 3.6x with --world-thread, alternating runs: - 8 ms a frame (2.4 runtime, 5.4 to 6.6 drawing), against 61 with threshold: 100000 (each its own node); - 800 take 8 ms of drawing. Their world, at 16 to 18 ms a frame, is now the cost. Not yet: the other layers (flags, goals, trails, path, belief, dots, targets, follow, headlights), of: { fleet } on a client (the room's identities carry no fleet), and swarm_layer moving here (FL3). * FL2: a parted look at scale, its wheels dark at every rung #1471's parted look (look: { chassis:, wheel:, rig: }) is a fitted look whose one-piece model is null, so the entity view drew every parted vehicle as a node of its own. - vehicle_look_mesh_of: a parted look's mesh is its chassis and its wheels at rest, each point where attach_parted_model's nodes draw it (the chassis fitted per axis; each wheel at its fitted hub, a right one turned or reflected as its rig says), the wheels in a tyre's dark. One texture, the chassis's. add_part bakes a part by a 3x3 matrix, normals by its inverse transpose; the one-piece model goes through it too. - Role 3, the model's (white under its texture, else the entity's colour), so an untextured rung keeps role 2's dark. - make_rungs decimates each colour role on its own. A coarse rung kept no roles, so the wheels would have taken the body's colour. - sync_vehicle_markers keeps #1471's vehicle_wheels with the markers: a rebuild clears them, a demoted vehicle's go with its node. Test cvcgl_ariadne_entities, parted: the mesh against attach_parted_model's nodes (mirror turn and reflect, an axle offset); 40 at scale in the model's four rungs, wheels dark at each rung drawn; one rung (lod: false), each copy's chassis in its colour and its wheels dark. * vehicle_view: entity_view.h's include without a trailing comment CI's clang-format checks only the changed lines, so it would not align this comment with the unchanged scene_labels.h line under it, while a whole-file format does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1475 (its base is that branch, so this diff is FL2 alone). Once #1475 merges, this rebases onto master and retargets.
Each world entity was a scene node of its own: a box look is six boxes and
a group, so 200 vehicles were 1400 actors. On arigl, 200 kinematic vehicles
at 3.6x took 61 ms a frame (19 of runtime, 42 to 46 of drawing), and 800
took seconds.
cvc::gl::ariadne::entity_view (entity_view.h) is the view of a set of
entities, whatever feeds it:
Its bodies layer draws the entities it takes as one mesh per archetype and
LOD rung:
to mesh_lod.h and the swarm uses it there), a box look one;
sides. Near and far are left out: the renderer fits them to what it
draws, and an unposed rung is a point, so a far plane fitted to it cut
away the entities about to be drawn.
Promotion and layers:
(a camera's track.target, vehicles.watch, the vehicle a client drives),
then the nearest. An incumbent keeps its node until another is a fifth
nearer.
look as before;
promote:, threshold:) declares a layer. With none, an implicit layer
covers every entity.
Two feeds, the local and the server-side holon:
physics binding's group of the chassis bodies (bind_group), between steps,
whether the frame steps the world or Fleets: kept fleet lookups, D3 as OW7's first part, and FL2's first part (a world's vehicles drawn at scale) #1475's world_worker holon does;
entities section and the client's entity_playout poses.
sync_vehicle_markers draws only the promoted, and adds or removes nodes as
promotion changes. A boat, a mesh file look without fit, or an entity no
layer takes keeps its own node.
Test cvcgl_ariadne_entities (37 checks, 5 repeats): the implicit layer,
follow, keep, the threshold, of:, the world on a worker, and the room.
Locally, cvcgl_ariadne_labels, _scenes, _realize, _swarm, _physics and
cvcgl_room_view also pass.
arigl, 200 kinematic at 3.6x with --world-thread, alternating runs:
threshold: 100000 (each its own node);
cost.
Not yet: the other layers (flags, goals, trails, path, belief, dots,
targets, follow, headlights), of: { fleet } on a client (the room's
identities carry no fleet), and swarm_layer moving here (FL3).