跳到正文
arXiv cs.AI· Zhiqiang Yuan, Chong Wang, Zhenhao Zhou, Junwei Liu, Xin Peng·· 12 小时前AI 评分39

C 到 Rust 转译为何性能下降?研究揭示九类问题并用 LLM 优化规则恢复性能

Where Does the Performance Go? Understanding and Recovering Performance Regressions in C-to-Rust Translation

AI 导读

研究在 20 个真实 C 项目及其 C-to-Rust 转译版本上发现,用于分析的 8 个项目中 19 项操作有 12 项转译后 Rust 比原 C 慢 3% 以上,最高慢 62.2%,并归因于九类反复出现的性能问题。作者提出基于 LLM 的工具,将这些问题编码为可复用优化规则,在 12 个留出项目的 41 项操作上全部保持 C 输出一致,其中 40 项快于转译版本、18 项快于原 C。

正文 · 原文

View PDF HTML (experimental)

Abstract:Rust is increasingly adopted as a memory-safe successor to C, and transpilers such as \crust{} can migrate entire C projects while preserving their behavior. Preserving behavior, however, does not guarantee preserving performance. We study this gap on 20 real-world C projects and their \crust{} translations. On the eight projects used for analysis, the translated Rust is more than 3\% slower than the original C on 12 of 19 operations, by up to 62.2\%. By comparing execution-cost profiles, optimized LLVM IR, and compiler optimization remarks across each C--Rust pair, we trace these slowdowns to nine recurring performance issues, spanning residual runtime work, missed compiler optimizations, and C-style source patterns, and derive an optimization direction for each. We then present \ourtool{}, an LLM-based approach that encodes these issues as reusable optimization rules to recover the performance of translated Rust. \ourtool{} profiles each project to locate hot functions and matches them against rule-specific patterns. The LLM then checks each rule's rewrite preconditions against the project context before rewriting, and a rewrite is kept only if it passes both functional and performance validation. On 41 operations from twelve held-out projects, \ourtool{} preserves C outputs on all tested workloads and speeds up 40 operations over the \crust{} translations, 18 of which end up faster than the original C. It outperforms the general-purpose coding agent \codex{} on 31 of the 37 operations where both preserve C outputs, and outperforms its own variant without rule guidance on 34 of the 41 operations.
Subjects: Artificial Intelligence (cs.AI); Programming Languages (cs.PL)
Cite as: arXiv:2610.23044 [cs.AI]
  (or arXiv:2610.23044v1 [cs.AI] for this version)
  https://doi.org/10.48550/arXiv.2610.23044

arXiv-issued DOI via DataCite (pending registration)

Submission history

From: Zhiqiang Yuan [view email]
[v1] Fri, 16 Oct 2026 07:22:54 UTC (560 KB)

来源:arXiv cs.AI · arxiv.org