Skip to content

fix(@angular/build): flush perf timings from within the diagnostic worker#33414

Open
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/flush_diagnostics_profiling
Open

fix(@angular/build): flush perf timings from within the diagnostic worker#33414
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/flush_diagnostics_profiling

Conversation

@arturovt

Copy link
Copy Markdown
Contributor

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:

Screenshot from 2026-06-18 22-15-54

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@arturovt arturovt force-pushed the fix/flush_diagnostics_profiling branch from ce45591 to aa0039d Compare June 18, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant