$ show dmtrKovalenko/fff
fff (Fast File Finder) is a high-performance file search and content grep toolkit written in Rust, designed for long-running applications like code editors, AI agents, and file explorers. It provides fuzzy filename search with typo resistance, live content grep (plain text, regex, fuzzy), directory search, glob filtering, and git-aware frecency ranking. The core library maintains a persistent in-memory index with a bigram-based content prefilter, an LMDB-backed frecency and query history store, and a live filesystem watcher for incremental updates. The system is exposed through multiple interfaces: a Neovim plugin with a full TUI picker UI, an MCP server for AI assistants (Claude Code, Codex), language bindings for Python, Node.js, and Bun, and a C FFI for embedding in other languages. The architecture is a Rust core library with multiple frontends communicating via FFI or direct Rust API, all sharing the same `FilePicker` instance that manages indexing, searching, and watching. The codebase demonstrates exceptional performance engineering with SIMD-optimized string operations, compressed inverted indexes, arena-based path storage, and careful concurrency design with thread pools and lock-free snapshots.
The LLM identified 5 files worth highlighting for reuse:
Implements a compressed bigram inverted index for fast grep prefiltering. Uses dense/sparse column encoding with LEB128 gap lists, in-place compaction, and heap-bytes accounting. The build phase uses SIMD normalization and branchless two-pass construction for files under 1024 bytes. The query phase converts regex patterns to bigram queries with consecutive and skip-1 bigrams, then filters candidates via bitmask intersection. Includes a BigramOverlay for modified/deleted files since the base scan. This is a non-trivial, self-contained data structure that could be extracted for any text indexing or search application needing fast candidate narrowing.
Provides SIMD-accelerated substring search with runtime CPU detection. Implements AVX2 packed-pair search and NEON with rare-byte-pair prefilter, falling back to memchr for short patterns or unsupported architectures. The `find` and `find_case_insensitive_short` functions are used throughout the grep engine for fast content matching. This module is cleanly abstracted, has no internal dependencies beyond standard Rust, and could be extracted into any Rust project needing high-performance string search.
Implements an Arc-shared, non-reallocating vector with atomic length for lock-free snapshots. The vector reserves capacity upfront and never reallocates, allowing raw-pointer snapshots for parallel post-scan work. Provides `get_mut`/`iter_mut` for mutation (with documented UB around aliasing) and `snapshot` for read-only access. This is a clever pattern for concurrent data structures where growth is bounded and lock-free reads are critical. Could be extracted for any Rust project needing a grow-only, snapshotable vector.
Manages process-shared LMDB environments with health checks, stale reader purging, and max_readers bounds. Provides `SharedEnv` with weak-reference tracking, first-caller GC, `EnvSpec` mismatch detection, transient open retries, and reader-slot tuning. The `DbHealth` state machine marks environments as healthy/unhealthy and triggers reconnection. This module solves a common problem (managing LMDB environments across threads/processes) with robust error handling and could be extracted for any Rust project using LMDB.
A configurable query parser that extracts constraints from search queries. Supports extension (`*.rs`), glob (`**/test/**`), path segment (`/src/`), git status (`git:modified`), negation (`!pattern`), file path (`path:...`), and file type constraints. Uses a `ParserConfig` trait to allow different behaviors for file search, grep, and AI grep modes. Handles backslash escaping, brace expansion, and location parsing. This is a well-designed, self-contained parser that could be reused in any search tool needing a constraint query language.