Repository navigation
Ariadne runtime frame: state paths kept resolved between frames (structure epoch, state_key) - #1477
Merged
Merged
Conversation
…cture epoch, state_key)
The runtime frame (AriRuntime::frame -> AppRuntime::drain) looked up every key it read or wrote
by path every frame: the root through the app's data map under a named mutex, then a lock and a
map search per segment. In demo3-ari that and the telemetry's formatting were most of the frame.
- cvc::state::structureEpoch(): a count shared by a tree's nodes that moves when a node is made
or taken out, or a link is set, cleared or changes mode or writability; never on a write.
- cvc::state_key (state_key.h): a path resolved once (physical or through links, as the call it
replaces), walked again only after the epoch moved; it pins what it resolved (pin_vector).
- Kept this way: scene visible:, opacity:, clip offsets, repeat: counts, ribbon and link sources
and bound numbers, the scene clock's keys, SceneWorld's physics.stats.* and its keys,
WorldVehicles' telemetry, pose, intent and table keys.
- SceneWorld: step_ms_history formatted once a step, num() by snprintf("%.17g") (the same text
as the ostream it replaces). WorldVehicles: an entity's numbers formatted again only when they
changed, stats lines likewise, parse_poses without per-character strings (from_chars where it
reads the whole token, else stod), the poses table's specs made only to spawn.
- state::value(string): one lock for the link, read-only and equality checks.
Same keys, same text, written as often. cvcgl_ariadne_frame (a demo3-ari-shaped scene, 12 pose
vehicles) times the adapter's frame: 1.17-1.21 ms -> 0.60-0.70 ms here, visible: sync 89-98 us
-> 9.5-11 us; tick_scene's instructions -50% (callgrind).
transfix
enabled auto-merge (squash)
November 23, 2026 01:52
This was referenced Nov 23, 2026
…e-frame-epoch # Conflicts: # src/cvc/ariadne/scene_world.cpp
transfix
added a commit
that referenced
this pull request
Nov 23, 2026
loader.cpp conflicted where both sides add functions after load_file, in the yaml build and in the stub: this branch's validate_string/validate_file and master's parse_value (#1477). Both kept.
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.
The Ariadne runtime frame (
AriRuntime::frame→AppRuntime::drain) looked up every key it read or wrote by path, every frame. That cost is most of the frame in cvcdbg's demo3-ari. This keeps those paths resolved between frames. The keys, their text and when they're written stay the same.Where demo3-ari's frame went (Chromium profile of
AppRuntime::drain, CVC-DBG/cvcdbg's findings of 2026-11-22):tick_scenewas 74% of the drain.SceneWorld::followwas 48% of that:WorldVehicles::publish_entitiestook 35% of follow andSceneWorld::publish_stats31.5%.GlSceneAdapter::sync_visibilitywas 24%, andRibbonBinding::tick10%.cvc::statepath lookups (findThroughLinksShared,findDescendant,operator()),state::instance(a named mutex and a data-map lookup per call), number formatting and mutexes.What changes
cvc::state::structureEpoch()removeChild,sweepExpired,reset(false)), or when a link is set, cleared, or changes its mode or writability. Value and data writes never move it.cvc::state_key(inc/cvc/state/state_key.h, header-only)findDescendant/operator()) and through links (findThroughLinks/childThroughLinks), so a cached key resolves exactly as the call it replaces.pin_vectors (the node before its ancestors), so it never dangles. A node taken out is let go at the key's next look.docs/STATE_API.md("Paths Kept Resolved").What keeps its paths resolved now
cvc::ariadnebind reads (bind.h):bind_key, plusread_or,read_bool_orandwriteoverloads that take a key. They cover:visible:(sync_scene_visibility);opacity:;repeat:counts;window:,value:,opacity:).SceneWorld:physics.stats.*leaf, the hash switch, the enabled key and the world'ssourcekey are kept resolved;step_ms_historyis kept as text, each step's ms formatted once when it steps, instead of all 120 values re-formatted every frame;num()usessnprintf("%.17g"), which writes the same text as the ostream atprecision(17)it replaces;nodesline counts a node's bodies without a map lookup per body.WorldVehicles: everyput,getandseed, the pose and intent keys read before each physics step, the packedposeskeys and the poses table are kept resolved. The cache is bounded at 4096 paths. It's only used on the world's thread; the methods any thread may call don't touch state.world_clock_binding: its 10 control and telemetry keys, which a scene's clock pulls and pushes every frame.No rate cap. Telemetry is still written every frame it was written before. A cap would change what a reader sees right after a
follow(physics.stats.tick), and the native numbers below didn't need one.Measured
cvcgl_ariadne_frame(new, headless) is a scene shaped like demo3-ari:posevehicles placed from a host's table rewritten every frame;visible:s.It times
sync_scene_visibility+tick_scene, which is whatAppRuntime::drainruns under AriRuntime, over 600 frames after 120 warm-up frames. Release build, Linux, 4 alternating runs of each, with the machine quieter (load ~35 on 32 cores):visible:sync / frameThe tree's shape moved 0 times in the timed frames, so no kept path walked again.
Instructions inside
tick_scene(callgrind, the same ~730 frames, so load doesn't affect them):tick_sceneSceneWorld::followWorldVehicles::publish_entitiesSceneWorld::publish_statsWorldVehicles::read_pose_keys(before each step)About 320 M in both is the vehicles' looks being realized while they spawn. Without it, a steady frame is 3.98 M → 1.79 M instructions (−55%). Most of what's left is cvcGL posing the box look's chassis and wheels (
physics_scene_binding::present,pose_vehicle_wheels), not state. demo3-ari's model look poses no wheels.Web numbers aren't measured here. The web demos run cvcpkg's published libcvc, so demo3-ari gets this only through a libcvc release plus a cvcdbg pin. Its Firefox/Chromium frame histogram needs that build.
Tests
state_test:StateStructureEpoch.*:ariadne_bind_test:SyncFollowsKeysTakenOutAndLinksSet, where visibility follows:cvcgl_ariadne_framechecks that the frame still publishes what it did:physics.stats.*, at two ticks a 60 Hz frame;entities.<id>.*, equal to its pose;visible:following written and deleted keys;