Unleashing the Efficiency of Rust: An Empirical Study of Performance Bugs in Rust Projects - Cui, Chenhao; Xu, Hui (Proceedings - International Symposium on Software Reliability Engineering, 2025)
Rust is a system programming language that emphasizes both efficiency and memory safety. It achieves comparable efficiency with C/C++ by pursuing the concept of zero-cost abstraction and memory safety via its ownership scheme. As a side effect, these features may also steepen the learning curve for developers, potentially leading to the use of inefficient code in their programs. In this paper, we aim to investigate the characteristics of performance bugs that occur in real-world Rust projects. To this end, we have mined the repository of 100 well-known projects on GitHub and collected 114 performance bugs. We manually audit each case and find 8 optimization patterns unique to Rust, including three types of checking, two types of cloning, and three types of data collection. We have further designed a static analyzer for Rust-specific patterns and evaluated it through two complementary experiments: (1) a controlled micro-benchmark across 48 cases, demonstrating strong detection capability for optimizable patterns like bounds checking, and (2) a large-scale validation on 5 real-world projects (7k functions, 50K LOC) confirming practical applicability. The results advocate a tiered optimization strategy: automated fixes for less context-sensitive patterns and developer-guided solutions for complex cases like cloning. We hope our work can enhance the usability of Rust's complex yet powerful language features, empowering developers to write safe, high-performance code more efficiently.