High-performance code search tool, faster alternative to ack with git ignore support and parallel processing
The Silver Searcher (ag) is a code search tool designed as a faster alternative to ack. It searches through codebases with significantly improved performance, achieving speeds up to 34x faster than ack in benchmarks. The tool automatically respects .gitignore and .hgignore patterns, and supports custom .ignore files for excluding specific file patterns from searches.
The performance improvements come from several technical optimizations: multithreaded searching using Pthreads to leverage multiple CPU cores, memory-mapped file reading instead of buffering, Boyer-Moore string search algorithm for literal matches, and PCRE JIT compilation for regex searches. It also pre-compiles regex patterns and uses binary search for ignore patterns rather than calling fnmatch() repeatedly.
Primary users are developers and anyone working with large codebases who need fast text searching. The tool integrates well with popular editors including Vim (via ack.vim plugin), Emacs (ag.el), and TextMate. It's available across all major platforms and can be installed through standard package managers. The command name 'ag' provides a shorter alternative to 'ack' while maintaining similar functionality and command-line interface patterns.
# via Homebrew
brew install the_silver_searcher
# via APT
apt-get install silversearcher-ag
# via DNF
dnf install the_silver_searcher