# Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance

AIでRustの性能低下を診断し、境界チェックをループ前にまとめて確かめる

Dalton Davis, Kunal Pai, Tapti Palit · arXiv · 2026年11月24日

- **課題** Rustは添字アクセスに境界チェックを残すため、Cから移すと遅くなることがあります。原因が安全性チェックか最適化かを切り分けるのは難しいままでした。
- **手法** FerroScopeは、ソースコード、最適化の記録、実行トレース、ハードウェア性能カウンタをAIで組み合わせ、Rustの遅い原因を診断します。
- **結果** Selection SortのC比は、境界チェックをループ前にまとめて確かめるパスにより2.95×から1.00×に下がりました。

## 移行後の性能が読めない理由

Rustはコンパイル時に所有権と借用の規則を検査するため、時間的なメモリ安全性を実行時のコストを抑えて確保できます。そのため、OSやデバイスドライバなどのシステムソフトウェアでCからの書き換えが進んでいます。一方で、Rustは配列やベクタの添字アクセスに実行時の境界チェックを残し、これが性能に効く可能性があります。

境界チェックは条件分岐として実装されるため、コンパイラの最適化や分岐予測器の振る舞いにも影響します。分岐が増えると分岐予測ミスが増え、パイプラインが止まって実行時間が伸びるおそれがあります。ただし分岐が予測しやすければ、予測器がそのコストを隠すこともあります。

![Figure 1: Rust Code and Assembly Instructions for Simplified Rust Runtime Safety Check](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-32c54c209ae037afb835dfdb0f6e70ee.png?thumb=512)

**Fig. 1** . Rust Code and Assembly Instructions for Simplified Rust Runtime Safety Check.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの4ページ目から図の部分を抽出しています。

既存の報告も一致していません。zlibのRust実装はCより速いと報告されている一方、GNU CoreUtilsのRust版は当初遅く、その後の最適化でwcやlsがCに並びました。先行研究では安全性チェックのオーバーヘッドが最大2.49×と報告されていますが、Rustが一部のライブラリでCを上回るという報告もあります。さらに、書き換えの方針が一行ずつの翻訳か全面的な再設計かで性能特性が変わるため、原因を体系的に分析する必要があります。

## 安全性チェックの寄与を切り分ける比較設計

本研究の着眼点は、境界チェックだけを無効化したRust--を用意し、CとRustとRust--を同じ条件で並べることです。Rust--では配列、ベクタ、スライス、文字列の境界チェックと整数オーバーフロー検出を外し、参照カウントなどのチェックは残します。こうすると、Rust版の差のうちどこまでが境界チェックで説明できるかを見られます。

マクロにはSkip ListやPageRank、LibCsv、u8cが入ります。Rustの実装には添字ベースとイテレータベースなど書き方の違いもあり、同じアルゴリズムでも結果が変わります。

実験はAMD EPYC 7302PのサーバとIntel Xeon Silver 4314のサーバで行い、いずれも-O3で最適化しています。CはClang、RustはrustcでコンパイルされLLVM-21バックエンドを共有するため、両者とも同じLLVMの最適化パイプラインを通ります。結果は3回の独立実行の平均で、ハードウェア性能カウンタで分岐予測ミスやL1D、L2のキャッシュミスを、Intel Pinで分岐、ロード、ストアのトレースを取得します。L3ミスは、共有キャッシュがOSの影響を受けるため報告していません。

## FerroScopeの3フェーズ診断

FerroScopeは、Rustの実行時間がCを閾値以上上回るときだけ起動する診断パイプラインです。本評価の閾値は10%で、閾値以下の対象には診断を走らせません。診断は、プログラミングイディオム、コンパイラ最適化、マイクロアーキテクチャの3つの段階に分けられています。

フェーズ1と2は、それぞれの要因が性能差に寄与したかをyesかnoで判定し、確信度を低、中、高の3段階で付けます。各フェーズの出力は仮説として次のフェーズに渡り、次のフェーズは自分の入力で検証しなければなりません。図3は、この各フェーズの入力と最終レポートの流れを示しています。

![Figure 3: FerroScope’s AI-assisted performance debugging pipeline. The phases run only when the Rust runtime exceeds the C runtime by more than the overhead th…](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-931bad84230b2763aebf2a6e42ceb8d4.png?thumb=512)

**Fig. 3** . FerroScope’s AI-assisted performance debugging pipeline. The phases run only when the Rust runtime exceeds the C runtime by more than the overhead threshold (10% in our evaluation). Each phase records a verdict and a confidence level (low, medium, or high) in the final report. Phases 1 and 2 answer yes or no to their question, and Phase 3 names the primary driver of the overhead. Only the notes pass to the next phase, as leads that it must verify in its own inputs. Inputs marked \* also include the Rust-- build.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの8ページ目から図の部分を抽出しています。

入力にはソースコード、フレームグラフ、LLVM IR、最適化remarks、Pinの統計、perfの統計を使い、\*印の入力はRust--のビルドも含みます。Rust--との差を使うことで、安全性チェックの寄与を実装の差から切り離して見られます。FerroScopeは、手作業で得た説明をすべて再現し、多くの場合で診断を鋭くしました。著者らは、各診断を手作業の分析と照合しています。

## 境界チェックの寄与と残るオーバーヘッド

図2は、AMDとIntelでのRustとRust--の実行時間をCで正規化して比べたものです。12ベンチマーク中8件で、少なくとも1つのRust実装がCより10%以内か、Cより速くなりました。添字ベースの実装でも、オーバーヘッドの小さいものがあり、境界チェックだけでは性能劣化が決まらないことを示しています。

![Figure 2: Runtime of Rust and Rust-- normalized to C on (a) AMD and (b) Intel (1× = C runtime; lower is better). Bars above2× are truncated. The dotted line se…](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-481701d9b4c2eb2f0f59a8707800a1ac.png?thumb=512)

**Fig. 2** . Runtime of Rust and Rust-- normalized to C on (a) AMD and (b) Intel (1× = C runtime; lower is better). Bars above2× are truncated. The dotted line separates microbenchmarks (left) from macrobenchmarks (right). Benchmark abbreviations: BSrch (Binary Search), MM (Matrix Multiplication), MS (Merge Sort), QS (Quicksort), SelS (Selection Sort), SL (Skiplist), PR (PageRank), CSV-V (CSV Validation), and I (Iterator). TDR and BUI denote top-down recursive and bottom-up iterative implementations, respectively.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの6ページ目から図の部分を抽出しています。

境界チェックの寄与が大きいのは、Matrix Multiplication、再帰のMerge Sort、PageRankです。Matrix Multiplicationは、AMDで1.86×から1.67×、Intelで1.71×から1.40×に下がりました。Selection Sortは、AMDで2.93×から0.99×、Intelで1.57×から0.83×に下がり、BUI版のMerge Sortも差がほぼ消えました。一方、BFS、DFS、Binary Searchでは、境界チェックを外しても差は10%未満で、条件分岐は30%から60%減っていますが、オーバーヘッドは別の場所に残ります。

Rust--でもAMDで4件、Intelで5件がCより遅くなり、BFSとBinary Searchは20%を超えるオーバーヘッドが残りました。つまり、安全性チェック以外にも、コンパイラの最適化とマイクロアーキテクチャの相互作用によるオーバーヘッドがあります。著者らは、先行研究が残りの差をASCIIからUTF-8への変換に帰していたのとは違い、本研究のRust版はその変換を行わないと説明しています。

同じMerge Sortでも、再帰版（TDR）と反復版（BUI）ではオーバーヘッドが異なります。AMDではTDRが68%、BUIが44%、Intelでは58%と43%で、TDRのほうが大きくなります。Rustの動的分岐命令はTDRで2.13×、BUIで2.69×に増え、分岐予測ミスはおよそ18×と20×に増えました。分岐を予測器が吸収しきれないことが、この差の原因の一つと読めます。

## 境界チェックを巻き上げるLLVMパス

ホットループ内の境界チェックが高くつくことが分かったため、チェックをループの前に移すLLVMパスを作りました。その際、ループを検査なしの複製と元のループの二つに分け、前処理部で条件を一度評価して選びます。条件が成り立たない場合は元のループを残すため、Rustのパニックが起きる場所と時点は変わりません。

条件は、ループ内の各チェックが毎回成立することを保証する、ループ不変の述語φcとして導出します。規則1は誘導変数の初めと終わりを見れば途中も成立すると考え、ラップアラウンドしないことを確かめます。規則2は既存のガード条件を、規則3は条件によって値が変わる変数を候補ごとに扱い、規則4は複数カウンタの合計で上限を抑えます。規則4は、Merge Sortのmerge関数のようにカウンタが一緒に増えるループで使われます。

効果は、チェックが消えたことでLLVMが分岐をCMOVに変換できるようになったことによります。Selection Sortでは、チェックのないループが4×にunrollされ、Cと同じ形になりました。一方で、Merge Sort（TDR）には17%のオーバーヘッドが残ります。Matrix Multiplicationでは、matrix\_b\[k\]\[j\]の上限が毎回変わるため前処理部で証明できず、パスは効果がありません。

## 別名情報と抽象化のコスト

Rustは&mutと&の引数に別名がないという情報を与えますが、rustcはTBAAを出力しません。Cはstrict-aliasingの規則に基づくTBAAで、型の違うアクセスを分けます。PageRankでは、NoAliasの割合がCの14.5%に対し、Rustは24.4%でした。Rustのスライス引数が別名情報を持つことが効いていると考えられます。

行列積の添字i-j-k版では、Rustの問い合わせのNoAliasが0.0%で、Cは40.0%でした。外側のVecには別名情報が効く一方、内側の行は引数から届かないため、結果への書き込みが行のヘッダと衝突すると見なされます。内積を別のkernel関数に分け、出力を&mutで渡すと、NoAliasは18.2%に上がりました。これにより累積変数をレジスタに置けるようになり、Rustのオーバーヘッドは90.8%から46.0%に下がり、Rust--はCの5.1%以内に入りました。

![Table 7: Matrix multiplication runtimes atN= 2000. Overhead is relative to C in each group](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-c476f45019cc143d24c39001333b1604.png?thumb=512)

**Table 7** . Matrix multiplication runtimes atN= 2000. Overhead is relative to C in each group.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの16ページ目から図の部分を抽出しています。

Skiplistの主データ構造をRc\<RefCell\<\>\>からNonNullに替えると、Rc\<RefCell\<\>\>のオーバーヘッドは各フェーズで11から17%になりました。候補のコードは1.7から2.0×の命令を実行し、参照カウントの増減と二つのRefCell借用フラグの確認が、訪問するノードへの書き込みになります。ノードは64バイトで40バイトではないため、ホットなフィールドがキャッシュラインをまたぎやすくなっています。追加命令の15から20%ほどが改善余地と見積もられていますが、実行時間では数%程度です。

## 限界

評価はAMD EPYCとIntel Xeon Silverの2種類のサーバ、12ベンチマークに限られます。傾向は両機で揃うものの、オーバーヘッドの大きさは機械ごとに違います。

Binary SearchでCはプリフェッチ要求を約5倍多く出していました。プリフェッチを止められなかったため、この差が性能差をどこまで説明するかは検証できていません。

Rust--でも残るオーバーヘッドの原因は、BFSやBinary Searchで十分に特定されていません。パスはSelection SortとMerge Sort（BUI）では効きますが、Matrix Multiplicationでは効果がありません。L3キャッシュのミスは計測対象外で、共有キャッシュの影響は切り分けていません。C版からRust版の性能を予測するには、新しい性能モデルが必要です。

## 論文情報

- **著者**: Dalton Davis, Kunal Pai, Tapti Palit
- **学会・ジャーナル**: arXiv · プレプリント
- **公開日**: 2026年11月24日
- **登録日**: 2026年11月26日
- **更新日**: 2026年11月24日
- **バージョン**: v1
- **arXiv**: 2611.33490
- **カテゴリ**: cs.PF · cs.PL · cs.SE
- **ライセンス**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **掲載内容**: 論文情報・解説・論文の図

[元論文 ↗](https://arxiv.org/abs/2611.33490v1) · [PDF ↗](https://arxiv.org/pdf/2611.33490v1)

この解説は、Refivuの韓国語解説をAIで翻訳したものです。不正確な翻訳や誤りが含まれる可能性があります。論文と図の利用条件は各出典に従います。

## アブストラクト

Migrating C code to Rust can significantly improve software security, but understanding the performance implications of such migrations remains challenging. While Rust is often claimed to match C's performance, runtime safety checks, compiler optimizations, and hardware microarchitecture interact in ways that complicate performance diagnosis. We first conduct a systematic cross-layer characterization of 12 benchmarks comprising C implementations and their Rust counterparts. Our study reveals that runtime safety checks do not necessarily dominate performance overhead, as compiler and microarchitectural optimizations often mitigate their costs. Across 8 of the 12 benchmarks, at least one Rust implementation performs within 10% of its C counterpart or outperforms it. Motivated by these findings, we introduce FerroScope, an AI-assisted performance debugger that integrates source-level analysis, compiler optimization remarks, dynamic instruction traces, and hardware performance counters to diagnose performance differences between C and Rust. FerroScope reproduces our manual findings while providing more precise explanations in several cases, including identifying compiler optimizations inhibited by redundant bounds checks. Guided by these diagnoses, we develop an LLVM compiler pass that hoists redundant bounds checks through guarded loop versioning while preserving Rust's panic behavior. The pass enables downstream compiler optimizations, including loop unrolling and conditional-move conversion, reducing Selection Sort's overhead from 2.95x to 1.00x and improving Merge Sort from 1.43x to 0.91x relative to C. Together, our results demonstrate how cross-layer performance characterization and AI-assisted diagnosis can guide safety-preserving compiler optimizations for efficient C-to-Rust migration.

## 論文の図

![Table 1: Summary: Benchmark Variants and Rust’s Relative Performance to C at -O3 The benchmarks with \* indicate cases where the FerroScope analysis found addit…](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-6197dbacec929be55e9a0bcdbbc5689f.png?thumb=512)

**Table 1** . Summary: Benchmark Variants and Rust’s Relative Performance to C at -O3 The benchmarks with \* indicate cases where the FerroScope analysis found additional insights over those reported by manual analysis.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの11ページ目から図の部分を抽出しています。

![Table 5: Dynamic CMOV instruction counts for C, Rust, and Rust--. Counts are identical across AMD and Intel](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-fc3d7c952ea5c196ff66464d6a558277.png?thumb=512)

**Table 5** . Dynamic CMOV instruction counts for C, Rust, and Rust--. Counts are identical across AMD and Intel.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの14ページ目から図の部分を抽出しています。

![Table 9: Bounds-check hoisting pass runtimes in sec- onds on AMD. Parentheses compare against C as the baseline](https://refivu.com/papers/b9b8f973-d979-443f-b049-2f0218e3517a/figures/figure-31918956707b4563e3e39291e6c39649.png?thumb=512)

**Table 9** . Bounds-check hoisting pass runtimes in sec- onds on AMD. Parentheses compare against C as the baseline.

[出典](https://arxiv.org/abs/2611.33490v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dalton Davis, Kunal Pai, Tapti Palit · Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance · 論文の図を引用 · 元のPDFの18ページ目から図の部分を抽出しています。

## この論文を引用

Dalton Davis, Kunal Pai, Tapti Palit (2026). Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance. arXiv:2611.33490v1. https://arxiv.org/abs/2611.33490v1

**BibTeX**

```
@misc{davis2026cross,
  title = {{Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance}},
  author = {Dalton Davis and Kunal Pai and Tapti Palit},
  year = {2026},
  eprint = {2611.33490},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33490v1}
}
```

## ほかの論文解説

- [When Is Product Decoding of ECOC MAP-Consistent? Pair Structure and the n-vs-Rest Codes](https://refivu.com/ja/papers/91c0b439-85c0-4c82-8b80-68deaac338ab-when-is-product-decoding-of-ecoc-map-consistent.md)
- [Optimal Transport Meets t-SNE: Integrated Visualization without Batch Effects in OT-tSNE](https://refivu.com/ja/papers/d3dac575-8b8b-4708-aa8c-3d0db81121bd-optimal-transport-meets-t-sne-integrated-visualization.md)
- [Predicting Rare-Mode Collapse in Recursive Generative Training from Single-Generation Calibration](https://refivu.com/ja/papers/5c8147d8-eed2-4206-bf09-95dd28fcd1c5-predicting-rare-mode-collapse-in-recursive-generative.md)
- [The KL Divergence Is Never Negative, Except in PyTorch](https://refivu.com/ja/papers/a58a89ab-5b60-441f-9175-c03ffbd24fec-the-kl-divergence-is-never-negative-except-in.md)
- [Per-Attack Blocking Hides Catalog Vulnerability: A Weakest-Link Analysis of Tool Manifests](https://refivu.com/ja/papers/e81c6c5d-9783-464f-93c2-4b7a8263a787-per-attack-blocking-hides-catalog-vulnerability-a-weakest.md)
- [Beyond Single-Turn Privacy: Training-Data Leakage in Conversational RAG](https://refivu.com/ja/papers/51c92831-e3a5-4575-943b-50961dd4fa10-beyond-single-turn-privacy-training-data-leakage-in.md)
- [Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents](https://refivu.com/ja/papers/52e2d558-711f-4753-af6e-c88268527a9b-escaping-whack-a-mole-optimizing-documentation-as-repo.md)
- [When Random Saliency Looks Trained: Architectural Center Bias in CNN Interpretability](https://refivu.com/ja/papers/dedacf70-34e7-40a0-b505-6e9e917d078c-when-random-saliency-looks-trained-architectural-center-bias.md)
- [Zeroth-Order Forward-Only SNN Training Inspiring Neuromorphic On-Chip Learning](https://refivu.com/ja/papers/62311c6d-94fc-4546-98d2-cb89a4630c19-zeroth-order-forward-only-snn-training-inspiring.md)
- [Roboclock: A Unified Benchmark for Time-Aware Robotic Intelligence](https://refivu.com/ja/papers/d28d7b22-274f-4e81-9d24-a3d9cc69084a-roboclock-a-unified-benchmark-for-time-aware-robotic.md)
- [Demographic Encoding is Not Exposure: Fairness and Privacy in Chest X-ray Foundation Models](https://refivu.com/ja/papers/d91f434f-7371-40be-9129-9d3da0b4398c-demographic-encoding-is-not-exposure-fairness-and-privacy.md)
- [Token Pruning Needs a Protected Sink Token: Coherent Spatial Aggregation in Vision Transformers](https://refivu.com/ja/papers/ccf2a0da-8ba4-468b-bb16-97b8206e5236-token-pruning-needs-a-protected-sink-token-coherent.md)

---

AI解説には誤りが含まれることがあります。 [Refivu](https://refivu.com/ja/papers/b9b8f973-d979-443f-b049-2f0218e3517a-cross-layer-characterization-and-ai-assisted-diagnosis-of)
