Fast code search tool similar to ack, optimized for speed with multi-threading and memory mapping
The Silver Searcher (ag) is a code search utility designed as a faster alternative to ack and grep. It searches through source code files using parallel processing with Pthreads, memory mapping instead of buffering, and optimized string search algorithms including Boyer-Moore for literal strings and PCRE's JIT compiler for regex patterns.
The tool automatically respects version control ignore files (.gitignore, .hgignore) and supports custom .ignore files for excluding unwanted patterns like minified JavaScript files. In benchmarks, ag demonstrates significant performance improvements over ack - searching an 8GB codebase in 3.2 seconds compared to ack's 110 seconds, achieving 34x faster results by only searching relevant files (700MB after applying ignore patterns).
Developers working with large codebases benefit from ag's speed optimizations and intelligent file filtering. The tool integrates with popular editors including Vim (via ack.vim), Emacs (ag.el, helm-ag), and TextMate through plugin configurations. Its shorter command name (ag vs ack) and home-row key placement provide ergonomic advantages for frequent use.
# via Homebrew
brew install the_silver_searcher
# via APT
apt-get install silversearcher-ag
# via DNF
dnf install the_silver_searcher