perf(rbd): dedupe shared TriMesh uploads in from_rapier#19
Open
haixuanTao wants to merge 1 commit into
Open
Conversation
Batched RL environments typically clone one terrain SharedShape across N envs; from_rapier re-serialized the flat BVH + pseudo-normals N times. The GPU Shape descriptor only holds ranges into the shared shape_buffers, so caching it by the parry shape data pointer uploads each unique trimesh once — vertex/index memory O(unique meshes) instead of O(envs). TriMesh only; scenes without shared trimeshes produce byte-identical buffers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U2n9RqmxTJb8UG5d1Sjw4W
haixuanTao
force-pushed
the
perf/trimesh-dedupe
branch
from
July 16, 2026 16:03
ccedf66 to
e137707
Compare
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.
What
RbdState::from_rapiernow caches the GPUShapedescriptor of eachTriMeshby its parry shape data pointer. When the sameSharedShapeArc is cloned across environments — the normal way to build batched scenes with shared terrain — the flat BVH + pseudo-normals are serialized intoshape_buffersonce and every clone reuses the descriptor (which only holds ranges into the shared buffers).Why
Batched RL training scenes routinely attach one large terrain trimesh to hundreds or thousands of environments. Before this,
from_rapierre-uploaded the mesh per env: with 3 terrain strips of a few thousand triangles across 4096 envs we measured hundreds of MB of duplicated vertex/index/BVH data; after, it's O(unique meshes) — three uploads total.Scope / safety
SharedShapeclone. Structurally-equal-but-distinct meshes are (correctly) not deduped.cargo checkclean onnexus_rbd3dandnexus_rbd2d. Running in production on our terrain-curriculum training (4096 envs × 3 shared strips) for two days.🤖 Generated with Claude Code
https://claude.ai/code/session_01U2n9RqmxTJb8UG5d1Sjw4W