All Articles
RustCLIPerformance

Building Blazing-Fast CLI Tools with Rust

May 20, 2026
8 min read

Building Blazing-Fast CLI Tools with Rust

Rust has fundamentally changed how I think about systems programming. When I set out to build a log analysis tool, I needed something that could process millions of lines per second without breaking a sweat.

Why Rust for CLI?

The combination of zero-cost abstractions, memory safety, and fearless concurrency makes Rust a natural fit. You get C-level performance without the footguns.

use std::io::{self, BufRead};
use rayon::prelude::*;

fn process_lines(path: &str) -> Vec<String> {
    let file = std::fs::File::open(path).unwrap();
    let reader = io::BufReader::new(file);
    
    reader
        .lines()
        .par_bridge()
        .filter_map(|l| l.ok())
        .filter(|line| line.contains("ERROR"))
        .collect()
}

Key Lessons

1.Use rayon for parallel iteration — it's dead simple and incredibly effective
2.Buffer your I/O — raw reads are slow; BufReader is your friend
3.Profile before optimizingcargo flamegraph is indispensable

The final tool processes 10 million lines per second on a single core, with near-linear scaling across cores via Rayon.