Repository navigation
Conversation
…p no process state Nav, world, physics and the vendored SDF library kept process-wide state: caches, counters, flags, registries and thread-locals. They are each app's own now (app.slot), or the object's that does the work, or constants. Allowlist -72 lines (cvc 261 -> 190, cvc_physics_jolt 2 -> 1). - world: the terrain and city generators are each app's own (slot cvc.world.generators): register_terrain_generator, terrain_generator_names, make_terrain, register_city_generator, city_generator_names, to_world_params, generate_world and world_builder take the app. Every app starts with the built-ins; what one registers, another never sees. world_builder looks both generators up as it is made (it keeps them, not the app); an unknown name still fails at the first step. ariadne's make_height_field takes the app too. pycvc's generate_world uses the app's generators, or the built-ins without an app. - world: surface_registry's three ontologies are constexpr tables built at compile time (read-only data); ontology() returns const char *. graded_terrain::sample / graded_at keep their candidates on the stack (small_vector), not in thread-locals. - nav: sim_world's CVC_NAV_PROFILE flag and its per-phase sums are the world's (read when it is made), and policy_key(0)'s empty string is a member. The plant ledger's items are constexpr tables; plant_ledger_vehicle / plant_ledger_episode return std::span. grid_nav's scratch thread-locals are gone: build_sdf and astar make their own, astar_batch's queries share a pool, and sense_batch takes a caller-owned sense_scratch (a sim_world keeps one, tick to tick). - physics: world_binding's thread-locals are the binding's: who is writing its own keys (shared with its tree watch) and whether a pull read a key through a link. jolt_backend's heightfield rotation is made where used. - geometry/SDF: the legacy API's 26 globals in head.cpp (and init_all_vars, which reset them) are gone; every computation's state is its SDFContext's. octree.cpp's INF is constexpr; main.cpp's unused thread-local context is gone. Left on purpose: jolt_backend's jolt_runtime::state() use count and mutex. Jolt's factory, type registry, allocator hooks and trace/assert hooks are the library's process globals; the count guards their one setup and teardown across every world in the process, so it cannot be per app. Tests: world_generated_test adds GeneratorsAreEachAppsOwn (two apps in both orders, a later app clean) and GeneratorsOfAppsOnThreads, and checks a new app's generators are the built-ins exactly (the old test allowed more because other tests registered process-wide). nav_test adds ScratchIsTheCallersAndShareable; nav_sim_world_test adds WorldsOfSeveralAppsAreEachTheirOwn; physics_world_test adds BindingsOfSeveralAppsAreEachTheirOwn; geometry_test adds SDFV1OfSeveralAppsAreEachTheirOwn; world_roads_test adds SamplingOnThreadsAtOnceIsSamplingAlone. multi_app_integration_test's workload adds nav_world: each app registers its own terrain generator, computes an SDF of its own size, steps a sim_world from its own tree and binds a physics world to its own gravity.
This was referenced Nov 12, 2026
Closed
Owner
Author
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.
No singletons, nav/world: nav, world, physics and the SDF library keep no process state. Stacked on #1176 (Ariadne part 3); a sibling of #1182 and #1183. Breaking (4.0).
What moved, and the bugs it fixes
app.slot), and every app starts with the built-ins only.world_builderlooks its generators up when it is made and keeps them, not the app. An unknown name still throws at the first step.surface_registry's three ontologies areconstexprtables, with the same hash.graded_terrain::sample/graded_atkeep their candidate lists on the stack, not in thread-locals.sim_world: theCVC_NAV_PROFILEflag and the per-phase timing sums are each world's. The flag is read when the world is made, andpolicy_key(0)'s empty string is a member.constexprarrays.grid_nav's scratch buffers are no longer thread-locals:build_sdfandastarallocate their own;astar_batchcall's queries share a pool;sense_batchtakes a caller-ownedsense_scratch, whichsim_worldkeeps across ticks.world_binding: each binding tracks the threads writing its own keys, and whether a pull read a key through a link is a member under its mutex. Bug fixed: one binding's writes were hidden from another binding's watch on the same thread.init_all_varswere dead duplicates ofSDFContext's members, and are gone. Every computation's state is its ownSDFContext's.INFisconstexpr, andmain.cpp's unused thread-local context is gone.Public API changes
register_terrain_generator,terrain_generator_names,make_terrain;register_city_generator,city_generator_names;to_world_params,generate_world,world_builder's constructor;ariadne::make_height_field.surface_registry::ontology()returnsconst char *, and the class hasclass_count.plant_ledger_vehicle()/plant_ledger_episode()returnstd::span<const plant_ledger_item>.nav::sense_scratch;sense_batch(..., sense_scratch *scratch = nullptr).generate_worlduses the given app's generators. Its app was already optional; without one, a temporary app with only the built-ins is made, and nothing is shared.Callers updated:
terrain_lab;bundle.cpp;docs/ARIADNE.md.Allowlist: -72 lines (cvc 71, cvc_physics_jolt 1)
head.cpp, plusoctree.cpp'sINF;nav/grid_nav.cpp6,nav/plant_ledger.cpp4,nav/sim_world.cpp14;physics/world_binding.cpp2;world/generated_world.cpp4,world/road_grade.cpp6,world/surface.cpp8;kHeightfieldRotation.Not removed (please review)
jolt_runtime::state()::sstays: the use count and mutex around Jolt's own process globals (Factory::sInstance,RegisterTypes' registry, the allocator, Trace and AssertFailed hooks). Jolt has one of each per process. Counting per app would let one app's last world tear Jolt down while another app's world still uses it.Tests
world_generated_test:GeneratorsAreEachAppsOwn: two apps in both orders, and a later app starts clean;GeneratorsOfAppsOnThreads;GeneratorsByName, tightened: a new app has exactly the built-ins. The old check allowed extras only because other tests registered process-wide.nav_testScratchIsTheCallersAndShareable.nav_sim_world_testWorldsOfSeveralAppsAreEachTheirOwn.physics_world_testBindingsOfSeveralAppsAreEachTheirOwn.geometry_testSDFV1OfSeveralAppsAreEachTheirOwn(16³ and 32³ from several apps: alone, both orders, threads, a later app).world_roads_testSamplingOnThreadsAtOnceIsSamplingAlone.multi_app_integration_testgains anav_worldpart. Each app:sim_worldfrom its own tree;Locally (MSVC Release,
-j 4):app_test,multi_app_integration_test;world_*/nav_*tests run, and all 12physics_*;geometry*,algorithm_test,mtxlib_test;ariadne_loader_test,ariadne_scene_world_test;cvcgl_nav_stats_publish,cvcgl_ariadne_realize,pycvc_plant_host,pycvc_nav_agents,pycvc_nav_belief,pycvc_nav_routes,physics_replay_test.CI
Full run: the push to
ci/full/no-singletons-nav-world, https://github.com/transfix/libcvc/actions/runs/43211874618.