fix(@angular/build): flush perf timings from within the diagnostic worker - #33414
fix(@angular/build): flush perf timings from within the diagnostic worker#33414arturovt wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces cumulative duration resetting and logging around the diagnostic collection phase in AngularCompilation.diagnoseFiles, along with a new test suite to verify this behavior. The review feedback points out a critical issue: running this lifecycle on the main thread (when parallel compilation is disabled) would prematurely clear and print cumulative timings. The reviewer suggests restricting this profiling lifecycle to worker threads by checking isMainThread from node:worker_threads via a helper method shouldFlushPerformanceTimings(), which can also be overridden in tests to maintain test coverage.
…rker When ParallelCompilation is used, diagnoseFiles() runs in a worker thread. The cumulative duration Map (populated by profileSync(..., cumulative=true) inside collectDiagnostics) lives in that worker's module memory — the main thread's logCumulativeDurations() call never sees it, so timings were silently dropped. Fix by owning the full reset→log cycle inside diagnoseFiles() itself, with a try/finally to guarantee the flush even if diagnostics throw. Also adds unit tests covering call order, the empty-diagnostics path, result correctness, and the throw-still-flushes guarantee.
ce45591 to
aa0039d
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When ParallelCompilation is used, diagnoseFiles() runs in a worker thread. The cumulative duration Map (populated by profileSync(..., cumulative=true) inside collectDiagnostics) lives in that worker's module memory — the main thread's logCumulativeDurations() call never sees it, so timings were silently dropped.
Fix by owning the full reset→log cycle inside diagnoseFiles() itself, with a try/finally to guarantee the flush even if diagnostics throw.
Also adds unit tests covering call order, the empty-diagnostics path, result correctness, and the throw-still-flushes guarantee.
Result: