我们如何通过量化向量搜索使代码搜索在超过1亿行代码库中提高40%的速度

Augment Code is designed to provide the most useful context for working with large codebases. As we took on even bigger codebases, a challenge emerged: our context engine gets great results, but it was running into performance limitations due to the large amount of data to process. We solved this problem by implementing an approximation of context search that shrinks the search space by orders of magnitude while maintaining more than 99.9% fidelity to the exact results. As a result, the latency of real-time features like code completions seamlessly improved by over 40% for our most challenging codebases.

Augment Code旨在为处理大型代码库提供最有用的上下文。当我们处理更大的代码库时,出现了一个挑战:我们的上下文引擎取得了很好的结果,但由于需要处理大量数据,性能受到了限制。我们通过实现一种上下文搜索的近似方法解决了这个问题,该方法在保持超过99.9%准确性的同时,将搜索空间缩小了几个数量级。因此,实时功能(如代码补全)的延迟在我们最具挑战性的代码库中无缝改善了超过40%。

Here's the hard data: we reduced memory usage by 8x (from 2GB to 250MB for a 100M LOC codebase), cut search latency from 2+ seconds to under 200ms, and maintained 99.9% accuracy on typical queries. For the 0.1% of edge cases—usually involving very recent code changes or extremely rare patterns—we have automatic fallbacks.

这里是硬数据:我们将内存使用量减少了8倍(从2GB降至250MB,针对1亿LOC的代码库),将搜索延迟从2秒以上减少到200毫秒以下,并在典型查询中保持99.9%的准确性。对于0.1%的边缘案例——通常涉及非常近期的代码更改或极其罕见的模式——我们有自动回退机制。

Why scale?

为什么要扩展?

A classic puzzle in software engineering is: “What’s the fastest practical way to sort a list?”. The key is that the answer depends on your assumptions and especially on scale. The best approach changes qualitatively every few orders of magnitude. Does the list fit in registers? In cache? In RAM? Does it fit on one machine at all?

软件工程中的一个经典难题是:“对一个列表进行排序的最快实用方法是什么?”关键在于答案取决于你的假设,尤其是规模。最佳方法在每几个数量级上都会发生质的变化。列表是否适合寄存器?在缓存中?在RAM中?它是否完全适合一台机器?

Something similar goes for building software. 1,000 lines of code (LOC) is the size of a casual project that fits in one developer’s “working memory”. 10,000 LOC is typical of a concise open-source library but already requires “paging in” various parts of the design to maintain. 100,000 LOC could be a larger open-source eff...

开通本站会员,查看完整译文。

Главная - Вики-сайт
Copyright © 2011-2025 iteam. Current version is 2.144.0. UTC+08:00, 2025-06-27 20:04
浙ICP备14020137号-1 $Гость$