Github 代码搜索
GitHub 在 2021 年 12 月上线了新的代码搜索引擎,使用 Rust 语言完全重写,支持特殊字符、正则表达式和代码导航功能,现处于预览阶段。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
文章链接:https://github.blog/2021-12-15-a-brief-history-of-code-search-at-github/Github 在 2021 年 12 月上线了新的代码搜索引擎,用 Rust 语言完全重写,现处于预览阶段,需要申请测试名额方可访问。本文讲述了 Github 代码搜索的架构演进历史,从直接使用现有工具到完全自研,大致可分为三个阶段:* 2008-2013:公共 repo 搜索基于 Solr,私有 repo 搜索基于 git grep。用户体验撕裂且搜索执行缓慢,大型私有 repo 依然无法搜索。* 2013-2021:基于 elesticsearch,高峰时集群规模达到 40TB RAM, 1.25 storage,承载每秒 200 次搜索,索引 53b 文件。因规模庞大,还发现并修复了 elesticsearch 的多个 bug。但受索引机制所限,不支持特殊字符、子字符串、正则表达式等对代码搜索十分重要的特性。* 未来:基于 Rust 重写的代码搜索引擎,分片策略更优(基于 git blob object ID),索引文件更小,支持特殊字符和正则表达式,甚至可以利用代码元数据(如 symbol definition)提供更好的代码导航(code navigation)体验。