Add env step/reset time profiling with per-functor breakdown - #435
Merged
Conversation
…eakdown Add EnvProfiler, a toggleable hierarchical wall-time profiler for the gym env reset/step pipeline. Zero overhead when disabled (cfg.profiler is None). - New embodichain/lab/gym/utils/profiler.py (EnvProfilerCfg + EnvProfiler). Section names are built from the active call stack (Isaac Lab Timer semantics); a parent's time includes its children. - Instrument BaseEnv.step/reset/get_obs and EmbodiedEnv manager calls. The report flushes in close() before sim.destroy() (which exits the process). - Add ManagerBase._call_functor; route EventManager.apply and ObservationManager.compute through it so every registered event/obs functor is timed automatically, nesting under the manager call site. Interval functors are timed per-firing (calls reflects interval_step), not per-step. - Split the sensor section into render_camera_group and sensor_fetch. - CLI: --profile / --profile_output on run-env. - Docs: cli.md Profiling section, env-framework & manager-functor agent context topics, gym.utils API reference. - Tests: 14 unit tests + 1 integration test (real UR10 env rollout). Co-Authored-By: Claude <noreply@anthropic.com>
…n stub The _initialize_episode instrumentation opens profiler sections around each manager call. The stub env (SimpleNamespace) used to test dataset-save selection bypasses BaseEnv.__init__, so it had no _profiler and failed with AttributeError. Add a disabled EnvProfiler (no-op section()) to the stub so it matches a real env's attributes. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Description
This PR adds
EnvProfiler, a toggleable, hierarchical wall-time profiler for the gym env reset/step pipeline, with automatic per-functor breakdown for event and observation functors.What's included:
EnvProfilerCfg+EnvProfiler(embodichain/lab/gym/utils/profiler.py). Section names are built from the active call stack (Isaac LabTimersemantics); a parent's time includes its children. No-op (zero overhead) whencfg.profiler is None.BaseEnv.step/reset/get_obsandEmbodiedEnvmanager calls are instrumented with profiler sections. The report is flushed inclose()beforesim.destroy()(which exits the process without returning to Python).ManagerBase._call_functorhelper;EventManager.applyandObservationManager.computeroute through it so every registered event/obs functor is timed individually and automatically, nesting under the manager call site. Interval functors are timed per-firing (callsreflectsinterval_step), not per-step.sensorsection is split intorender_camera_group(actual render) andsensor_fetch(data fetch).--profile/--profile_outputonrun-env.cli.mdProfiling section,env-framework&manager-functoragent-context topics,gym.utilsAPI reference.Motivation: There was no easy way to see which module in the reset/step chain (or which individual functor) dominates runtime. Now
run-env --profile ...prints a breakdown like:GPU-memory profiling is intentionally out of scope for this PR (time-only).
Dependencies: none
Type of change
Screenshots
N/A — sample report shown in Description.
Checklist
black .command to format the code base.🤖 Generated with Claude Code