rust.cpu_in_async
Performance
High
Detects CPU-intensive operations in async functions that block the tokio runtime.
Why It Matters
Section titled “Why It Matters”CPU work in async:
- Blocks runtime threads — All other tasks stall
- Destroys concurrency — Async benefits lost
- Causes timeouts — Other operations delayed
Example
Section titled “Example”// ❌ Before (blocking async runtime)async fn process() { let result = expensive_computation(); // Blocks runtime!}// ✅ After (offload to blocking thread)async fn process() { let result = tokio::task::spawn_blocking(|| { expensive_computation() }).await?;}What Unfault Detects
Section titled “What Unfault Detects”- Heavy computations in async fns
- Loops without yield points in async
- Cryptographic operations in async