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
{{ message }}
Repository navigation
ltm: LTM_BENCH_TRACE should be cfg(any(test, feature = "ltm_bench")) instead of runtime env check #464
src/simlin-engine/src/ltm_augment.rs::generate_loop_score_variables checks a runtime env var (LTM_BENCH_TRACE) on every compile, and the read_rss_mib() helper + should_trace() + all tracing eprintln!s are compiled into production builds even though the feature is strictly a benchmarking/diagnostic aid.
A std::env::var lookup on every call to generate_loop_score_variables is a small tax (compared to the work the function already does) but the bigger issues are:
Production WASM builds carry code that reads /proc/self/status (wrapped in #[cfg(target_os = \"linux\")] so it no-ops on non-Linux, but the stub path still ships).
The dead-code bloat is non-trivial: read_rss_mib, should_trace, the eprintln! branches, and the byte-counter arithmetic all live in the release binary.
Environment-variable feature gates invite accidental activation in deployed environments; a cargo feature makes the boundary explicit.
Proposed fix
Gate the tracing machinery behind #[cfg(any(test, feature = \"ltm_bench\"))] (or just a dedicated ltm_bench feature) and inline a no-op shim for the default build. The trace_on check, the byte counter, and the entire read_rss_mib/should_trace pair would then compile out entirely in the common case. Callers that benchmark LTM compilation can enable the feature explicitly when running the benches in benches/compiler.rs.
Severity
Low. The runtime cost is negligible and the correctness impact is zero. This is a code-organization / build-hygiene issue.
Discovery context
Noted during adversarial review of PR #461 (branch ltm-perf-enable-always).
Files
src/simlin-engine/src/ltm_augment.rs:143-188 (tracing machinery in generate_loop_score_variables)
Activity
engine: close LTM auto-flip gaps flagged in review
engine: close LTM auto-flip gaps flagged in review
doc: refresh LTM tech-debt entries after triage of open issues
engine: gate LTM loop-score tracing behind ltm_bench feature