I built a file watcher in Rust that's faster than watchexec (and way faster than nodemon) - would love feedback

182 points Crazywolf132 28 comments

Hey r/rust! 👋

I've been working on a file watcher called Flash and wanted to share it with the community. I know there are already great tools like watchexec out there, but I had some specific needs that led me to build this.

What it does

Think nodemon but more general purpose and written in Rust. It watches files and runs commands when they change - pretty standard stuff.

Why I built it

I was frustrated with slow startup times when using file watchers in my development workflow. Even a few extra milliseconds add up when you're restarting processes hundreds of times a day. I also wanted something with better glob pattern support and YAML config files.

The numbers (please don't roast me if I messed up the benchmarks 😅)

  • Startup: ~2.1ms (vs 3.6ms for watchexec, ~35ms for nodemon)
  • Binary size: 1.9MB (vs 6.7MB for watchexec)
  • Memory: Pretty low footprint

I used hyperfine for timing and tried to be fair with the comparisons, but I'm sure there are edge cases I missed.

What makes it different

  • Fast mode: --fast flag skips unnecessary output for maximum speed
  • Flexible patterns: Good glob support with include/exclude patterns
  • Config files: YAML configs for complex setups
  • Process management: Can restart long-running processes or spawn new ones
  • Built-in stats: Performance monitoring if you're into that

Example usage

# Basic usage
flash -w "src/**/*.rs" -c "cargo test"

# Web dev with restart
flash -w "src/**" -e "js,jsx,ts" -r -c "npm start"

# With config file
flash -f flash.yaml

The honest truth

  • It's not revolutionary - file watchers are a solved problem
  • Probably has bugs I haven't found yet
  • The "blazingly fast" claim might be a bit much, but hey, it's Rust 🦀
  • I'm sure there are better ways to do some things

What I'd love feedback on

  1. Performance: Did I benchmark this fairly? Any obvious optimizations I missed?
  2. API design: Does the CLI feel intuitive?
  3. Use cases: What features would actually be useful vs just bloat?
  4. Code quality: Always looking to improve my Rust

Links

I'm not trying to replace watchexec or anything - just scratching my own itch and learning Rust. If it's useful to others, great! If not, at least I learned a lot building it.

Would love any feedback, criticism, or suggestions. Thanks for reading! 🙏


P.S. - Yes, I know "blazingly fast" is a meme at this point, but the startup time difference is actually noticeable in practice