Repository navigation
Fix O(N)/O(N^2) camera-pose resolution stall under PhysX + Newton ren… #6554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
051dec8
4448d31
37c7ba6
af30c9e
e1dec94
87035a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed a quadratic path lookup in :class:`~isaaclab.scene_data.SceneDataProvider` transform | ||
| mapping that stalled setup at high rigid-body counts (thousands of environments). The | ||
| per-item ``list.index`` scan is now an ``O(N)`` dictionary lookup. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed camera world-pose resolution stalling (and benchmark timeouts) at high environment | ||
| counts under the PhysX backend. The Fabric frame view no longer rebuilds a whole-scene | ||
| path-to-index map on every environment reset; resolved indices are cached and recomputed | ||
| only when the prim selection changes. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,22 +491,48 @@ def _refresh_active_bundle_if_needed(self) -> None: | |
| self._rebuild_ro_arrays() | ||
|
|
||
| def _rebuild_ro_arrays(self) -> None: | ||
| """Rebuild the four ``_sel_ro``-keyed indexed arrays (children + parents).""" | ||
| self._ro_fabric_indices = self._compute_fabric_indices(self._sel_ro) | ||
| """Rebuild the four ``_sel_ro``-keyed indexed arrays (children + parents). | ||
|
|
||
| The view->fabric index maps change only when the selection's prim set | ||
| changes, but resolving them costs a ``str(Sdf.Path)`` over every prim in | ||
| the selection (the whole env hierarchy, ~1.1M prims at 8192 envs). So the | ||
| (small) resolved index arrays are recomputed only when the selection size | ||
| changes; the indexed-fabric-array wrappers below are always rebuilt since | ||
| the underlying buckets may have moved. | ||
| """ | ||
| n = len(self._sel_ro.GetPaths()) | ||
| if getattr(self, "_ro_cached_n", None) != n: | ||
| # Cache only the tiny resolved indices on the host (a few KB), NOT the | ||
| # giant per-selection path->index dict. | ||
| self._ro_child_idx_host = self._compute_fabric_indices(self._sel_ro).numpy() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why .numpy() here? |
||
| self._ro_parent_idx_host = self._compute_parent_fabric_indices(self._sel_ro).numpy() | ||
| self._ro_cached_n = n | ||
| # Fresh device arrays each rebuild (do not alias one cached wp.array across | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this comment |
||
| # the churning per-reset wrappers). | ||
| self._ro_fabric_indices = wp.array(self._ro_child_idx_host, dtype=wp.int32, device=self._device) | ||
| self._ro_parent_fabric_indices = wp.array(self._ro_parent_idx_host, dtype=wp.int32, device=self._device) | ||
| self._world_ifa_ro = self._build_indexed_array(self._sel_ro, self._WORLD_MATRIX_NAME, self._ro_fabric_indices) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wny do we create new indices here? Can't we use the cached ones directly? |
||
| self._local_ifa_ro = self._build_indexed_array(self._sel_ro, self._LOCAL_MATRIX_NAME, self._ro_fabric_indices) | ||
| self._ro_parent_fabric_indices = self._compute_parent_fabric_indices(self._sel_ro) | ||
| self._parent_world_ifa_ro = wp.indexedfabricarray( | ||
| fa=wp.fabricarray(self._sel_ro, self._WORLD_MATRIX_NAME), | ||
| indices=self._ro_parent_fabric_indices, | ||
| ) | ||
|
|
||
| def _rebuild_rw_arrays(self) -> None: | ||
| """Rebuild the four ``_sel_rw``-keyed indexed arrays (children + parents).""" | ||
| self._rw_fabric_indices = self._compute_fabric_indices(self._sel_rw) | ||
| """Rebuild the four ``_sel_rw``-keyed indexed arrays (children + parents). | ||
|
|
||
| See :meth:`_rebuild_ro_arrays`: the resolved index arrays are recomputed | ||
| only when the selection size changes; the wrappers are always rebuilt. | ||
| """ | ||
| n = len(self._sel_rw.GetPaths()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caching on just the length feels fragile. But better caching like computing a hash might make this slow again... |
||
| if getattr(self, "_rw_cached_n", None) != n: | ||
| self._rw_child_idx_host = self._compute_fabric_indices(self._sel_rw).numpy() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why numpy() here? |
||
| self._rw_parent_idx_host = self._compute_parent_fabric_indices(self._sel_rw).numpy() | ||
| self._rw_cached_n = n | ||
| self._rw_fabric_indices = wp.array(self._rw_child_idx_host, dtype=wp.int32, device=self._device) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wny do we create new indices here? Can't we use the cached ones directly? |
||
| self._rw_parent_fabric_indices = wp.array(self._rw_parent_idx_host, dtype=wp.int32, device=self._device) | ||
| self._world_ifa_rw = self._build_indexed_array(self._sel_rw, self._WORLD_MATRIX_NAME, self._rw_fabric_indices) | ||
| self._local_ifa_rw = self._build_indexed_array(self._sel_rw, self._LOCAL_MATRIX_NAME, self._rw_fabric_indices) | ||
| self._rw_parent_fabric_indices = self._compute_parent_fabric_indices(self._sel_rw) | ||
| self._parent_world_ifa_rw = wp.indexedfabricarray( | ||
| fa=wp.fabricarray(self._sel_rw, self._WORLD_MATRIX_NAME), | ||
| indices=self._rw_parent_fabric_indices, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching on just the length feels fragile. But better caching like computing a hash might make this slow again...