Dense startup time profiling#5072
Conversation
- Add error handling for YAML whitelist loading (OSError, YAMLError, type validation) - Use None instead of 0.0 for missing Timer sub-timings with info log - Warn when IsaacLab source directory is missing (empty prefix list) - Warn on unmatched whitelist patterns to catch typos - Use try/finally for cProfile disable to handle exceptions cleanly
- Fix orphaned docstring (convert to comment) - Improve main() and module docstrings for accuracy - Remove phase numbering from section comments (avoid confusion) - Fix Timer comment wording (backends -> environment types) - Fix top_n docstring (remove "per phase") - Remove dead print_startup_summary function
The humanoid observations pattern needs a leading wildcard to match the full module path (isaaclab_tasks.manager_based.classic.humanoid...).
Greptile SummaryThis PR introduces a dense startup-time profiling benchmark ( Key changes:
Three logic-level issues were found in Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as __main__
participant LS as launch_simulation()
participant M as main()
participant GYM as gym.make()
participant ENV as env
participant BP as BaseIsaacLabBenchmark
participant BE as Backend (SummaryMetrics etc.)
CLI->>LS: app_launch_profile.enable() → with launch_simulation(env_cfg, args_cli)
LS-->>CLI: context entered (app_launch_profile.disable())
CLI->>M: main(env_cfg, app_launch_profile, app_launch_wall_ms)
M->>GYM: env_creation_profile.enable() → gym.make(task, cfg)
GYM-->>M: env
M->>ENV: env.reset() [inner try/finally disables env_creation_profile]
ENV-->>M: obs
M->>ENV: env.step(actions) [first_step_profile try/finally]
ENV-->>M: obs, reward, ...
M->>BP: benchmark.add_measurement(phase, SingleMeasurement) ×N phases
M->>BP: benchmark.update_manual_recorders()
M->>BP: benchmark._finalize_impl()
BP->>BE: backend.finalize(output_path, output_filename)
BE-->>CLI: JSON + console summary printed
M->>ENV: env.close() [outer finally]
Last reviewed commit: "Document reliance on..." |
- Make --task required to fail early on missing argument
- Validate whitelist YAML values are list[str] per phase
- Warn on unknown phase names in whitelist config
- Wrap post-env-creation code in try/finally for env.close()
- Remove [UNMATCHED] prefix from placeholder labels to keep
dashboard keys stable (matches docstring/RST contract)
- Move fnmatch import to function top, replace warnings.warn
with print("[WARNING]") for consistency
- Remove stale "Launch Isaac Sim Simulator first" comment
- Use _ for unused lineno in pstats tuple unpacking
|
@greptile |
Move the try/finally guarding env.close() to wrap everything after gym.make() succeeds, so env.reset() failures also trigger cleanup.
|
@greptile |
| {"name": "seed", "data": args_cli.seed}, | ||
| {"name": "num_envs", "data": args_cli.num_envs}, | ||
| {"name": "top_n", "data": args_cli.top_n}, | ||
| {"name": "presets", "data": get_preset_string(hydra_args)}, |
There was a problem hiding this comment.
env_creation_profile left enabled on BaseException
except Exception does not catch KeyboardInterrupt, SystemExit, or any other BaseException subclass. If gym.make() is interrupted by a signal or a hard abort, the profile object is left in the enabled state for the remainder of the process lifetime, which silently continues accumulating CPU-time into the stale profile.
The standard pattern is to use a finally clause (or a bare except) so the profile is always stopped:
env_creation_profile.enable()
try:
env = gym.make(args_cli.task, cfg=env_cfg)
except BaseException:
env_creation_profile.disable()
raiseOr, more idiomatically, fold the disable into a try/finally around the whole block, the same way first_step_profile is handled a few lines below.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Antoine RICHARD <antoiner@nvidia.com>
except Exception misses KeyboardInterrupt and SystemExit, leaving the profiler enabled for the rest of the process lifetime.
Description
Allows for dense startup time profiling.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there