arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2211.01224cs.PL
收藏

堆栈图:大规模名称解析

Stack graphs: Name resolution at scale

Douglas A. Creager, Hendrik van Antwerpen

AI总结:

本文提出堆栈图,扩展作用域图框架,支持大规模仓库内的精确名称解析,通过文件增量构建和堆栈机制实现高效索引。

摘要:

我们提出了堆栈图,这是对Visser等人的作用域图框架的扩展。堆栈图为GitHub上的精确代码导航提供支持,使用户能够在仓库内部和跨仓库导航名称绑定引用。与作用域图类似,堆栈图在图形结构中编码程序的名称绑定信息,其中路径表示有效的名称绑定。将引用解析为其定义通过简单的路径查找搜索实现。GitHub托管着数百万个仓库,包含总计PB级的代码,使用数百种不同的编程语言编写,每分钟接收数千次推送。为了支持这种规模,我们确保图构建和路径查找判定是文件增量的:对于每个源文件,我们创建一个隔离的子图,不依赖于程序中的任何其他文件,也无法查看这些文件。这使我们能够消除重新分析已见过的文件版本的存储和计算成本。由于大多数提交只更改仓库中的一小部分文件,这大大摊销了大型、频繁更改的仓库的索引操作成本。为了处理类型导向的名称查找(这需要“暂停”当前查找以解析另一个名称),我们的名称解析算法维护一个当前暂停(但仍待处理)查找的堆栈。堆栈图可以通过对程序源代码的纯语法分析来构建,使用一种新的声明式图构建语言。这意味着我们可以为每个仓库提取名称绑定信息,而无需任何包级配置,也无需调用任意的、不受信任的、特定于包的构建过程。

英文摘要:

We present stack graphs, an extension of Visser et al.'s scope graphs framework. Stack graphs power Precise Code Navigation at GitHub, allowing users to navigate name binding references both within and across repositories. Like scope graphs, stack graphs encode the name binding information about a program in a graph structure, in which paths represent valid name bindings. Resolving a reference to its definition is then implemented with a simple path-finding search. GitHub hosts millions of repositories, containing petabytes of total code, implemented in hundreds of different programming languages, and receiving thousands of pushes per minute. To support this scale, we ensure that the graph construction and path-finding judgments are file-incremental: for each source file, we create an isolated subgraph without any knowledge of, or visibility into, any other file in the program. This lets us eliminate the storage and compute costs of reanalyzing file versions that we have already seen. Since most commits change a small fraction of the files in a repository, this greatly amortizes the operational costs of indexing large, frequently changed repositories over time. To handle type-directed name lookups (which require "pausing" the current lookup to resolve another name), our name resolution algorithm maintains a stack of the currently paused (but still pending) lookups. Stack graphs can be constructed via a purely syntactic analysis of the program's source code, using a new declarative graph construction language. This means that we can extract name binding information for every repository without any per-package configuration, and without having to invoke an arbitrary, untrusted, package-specific build process.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑