Profile-Guided Optimizationとは?
profile-guided optimizationは、まず代表的なworkloadでプログラムを実行し、どのbranchや呼び出し、経路が多いかのデータを集め、そのprofileを2回目のbuildでコンパイラに渡す手法です。コンパイラはそれを使って、inlining、branchのレイアウト、hot pathの配置についてより良い判断を下します。その結果、静的なヒューリスティックではなく実際の利用に合わせて調整されたコードが得られます。
なぜ重要か
どの経路が実際にホットかを知ることで、コンパイラは一般的なケースに合わせてコードを配置しinlineでき、推測に基づく最適化をしばしば上回ります。そのコストは、代表的なprofiling実行を伴う、より手間のかかる2パスのbuildプロセスです。
関連ガイド
What Is Just-in-Time Compilation?Just-in-time compilation translates code to native machine instructions at runtime, often focusing effort on…
What Is a Tracing JIT?A tracing JIT records the actual sequence of operations executed on a hot path and compiles that linear trace…
What Is Loop-Invariant Code Motion?Loop-invariant code motion hoists computations whose result does not change across iterations out of a loop s…