RustScout
A high-performance, concurrent code search tool written in Rust. RustScout is designed for quickly searching and analyzing large codebases with a focus on performance and usability.
Features
- 🚀 High Performance: Utilizes Rust's concurrency features for blazing-fast searches
- 🔍 Smart Search: Regex support with intelligent pattern matching
- 📁 File Filtering: Flexible ignore patterns and file type filtering
- 📊 Rich Output: Detailed search results with statistics
- 🛠️ Developer Friendly: Clear documentation with .NET comparison examples
Quick Start
Install RustScout using cargo:
Basic usage:
# Simple text search
# Search with regex
# Filter by file type
# Show only statistics
# Ignore specific patterns
# Control thread count
Installation
From crates.io
# Install CLI tool
# Or add library to your project
From Source
Usage Examples
Basic Search
# Search for a pattern in current directory
# Search in a specific directory
# Case-sensitive search
Advanced Pattern Matching
# Find function definitions
# Find TODO comments
# Find multiple patterns
File Filtering
# Search only Rust files
# Search multiple file types
# Ignore specific patterns
Output Control
# Show only statistics
# Show line numbers
Performance Tuning
# Set thread count
# Process large files
Library Usage
RustScout can also be used as a library in your Rust projects:
[]
= "0.1.0"
use ;
use NonZeroUsize;
use PathBuf;
Configuration
rustscout supports flexible configuration through both YAML configuration files and command-line arguments. Command-line arguments take precedence over configuration file values.
Configuration Locations
Configuration files are loaded from multiple locations in order of precedence:
- Custom config file specified via
--configflag - Local
.rustscout.yamlin the current directory - Global
$HOME/.config/rustscout/config.yaml
Configuration Format
Example .rustscout.yaml:
# Search pattern (supports regex)
pattern: "TODO|FIXME"
# Root directory to search in
root_path: "."
# File extensions to include
file_extensions:
- "rs"
- "toml"
# Patterns to ignore (glob syntax)
ignore_patterns:
- "target/**"
- ".git/**"
- "**/*.min.js"
# Show only statistics
stats_only: false
# Thread count (default: CPU cores)
thread_count: 4
# Log level (trace, debug, info, warn, error)
log_level: "info"
Command-Line Options
<PATTERN> Pattern )
)
)
)
Configuration Details
Search Pattern
- Supports both simple text and regex patterns
- For regex patterns, uses the Rust regex syntax
- Examples:
- Simple:
TODO - Regex:
FIXME:.*\b\d{4}\b
- Simple:
File Extensions
- Optional list of extensions to include
- Case-insensitive matching
- If not specified, searches all non-binary files
Ignore Patterns
- Uses
.gitignoresyntax - Supports glob patterns
- Built-in ignores:
.git/,target/ - Examples:
**/node_modules/***.bakbuild/*.o
Thread Control
- Default: Number of CPU cores
- Can be reduced for lower system impact
- Can be increased for faster searching on I/O-bound systems
Log Levels
trace: Most verbose, shows all operationsdebug: Shows detailed progressinfo: Shows important progresswarn: Shows only warnings (default)error: Shows only errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. See CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Benchmarks
Performance comparison with other popular search tools (searching a large Rust codebase):
| Tool | Time (ms) | Memory (MB) |
|---|---|---|
| RustScout | 120 | 15 |
| ripgrep | 150 | 18 |
| grep | 450 | 12 |
Note: These are example benchmarks. Actual performance may vary based on the specific use case and system configuration.
Performance
Benchmark Results
rustscout has been benchmarked against various scenarios using Criterion:
-
Simple Pattern Search (searching for "TODO" in 10 files with 100 lines each):
- Average time: ~2ms
- Consistent performance across multiple runs
- Linear scaling with file size
-
Regex Pattern Search (searching for complex patterns like
FIXME:.*bug.*line \d+):- Average time: ~5ms
- Optimized for both simple and complex patterns
- Automatic pattern optimization for literal strings
-
File Count Scaling (searching across different numbers of files):
- 5 files: ~1ms
- 10 files: ~2ms
- 25 files: ~4ms
- 50 files: ~8ms
- Near-linear scaling with file count
Performance Tips
-
Use Simple Patterns when possible:
# Faster - uses optimized literal search # Slower - requires regex engine -
Control Thread Count based on your system:
# Use all available cores (default) # Limit to 4 threads for lower CPU usage -
Filter File Types to reduce search space:
# Search only Rust and TOML files
Troubleshooting Guide
Common Issues and Solutions
-
Pattern Not Found
- Issue: Search returns no results
- Solutions:
- Check if pattern is case-sensitive
- Verify file extensions are correctly specified
- Check ignore patterns aren't too broad
-
Performance Issues
- Issue: Search is slower than expected
- Solutions:
- Use simple patterns instead of complex regex
- Adjust thread count with
--threads - Filter specific file types with
--extensions - Check if searching binary files (use
--stats-onlyto verify)
-
Permission Errors
- Issue: "Permission denied" errors
- Solutions:
- Run with appropriate permissions
- Check file and directory access rights
- Use ignore patterns to skip problematic directories
-
Invalid Regex Pattern
- Issue: "Invalid regex pattern" error
- Solutions:
- Escape special characters:
\.,\*,\+ - Use raw strings for Windows paths:
\\path\\to\\file - Verify regex syntax at regex101.com
- Escape special characters:
-
Memory Usage
- Issue: High memory consumption
- Solutions:
- Use
--stats-onlyfor large codebases - Filter specific file types
- Adjust thread count to limit concurrency
- Use
Error Messages
| Error Message | Cause | Solution |
|---|---|---|
Error: Invalid regex pattern |
Malformed regex expression | Check regex syntax and escape special characters |
Error: Permission denied |
Insufficient file permissions | Run with appropriate permissions or ignore problematic paths |
Error: File too large |
File exceeds size limit | Use --stats-only or filter by file type |
Error: Invalid thread count |
Invalid --threads value |
Use a positive number within system limits |
Error: Invalid file extension |
Malformed extension filter | Use comma-separated list without spaces |