rust.io_in_hot_path
Performance
High
Detects I/O operations in performance-critical code paths that block execution.
Why It Matters
Section titled “Why It Matters”I/O in hot paths:
- Blocks threads — Sync I/O stalls execution
- Increases latency — Disk/network ops are slow
- Reduces throughput — Can’t process other requests
Example
Section titled “Example”// ❌ Before (file I/O in hot path)fn process_items(items: &[Item]) -> Vec<Result> { items.iter().map(|item| { let config = std::fs::read_to_string("config.json")?; // I/O per item! process_with_config(item, &config) }).collect()}// ✅ After (load once, use many)fn process_items(items: &[Item]) -> Vec<Result> { let config = std::fs::read_to_string("config.json")?; items.iter().map(|item| { process_with_config(item, &config) }).collect()}What Unfault Detects
Section titled “What Unfault Detects”- File reads inside loops
- Network calls in iterators
- Database queries per item
Auto-Fix
Section titled “Auto-Fix”Unfault can hoist I/O operations outside loops.