Skip to main content

Posts

Showing posts with the label Rust

Optimizing Thread Contention When Compiling Large Rust Projects on AMD Ryzen Threadripper

  Upgrading to a 64-core or 96-core AMD Ryzen Threadripper should theoretically trivialize build times. However, developers attempting to compile large Rust workspaces on these high-core-count machines frequently encounter system freezes, severe GUI lag, or sudden terminations by the Linux Out-Of-Memory (OOM) killer. Throwing 128 hardware threads at  cargo build  without architectural awareness often degrades performance rather than improving it. To optimize Rust compilation on workstation-grade hardware, we must address how  rustc , the LLVM backend, and the linker interact with CPU caches and system memory. Here is the technical breakdown of why a Threadripper struggles with default Cargo configurations and the exact steps to eliminate thread contention and prevent a Cargo build OOM. The Root Cause of Thread Contention and Memory Exhaustion By default, Cargo spawns one job per logical CPU core. On a 64-core/128-thread Threadripper, a standard  cargo build ...

Fixing 'Future cannot be sent between threads safely' in Rust Async Traits (2026 Guide)

  You have just finished refactoring your direct struct calls into a clean, abstract interface. You define an   async fn   inside your trait, update your dependency injection logic, and compile. Then, the Rust compiler halts with the error that keeps backend engineers awake at night: error: future cannot be sent between threads safely Specifically, you see that the trait bound  impl Future: Send  is not satisfied. When working with Tokio, this error stops you cold. It usually happens because you are trying to execute a trait method inside a  tokio::spawn  block, and the compiler cannot guarantee that the future generated by your trait implementation is thread-safe. This guide covers the root cause of this thread-safety violation in async traits and provides the modern, idiomatic fix for Rust 2024/2026 editions. The Root Cause: Opaque State Machines To fix the error, you must understand what an  async fn  actually is. When you compile an async...