What's the fastest way to read a lot of files?

Here's how you can use jwalk for this:

jwalk::WalkDir::new(linux_dir())
    .parallelism(Parallelism::RayonNewPool(0))
    .into_iter()
    .par_bridge()
    .filter_map(|dir_entry_result| {
        let dir_entry = dir_entry_result.ok()?;
        if dir_entry.file_type().is_file() {
            let path = dir_entry.path();
            let text = std::fs::read_to_string(path).ok()?;
            if text.contains("hello world") {
                return Some(true);
            }
        }
        None
}).count();

I hope you can try that out and bench against a more custom solution and report back results. I'm curious! :slight_smile: