You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
… layer
Console timing panel now breaks env_step down into env-internal sub-stages
(apply_action / physics / transition / reset / observation, with nested
detail such as transition -> read and reset internals), and an optional TBB
threading layer removes an OpenMP wakeup storm on many-core machines.
- TorchEnv: opt-in Perf instrumentation on step, mirroring ArrayEnv scope names
- MotrixSim sim_data.execute: active_perf_scope("read") nests under the
caller's stage (transition/reset) without touching concrete environments
- async collector: enable the wrapped env's Perf, report sub-stage means as
dotted paths; worker rebuilds them into the nested panel tree (folding
scalar totals into nodes so either arrival order works)
- motrix-env-core: pinned tbb extra + preload_tbb() (full-path RTLD_GLOBAL
preload of <venv>/lib/libtbb.so.12) called in ManagerEnv.__init__, so numba
auto-selects the TBB layer without LD_LIBRARY_PATH; silent no-op otherwise
- workspace root exposes the tbb extra
Measured on g1-wbt-dance @4096 envs (192-core): evaluate 8.4ms -> 1.0-1.3ms
(OMP thread-wakeup storm, ~30 effective threads -> ~180), end-to-end
throughput 132.5k -> 163k env-steps/s (+23%). On 32-core machines the two
layers are equivalent (1.49 vs 1.52ms).
FastSacEnvWrap.env always exposes the original environment, so read it
directly; only the optional Perf capability stays probed. The collector
test fake now implements the .env contract instead of the production code
silently tolerating its absence.
…honest elapsed anchor
- console: Run progress card now shows elapsed and an ETA estimate (from
the cumulative iteration rate); the plain-text header gains the same eta
- Perf.stage_mean_ms(root): per-call mean ms of every sub-scope under a
root, keyed by dotted path — the tree-flattening moves next to the data
structure and the collector only adds its env_step_ prefix
- async learner: anchor elapsed/ETA (and the first rate window) at the
first ingested collector batch instead of learner readiness — the
collector's env build (scene compile, numba JIT) can outlast the learner
build by tens of seconds, which previously showed up as a large elapsed
on the first panel
sync_wait_writer & friends become sync.wait_writer, and env_step stages
become env_step.physics.read — one protocol for all nesting. The worker
now rebuilds the panel tree with a single rule (split on '.') and zero
per-prefix special cases; the scalar-total folding already handles either
arrival order. TensorBoard scalar names and the async-trainer design doc
follow the same dotted form.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
There are a few confirmed correctness/documentation issues (Markdown inline-code formatting and ETA/duration formatting edge cases) plus a small performance improvement opportunity (cache preload_tbb()), which should be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
This PR adds richer, nested performance timing instrumentation across env stepping and async FastSAC training, and introduces an optional Intel TBB threading layer preload to avoid OpenMP wakeup overhead on many-core hosts.
Changes:
Add nested env_step sub-stage timing (apply_action/physics/transition/reset + MotrixSim read scope) and merge dotted-path timing into a stable tree in the async worker/panel.
Add optional tbb extra + installer flag to preload libtbb.so.12 (RTLD_GLOBAL) before numba parallel kernels run, improving throughput on many-core machines.
Extend tests to cover dotted-path timing flattening, tree rebuild order-independence, and collector reporting of env_step substages.
- _format_duration: clamp negative inputs and document the 0m45s form
- preload_tbb: cache the probe result; ManagerEnv constructs per env and
should not repeat the glob + CDLL work
- wiki: fix nested backticks breaking markdown rendering
Adds the option to the install reference table in both languages and a
short section explaining when the TBB threading layer matters (many-core
training servers) and that it auto-activates once installed.
The start-time anchoring logic resets last_log_time but leaves last_log_step at the original resume_step, so the first logged steps_per_second window can be inflated (numerator counts steps since resume, denominator counts time since the first ingested batch). Reset last_log_step when anchoring so the first window rate matches the anchored time base.
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
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.
Summary
排查 g1-wbt-dance 训练 collector 卡点(env_step 29ms 中 transition 占 9.8ms)过程中落地的两类改进:
1. Console Timing 面板:env_step 子阶段树
TorchEnv.step接入Perf打点(apply_action / physics / transition / reset),scope 命名与ArrayEnv一致sim_data.execute()用active_perf_scope("read")记录原生批量读取,自动挂到调用方阶段下(transition / reset),无需修改任何具体环境面板效果:按
2切换 Timing 页后可直接看到 physics / transition(read) / evaluate / reset(backend_apply…) 的耗时与占比。2. 多核机器的 OpenMP 唤醒风暴修复(可选 TBB 层)
根因链:evaluate 每次 wall 8.4ms 但 CPU 只有 ~30 个有效线程 ——
OMP_WAIT_POLICY=PASSIVE下 192 个 OMP 线程每次 kernel 调用都要唤醒,barrier 长尾支配 wall time;OMP ACTIVE 自旋更糟(与 physics 线程池抢核)。motrix-env-core新增 pinnedtbbextra(tbb==2021.13.0),workspace 根暴露--extra tbbpreload_tbb()以完整路径RTLD_GLOBAL预加载<venv>/lib/libtbb.so.12(PyPI wheel 不含 Python 模块,numba 裸名 CDLL 找不到库),ManagerEnv.__init__在首个并行 kernel 前自动调用;未安装 extra 时静默回退默认层测量数据
Test plan
motrix_rl全量测试(console 嵌套树渲染、collector 点分路径上报、worker 嵌套回归测试)motrix_env_core全量测试 + TorchEnv / perf 模块测试