Skip to content

rust.io_in_hot_path

Performance High

Detects I/O operations in performance-critical code paths that block execution.

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
// ❌ 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()
}
  • File reads inside loops
  • Network calls in iterators
  • Database queries per item

Unfault can hoist I/O operations outside loops.