arXiv Science⌕ Search

arXiv · 2611.33490

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

Abstract

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.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Dalton Davis, Kunal Pai, Tapti Palit. 2026-11-24. Cross-Layer Characterization and AI-Assisted Diagnosis of C-to-Rust Performance. https://arxiv.science/abs/2611.33490

Citations retain the original authors and DOI and include this site’s record URL. If this discovery service contributed to your research, you can also cite arXiv Science by Indiciae: BibTeX · RIS.

KEEP EXPLORING

Related papers

Accelerating Token-and-Duration Transducer ASR Inference: A Production Case Study of Parakeet TDT 0.6B

Token-and-duration transducer (TDT) models enable accurate speech transcription, but translating their model-level efficiency into high-performance GPU serving requires execution strategies tailored to the distinct demands of encoding and decoding. We present an optimized inference engine for Parakeet TDT 0.6B on an NVIDIA H100 GPU. Our stage-specific engine combines row-packed FP8 encoding, shape-specialized fusion and persistent megakernel decoding without per-step launches or host synchronization. It overlaps front-end processing with encoding and applies accuracy-gated frame merging with sequence-length restoration and selective pruning without end-to-end fine-tuning. Evaluated on Parakeet TDT 0.6B at 1,024 utterances per batch, the engine transcribes 50,058 seconds of audio per second, 14 times the throughput of the evaluated TensorRT baseline, with a lower mean word error rate (WER) and an 8.9-fold reduction in GPU energy per audio second.

cs.PF↗

ServeCast: Predicting LLM Serving Throughput and Latency Across Models from Microbenchmarks

Deciding how to deploy an LLM means predicting its throughput and latency under varying load. Benchmarking every candidate model on every GPU is expensive, and prediction is complicated by continuous batching and by request contexts that evolve. We introduce ServeCast, a performance model that follows requests with variable prompt and output lengths through admission, prefill, and decode under limited GPU memory. Its explicit parameters describe the LLM architecture and the clock and memory bandwidth of the GPU, and three timing coefficients are calibrated with microbenchmarks. To predict how a different LLM is served on the same GPU, ServeCast may transfer the performance model. The transfer updates the explicit parameters and keeps the timing coefficients fitted on a different LLM, so no re-profiling is needed. Our extensive numerical evaluation spans three GPUs, six LLMs, and three trace-derived workloads, comparing ServeCast with Vidur, a widely used simulator. When both are calibrated on the target, the aggregate mean absolute percentage error (MAPE) of ServeCast is 6.4% for mean request throughput, 11.9% for time to first token (TTFT), and 7.5% for time per output token (TPOT), against 8.9%, 25.0%, and 8.6% for Vidur, respectively. Under cross-model transfer, throughput and TPOT errors are comparable to those of Vidur, which requires calibration for each model/GPU pair, while ServeCast's aggregate TTFT predictions are still more accurate.

cs.PF↗

Improving Hit Ratios in LLM Serving: From Descriptive Characterization to Prescriptive Optimization

Workflows in modern large language model (LLM) serving systems exhibit prolonged conversations consisting of recursive prompts and responses. Due to the autoregressive nature of LLMs, a new response must be generated based on KV states of the entire conversation history. Therefore, the hit ratio, i.e., the fraction of KV caches reused directly from the memory among all KV caches in one conversation, is a crucial metric that governs the performance and economics of LLM serving. Describing the hit ratio as a function of system primitives is highly nontrivial due to the complex system dynamics; hence prescriptively optimizing the hit ratio is even more challenging. We approach the two problems by formulating the system as a stochastic multi-turn conversation model (MCM). We first characterize the hit ratio of the MCM under the widely used least-recently-used (LRU) policy through a mean-field framework. We prove that as the workflow arrival rate and the memory capacity scale proportionally, the hit ratio converges to an explicit limit. Our descriptive characterization reveals that LRU implicitly leads to a possibly suboptimal workflow quota allocation when the workflow is a mixture of heterogeneous classes. Therefore, we further propose a family of workflow-aware quota LRU (WAQ-LRU) policies that make quota allocation an explicit control decision, among which we identify the optimal quota vector, yielding a policy that dominates LRU in the mean-field limit. Experiments with Qwen3 models on Ascend NPUs fed by real-world conversation datasets validate our resulting hit ratio empirical estimator, and show substantial gains of WAQ-LRU over LRU in both hit ratio and time-to-first-token. Our results provide both descriptive and prescriptive insights into the understanding and improvement of multi-turn LLM serving.

cs.PF↗