perf(@angular/build): use iterative post-order AST traversal for OXC transforms - #33951
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a custom, non-recursive post-order AST traversal utility (traversePostOrder) in packages/angular/build/src/tools/oxc/traversal.ts to replace the existing AST visitor and walk utilities in i18n-inliner-worker.ts and oxc-transform.ts. This custom traversal is designed to optimize performance by fast-pathing common AST nodes and pruning non-executable TypeScript type subtrees. The review feedback highlights several critical correctness issues and optimization opportunities in the new traversal logic: (1) pruning all nodes starting with 'TS' incorrectly skips executable TypeScript nodes like enums and namespaces; (2) class and member decorators are currently skipped during traversal; and (3) explicit fast-paths can be added for template literals and tagged template expressions to further improve performance.
…transforms Replace the recursive Visitor class from oxc-parser with a specialized iterative post-order AST traversal implementation. The new traversal implementation eliminates per-file visitor instantiation and internal cache overhead, prunes non-executable TypeScript type subtrees at the root, and uses monomorphic property access for high-frequency AST node types. It also provides stack safety with a single tree-depth array stack and is shared between the OXC transformer and the i18n inliner worker.
4b7e3bb to
46a90e2
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
Replace the recursive Visitor class from oxc-parser with a specialized iterative post-order AST traversal implementation.
The new traversal implementation eliminates per-file visitor instantiation and internal cache overhead, prunes non-executable TypeScript type subtrees at the root, and uses monomorphic property access for high-frequency AST node types. It also provides stack safety with a single tree-depth array stack and is shared between the OXC transformer and the i18n inliner worker.