Skip to content

Conversation

@thowell
Copy link
Collaborator

@thowell thowell commented Dec 16, 2025

the current testspeed memory report does not include memory allocated for convex collision detection (ccd)

in order to provide memory information for ccd this pr:

  • adds dataclass CCD containing memory for ccd
  • updates testspeed memory report: change utilized memory to be the sum of Model and Data memory since wp.get_mempool_used_mem_current and wp.get_mempool_used_mem_high do not include ccd memory allocated in collision_convex.convex_narrowphase (i think the memory is released after the function call?)

this update retains the property that memory is not allocated for ccd if collision_convex.convex_narrowphase is never called. however, if the function is called the ccd memory is no longer released after the call but is persistent in Data.ccd.


aloha + pot

mjwarp-testspeed ./benchmark/aloha_pot/scene.xml --nconmax=24 --njmax=128 --memory=True

this pr:

Rolling out 1000 steps at dt = 0.002...

Summary for 8192 parallel rollouts

Total JIT time: 0.68 s
Total simulation time: 4.95 s
Total steps per second: 1,656,290
Total realtime factor: 3,312.58 x
Total time per step: 603.76 ns
Total converged worlds: 8192 / 8192

Total memory: 2002.56 MB / 48640.12 MB (4.12%)
Model memory (0.27%):
 (no field >= 1% of utilized memory)
Data memory (99.73%):
 geom_xmat: 57.38 MB (2.87%)
 efc.J: 96.00 MB (4.79%)
 ccd.epa_vert: 90.00 MB (4.49%)
 ccd.epa_vert1: 90.00 MB (4.49%)
 ccd.epa_vert2: 90.00 MB (4.49%)
 ccd.epa_vert_index1: 30.00 MB (1.50%)
 ccd.epa_vert_index2: 30.00 MB (1.50%)
 ccd.epa_face: 407.25 MB (20.34%)
 ccd.epa_pr: 407.25 MB (20.34%)
 ccd.epa_norm2: 135.75 MB (6.78%)
 ccd.epa_index: 135.75 MB (6.78%)
 ccd.epa_map: 135.75 MB (6.78%)

main (528695a):

Rolling out 1000 steps at dt = 0.002...

Summary for 8192 parallel rollouts

Total JIT time: 0.69 s
Total simulation time: 4.95 s
Total steps per second: 1,654,766
Total realtime factor: 3,309.53 x
Total time per step: 604.31 ns
Total converged worlds: 8192 / 8192

Total memory: 432.81 MB / 48640.12 MB (0.89%)
Model memory (1.24%):
 (no field >= 1% of utilized memory)
Data memory (98.76%):
 xfrc_applied: 4.88 MB (1.13%)
 xmat: 7.31 MB (1.69%)
 ximat: 7.31 MB (1.69%)
 geom_xpos: 19.12 MB (4.42%)
 geom_xmat: 57.38 MB (13.26%)
 site_xmat: 4.78 MB (1.10%)
 cinert: 8.12 MB (1.88%)
 actuator_moment: 10.06 MB (2.32%)
 crb: 8.12 MB (1.88%)
 qM: 18.00 MB (4.16%)
 qLD: 16.53 MB (3.82%)
 cvel: 4.88 MB (1.13%)
 cacc: 4.88 MB (1.13%)
 cfrc_int: 4.88 MB (1.13%)
 cfrc_ext: 4.88 MB (1.13%)
 contact.frame: 6.75 MB (1.56%)
 contact.efc_address: 4.50 MB (1.04%)
 efc.J: 96.00 MB (22.18%)
 efc.quad: 12.00 MB (2.77%)
 subtree_bodyvel: 4.88 MB (1.13%)

multi_face1: wp.array2d(dtype=wp.vec3)
multi_face2: wp.array2d(dtype=wp.vec3)

def __init__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use default values or __post_init__?

value = getattr(dataclass, field.name)
fieldinfo = []
if isinstance(value, mjw.Contact) or isinstance(value, mjw.Constraint):
if any(isinstance(value, mjw_type) for mjw_type in (mjw.Contact, mjw.Constraint, CCD)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance accepts tuple as the second argument.

Suggested change
if any(isinstance(value, mjw_type) for mjw_type in (mjw.Contact, mjw.Constraint, CCD)):
if isinstance(value, (mjw.Contact, mjw.Constraint, CCD)):

@thowell
Copy link
Collaborator Author

thowell commented Dec 17, 2025

thank you for the review @hartikainen!

@thowell
Copy link
Collaborator Author

thowell commented Jan 6, 2026

closing in favor of arena memory #966

@thowell thowell closed this Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants