Skip to content
Open access

Rust Without Shortcuts: What Safety Actually Costs

2026 · IEEE Access · Vol 14, pp. 160832-160855 · 0 citations · 47 references

Abstract

Memory-unsafe languages remain the dominant root cause of severe software vulnerabilities, and national cybersecurity guidance now treats migration to memory-safe languages as a structural requirement. Automated C-to-Rust translation reports four to five percent runtime overhead, but on small programs that avoid dynamic allocation and complex aliasing. This article measures what memory safety costs as a function of the mechanism that enforces it, across twelve build configurations of ten languages and fourteen workloads, on bare-metal ARM64 and x86-64 Linux hosts and an Apple laptop. Seven metrics are captured, including hardware performance counters and a compiler-enforced unsafe-construct count of zero throughout. Across the controlled twelve benchmarks, hand-written safe Rust runs at a median of 0.99 to 1.03 times C and within 1.03 to 1.10 times its peak memory, while every configuration enforcing safety at run time—tracing collection under a just-in-time or ahead-of-time compiler, or automatic reference counting—costs 1.7 to 2.9 times Rust’s aggregate wall time under the cold-process measurement model used here. Their memory cost is uneven: 1.6 to 1.9 times Rust for Go and C# NativeAOT, 5.7 times for Swift, and an order of magnitude or more for the four just-in-time configurations. Toggling Zig’s runtime bounds and overflow checks on one source isolates that cost at 16 to 17 percent on every platform, while still leaving use-after-free reachable. The overhead is not a language constant either: on one numerical kernel, identical Rust source retires half of C’s instructions on ARM64 and two-thirds more on x86-64, an inversion no single-platform study can detect and that the generated code shows is not explained by vectorisation.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.