rust.unbounded_concurrency
Scalability
High
Detects spawning tasks without concurrency limits that can exhaust system resources.
Why It Matters
Section titled “Why It Matters”Unbounded concurrency:
- Exhausts memory — Too many tasks consume RAM
- Starves CPU — Excessive context switching
- Causes cascading failures — System-wide instability
Example
Section titled “Example”// ❌ Before (unbounded task spawning)for item in items { tokio::spawn(process(item));}// ✅ After (with concurrency limit)use futures::stream::StreamExt;
futures::stream::iter(items) .map(|item| tokio::spawn(process(item))) .buffer_unordered(100) // Limit concurrent tasks .collect::<Vec<_>>() .await;What Unfault Detects
Section titled “What Unfault Detects”- Unbounded task spawning in loops
- Missing semaphore guards
- No concurrency limits on parallel work
Auto-Fix
Section titled “Auto-Fix”Unfault can add concurrency limiting with buffer_unordered or semaphores.