refactor(@angular/build): bypass worker dispatch for untransformed files in JS transformer - #33797
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the JavaScriptTransformer to support Uint8Array inputs, optimizing performance by avoiding UTF-8 decoding when no sourcemap comments are present and transferring standalone ArrayBuffers to worker threads. However, removing the throttle wrapper from the file transformation method can lead to EMFILE errors and memory exhaustion due to concurrent file reads. To address this, the throttle should be kept at the file-reading level and removed from the worker pool dispatch to prevent deadlocks. Additionally, the sourcemap comment detection should be made more robust by searching for sourceMappingURL= to capture legacy and block comment formats.
…les in JS transformer Make transformData symmetrical to accept both string and Uint8Array inputs, allowing transformFile to directly delegate to transformData after reading from disk or cache. When no transformations are required, untransformed files bypass worker pool dispatch, thread synchronization, and string decoding overhead. In addition, introduce a fast byte-level check on raw ASCII bytes using a pre-allocated comment buffer to immediately return untouched buffers when no sourcemap comment exists.
2e7a666 to
9f90003
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
Make transformData symmetrical to accept both string and Uint8Array inputs, allowing transformFile to directly delegate to transformData after reading from disk or cache. When no transformations are required, untransformed files bypass worker pool dispatch, thread synchronization, and string decoding overhead. In addition, introduce a fast byte-level check on raw ASCII bytes using a pre-allocated comment buffer to immediately return untouched buffers when no sourcemap comment exists.