Design Code Search Across Google's Monorepo at Every Commit
Last updated: November 29, 2026
Quick Overview
Design an internal code search tool that lets engineers run regex and symbol searches over a monorepo with billions of lines of code, returning results in under a second and staying current with commits.
0
0
0 solved
Design an internal code search tool that lets engineers run regex and symbol searches over a monorepo with billions of lines of code, returning results in under a second and staying current with commits.
A hard Google onsite question for developer infrastructure teams. The interviewer checks trigram indexing for regex, sharding, incremental updates as thousands of commits land per hour, and cross-reference symbol data.
What the Interviewer Expects
- Explain trigram indexing to narrow regex candidates
- Shard the corpus and fan out queries
- Handle incremental updates without full reindexing
- Add symbol cross-references from build or compiler data
- Rank results by relevance like path, file type, and definition vs usage
- Respect access controls on restricted directories
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- Which regexes cannot use the trigram index and how do you bound their cost?
- How would you search at a historical commit?
- How do you make 'find all callers of this function' accurate?
- How do you hide results from restricted code?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Corpus: ~2B lines in tens of millions of files, ~100 TB of history but a few TB at head.
- Queries: literal, regex, filters (
file:,lang:,-path:), and symbol queries (definition, references)....
High-Level Design
- Indexer reads head of the repo, splits files into shards (by path hash, balanced by size), and builds for each shard a trigram posting index plus the raw content in memory or on SSD.
- **Query f...