Commit 11b8c64
authored
Suspends Fabric USD notice listener during cloning for faster startup (isaac-sim#5432)
# Description
Adds a re-entrant context manager `disabled_fabric_change_notifies` that
suspends the `omni::fabric::IFabricUsd` USD notice listener for the
duration of bulk cloning. During `Sdf.CopySpec` loops in
`usd_replicate`, every per-prim mutation otherwise fires
`IFabricUsd::UsdNoticeListener::Handle` to do an immediate Fabric↔USD
sync — for moderately heavy scenes that single hot path can dominate
scene-load time. Toggling the listener's soft flag
(`IFabricUsd.cpp:739`) gates the work without unregistering the
listener, then the natural `SimulationContext.reset` path performs the
catch-up resync in one pass.
The same handler is what
`isaacsim.core.cloner.Cloner.disable_change_listener` toggles, but this
implementation reaches it through the underlying
`omni::fabric::IFabricUsd` Carbonite interface directly, so the cloner
has **no `isaacsim.core.simulation_manager` dependency**. Since
`omni.fabric` has no public Python binding for
`setEnableChangeNotifies`, acquisition is via a small ctypes module
modelled on the in-tree `isaaclab_newton.physics._cubric` pattern.
The context manager is wired in at the cloner-session boundary —
`clone_from_template` and the two cloning regions in `InteractiveScene`
— not inside `usd_replicate` itself, keeping the leaf USD-authoring
primitive pure.
## Motivation
This PR supersedes the approach taken in isaac-sim#5070 (still open). isaac-sim#5070
reaches the same toggle via
`isaacsim.core.simulation_manager.SimulationManager.enable_fabric_usd_notice_handler`,
which:
1. Adds an `isaacsim.core.simulation_manager` dependency to the cloner
(project policy: avoid `isaacsim.*` implementation deps).
2. Implements via a state-dict pattern + a private
`_manage_notice_handlers` kwarg leaked through public `usd_replicate`.
3. Disables the handler from inside `usd_replicate` and never re-enables
it on exit (global-state leak that survives exceptions).
This PR keeps isaac-sim#5070's measured perf win while replacing the above with a
single context manager wired in at the orchestrator boundary,
exception-safe, re-entrant, and IsaacSim-implementation-free.
### Architecture
| Concern | Where it lives |
|---|---|
| ABI-coupled ctypes binding |
`source/isaaclab/isaaclab/cloner/_fabric_notices.py` (private, ~135
lines) |
| Public context manager | `disabled_fabric_change_notifies(stage, *,
restore=True)` in `cloner_utils.py` |
| Application | `clone_from_template` body and
`InteractiveScene.clone_environments` |
The `restore=False` kwarg, used at the two scene-init sites, opts out of
the on-exit re-enable. This avoids the redundant `forceMinimalPopulate`
batch that fires when the flag flips back on; downstream
`SimulationContext.reset` performs the same Fabric resync as part of
normal startup. `restore=True` (the default) is exception-safe and is
what tests and any future direct callers get.
When the Carbonite interface can't be acquired (e.g. running outside a
live Kit application), the context manager falls through to a no-op so
callers never break — they just don't get the perf win.
## Benchmarks
`scripts/benchmarks/benchmark_startup.py`, RTX 5090, headless, warm run
(2nd of 2 invocations after kernel/extension caches populate).
| Task | num_envs | Backend | Before | After | Saved | % |
|---|---:|---|---:|---:|---:|---:|
| `Isaac-Cartpole-Direct-v0` | 4096 | PhysX | 7.41 s | 6.47 s | 0.94 s |
−12.7% |
| `Isaac-Cartpole-Direct-v0` | 4096 | Newton | 22.06 s | 22.01 s | 0.05
s | ~0% |
| `Isaac-Velocity-Flat-Anymal-C-v0` | 4096 | PhysX | 28.09 s | 14.49 s |
13.60 s | **−48.4%** |
| `Isaac-Velocity-Flat-Anymal-C-v0` | 4096 | Newton | 36.72 s | 32.99 s
| 3.73 s | −10.1% |
| `Isaac-Dexsuite-Kuka-Allegro-Reorient-v0` | 8192 | PhysX | 104.84 s |
41.94 s | 62.90 s | **−60.0%** |
| `Isaac-Dexsuite-Kuka-Allegro-Reorient-v0` | 8192 | Newton | 81.00 s |
74.17 s | 6.83 s | −8.4% |
Savings come entirely from `env_creation` (Scene Creation + Simulation
Start) and `first_step`. Non-cloning phases (`app_launch`,
`python_imports`, `task_config`) are unchanged within run-to-run noise.
Newton kitless runs see smaller wins because Fabric is only touched when
`omni.fabric` is loaded for rendering; PhysX with Kit is the primary
beneficiary.
The `first_step` collapse on heavy scenes (e.g. Dexsuite −93%, 10.8 s →
0.74 s) is the deferred Fabric resync work folding into the existing
`SimulationContext.reset` pass with much less overhead than an eager
`forceMinimalPopulate`.
## Type of change
- New feature (non-breaking change which adds functionality)
- Performance improvement
## Test plan
- `pytest source/isaaclab/test/sim/test_cloner.py` → 18 passed
- `pytest source/isaaclab_physx/test/sim/test_cloner.py` → 22 passed (2
xfailed/2 xpassed are pre-existing)
- `./isaaclab.sh -f` (pre-commit) clean
- Smoke test confirms `restore=True` round-trips the flag,
`restore=False` leaves it off, and nested context managers are
re-entrant.
## Follow-ups
- File a Kit-team request for an `omni.fabric` Python binding to
`setEnableChangeNotifies`, after which `_fabric_notices.py` can be
deleted.
- Consider an ABI-drift smoke test under `test_cloner.py` to catch
Kit-side vtable changes in CI.
## Checklist
- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there1 parent 3827956 commit 11b8c64
6 files changed
Lines changed: 503 additions & 81 deletions
File tree
- source
- isaaclab_physx/test/sim
- isaaclab
- isaaclab
- cloner
- scene
- test/scene
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
0 commit comments