[論文レビュー] Conditional Execution of Transpiler Passes Based on Per-Script Feature Detection
The paper proposes a selective transpilation approach in Google Closure Compiler that tracks per-script language features to skip unnecessary passes, reducing build time and resource usage while preserving correctness.
As the ECMAScript specification evolves, industrial-scale JavaScript compilers face the challenge of supporting modern language syntax while maintaining compatibility for diverse execution environments. Traditionally, compilers solve this by running transpilation passes in a monolithic pipeline, where the transpilation passes are chosen to execute strictly based on a target language level. This results in significant computational waste, as compilers perform expensive Abstract Syntax Tree (AST) traversals to lower features that may not exist in the actual input source code. We present a compiler improvement that conditionally executes transpiler passes based on accurately tracking and dynamically maintaining the exact set of language features present in the compilation unit throughout the transpilation process. It is implemented in the production Google Closure Compiler. By populating and maintaining a FeatureSet at every JavaScript script-level, it dynamically skips running unnecessary lowering passes. We detail the architectural safeguards -- including strategic pass ordering and dynamic validation of the transpiled code for feature-correctness. Evaluation of this improvement on large-scale production monorepos produced a considerable reduction in compilation time and saved compute and memory usage.
研究の動機と目的
- Motivate reducing transpilation work by considering actual features used in each script.
- Introduce a per-script FeatureSet to gate transpiler passes dynamically.
- Ensure correctness through safeguards like feature propagation, validation, and post-transpile checks.
- Evaluate performance benefits in large-scale production monorepos and demonstrate correctness.
提案手法
- Record input features on each SCRIPT node during parsing.
- Map each transpiler pass to the features it lowers.
- Dynamically maintain a script-level FeatureSet, propagating synthetic features and enforcing a Transpiled-Away set.
- Apply a gate: run a pass only if it handles a feature present in the script and not in the target level.
- Maintain safeguards: strategic pass ordering, dynamic tracking, AST validation, and post-transpile verification.
実験結果
リサーチクエスチョン
- RQ1Can per-script feature tracking reliably determine when transpilation passes are needed?
- RQ2Does selective transpilation reduce compile time and resource usage without affecting output semantics?
- RQ3What architectural safeguards are necessary to prevent feature leakage or incorrect lowering?
- RQ4How does the approach perform on large production monorepos across diverse JavaScript language levels?
主な発見
| Metric | Result |
|---|---|
| Transpilation Time (Large Apps) | 50% Reduction |
| Mean Compilation Stage Latency | 12% Reduction |
| Redundant Transpiler Passes Skipped | 30% – 40% |
| Daily Production Executions | ≈ 900,000 |
- Total transpilation time for large apps reduced by about 50% in the evaluated workloads.
- Mean compilation stage latency decreased by about 12%.
- 30%–40% of transpiler passes were redundant in the legacy model for typical ES5-targeted apps.
- Daily production compilations are roughly 900,000 executions in the evaluated environment.
- Selective transpilation maintains output equivalence with the legacy model as shown by differential and code-size tests.
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。