深入了解 GitHub 全新的 Git 存储架构
原题Inside GitHub's new Git storage architecture
推荐理由GitHub Rubicon 以引用粒度达成一致、对象存储解耦及独立副本承接智能体写入;比 OpenClaw 模型目录更新影响更广,与近期 OpenAI Git 不同,是平台方架构实现和扩容边界的新证据。
读前速览
GitHub 全新的 Git 存储架构 Rubicon 使用 Azure Blob Storage 和 Ref-CAS 将存储与计算解耦,支持每秒数千次写入,助力大规模智能体驱动开发。
按引用进行串行化,提升写入吞吐量
将写入仲裁范围限定在单个引用,而非整个仓库,使多个智能体可以并发推送到不同分支,在保证正确性的同时实现每秒数千次写入。
虚拟副本将存储与计算解耦
虚拟副本是可随时替换的计算节点,会缓存来自 Azure Blob Storage 的数据。读写操作可以独立扩展,且正确性不依赖任何单一节点。
Ref-CAS 使用共识协议管理引用状态
复制日志服务 Ref-CAS 使用比较并交换事务处理引用更新,实现高吞吐、有序写入,同时将对象数据保存在持久化的 Blob Storage 中。
后台压缩保障读取性能
专用压缩节点在后台合并 pack,不影响虚拟副本,确保随着写入量增加,pack 数量保持平稳,读取延迟也保持一致。
架构支持全球化、可扩展的智能体驱动开发
统一架构让任何仓库都能处理智能体驱动的工作负载,无需特殊处理;未来还计划改进部分副本和全球分布等能力。
完整摘要
GitHub 全新的 Git 存储架构 Rubicon 通过迁移至 Azure Blob Storage,并引入用于管理引用的 Ref-CAS,应对智能体驱动开发的指数级增长。该系统通过按引用进行串行化,每秒可支持数千次写入,同时允许并发写入不同分支。虚拟副本独立处理读写,而压缩节点则在后台执行维护工作。这一设计让各种规模的仓库——从个人项目到大型单体仓库——都能实现可扩展、低延迟的 Git 操作。
目录 · 8 节
上周,在 GitHub Universe 大会上,我们宣布推出全新的 Git 存储架构。它每秒可处理数千次写入,并能按需扩展读取能力。通过内部测试,我们证明该架构能够支持 5,000 个智能体同时在同一个仓库中协作,每秒向仓库推送 7,200 次,同时持续以极低的延迟处理读取流量。这一新架构是 GitHub 为数亿开发者提供智能体式开发支持的基础,而我们一直在 GitHub 持续运行的同时,于其底层构建这一架构。Last week at GitHub Universe, we announced our new Git storage architecture, capable of handling thousands of writes per second with reads that scale on demand. Through internal testing, we’ve demonstrated the ability to support 5,000 concurrent agents working on a repository, sending 7,200 pushes per second to a repo, all while serving read traffic with consistently low latency. This new architecture is the foundation for GitHub to support agentic development for hundreds of millions of developers, and we’ve been building it underneath GitHub while it keeps running.
过去一年,智能体改变了 GitHub 上活跃仓库的面貌。在本系列的第一篇文章中,我们阐述了新一代 Git 存储架构背后的两项原则:尽量减少协调,并将存储与计算解耦。在上一篇文章中,我们介绍了过渡方案:将 99.99999% 的仓库迁移到 Azure,将写入仲裁范围限定到单个引用,并搭建由 Azure Blob Storage 提供支持的虚拟副本。Over the past year, agents changed what a busy repository looks like on GitHub. In our first post in this series, we laid out the two principles behind our next-generation Git storage architecture: minimize coordination, and decouple storage from compute. In our last post, we covered the bridge: moving 99.99999% of repositories into Azure, scoping the write quorum to individual references, and standing up virtual replicas backed by Azure Blob Storage.
我们还以一个观察结束了讨论:一次写入中,只有极少部分需要排序。Git 对象是不可变的,并以其内容命名,这意味着两个写入者可以同时存储对象,而无需达成任何共识。推送过程中需要达成共识的部分是引用更新,与之相比,引用更新所涉及的数据量很小。虚拟副本是围绕这一特点构建系统的第一步,也是我们将代码仓库迁移到新架构的方式。We also left off with an observation: very little of a write needs to be ordered. Git objects are immutable and named by their contents, meaning two writers can store them at the same time without agreeing on anything. The part of a push that needs agreement is the reference update, and a reference update is tiny in comparison. Virtual replicas were the first step toward building around that, and the means by which we onboard repositories to the new architecture.
架构的其余部分都建立在这一观察之上。只有引用更新需要达成一致。这使得 Git 基础设施中以往紧密耦合的部分(数据存储、请求处理和仓库维护)能够独立扩展。对开发者而言,Git 还是原来的 Git:他们仍以相同的方式推送、获取和创建分支,并享有同样的保护措施。下面,我们将介绍这一设计背后的需求,跟踪一个请求在系统中的处理过程,并深入探讨其中的两个组件。The rest of the architecture builds on that observation. Only reference updates need agreement. That lets the parts of Git infrastructure that used to be tightly coupled (storing data, serving requests, and maintaining repositories) scale independently. For developers, Git stays Git: they push, fetch, and branch the same way, with the same protections in place. Below, we walk through the requirements behind the design, follow a request through the system, and dive deep into two of its components.
面向智能体规模化构建Building for agent scale
我们从两个维度来思考 GitHub 平台的规模:We think about the scale of the GitHub platform along two axes:
- 横向扩展能力指的是有多少开发者和代理能够跨多个代码仓库协同工作。GitHub 在这一维度上的许多现有做法经过多年实践检验,并沿用到了新架构中,例如将租户分布到不同基础设施分区、隔离租户流量和/或确保流量公平性,以及根据负载进行路由等。Horizontal scale is how many developers and agents can work across many repositories. Many of GitHub’s current approaches on this axis have been battle-tested over the years and are carried forward to the new architecture: partitioning of tenants across infrastructure, isolation and/or fairness enforcement of tenant traffic, and load-aware routing, to name a few.
- 纵向扩展能力指的是一个代码仓库能够支持多少开发者和智能体同时协作。随着智能体编写的代码越来越多,我们预计单个代码仓库会变得更大、更繁忙,因此我们的大部分需求都来自纵向扩展这一维度。Vertical scale is how many developers and agents can work on one repository. As agents write more code, we expect individual repositories to get larger and busier, so most of our requirements came from the vertical axis.
如今,GitHub.com 上最繁忙的代码仓库每秒最多会收到数十次写入,通常以短暂突发的形式出现。随着越来越多的工作转交给全天候并行运行的智能体,我们预计在未来一年内,这些突发流量将变成持续的负载。每次推送都会带来更多读取操作:CI 运行、部署系统拉取新提交,其他智能体也会获取该提交作为上下文。这种读取扇出会大幅放大整体流量,而且流量会随着写入量同步增长。Today, the busiest repositories on GitHub.com receive at most dozens of writes in a single second, typically in short bursts. As more of that work shifts to agents running in parallel and around the clock, we expect those bursts to become a sustained rate within the next year. Each push leads to more reads: CI runs, deployment systems pull the new commit, and other agents fetch it for context. This read fan-out results in a large amplification effect on overall traffic that scales with writes.
我们已经看到这一趋势正在增长曲线顶端的代码仓库中显现。下图显示了 3 月至 5 月期间,GitHub 上一个代码仓库每天收到的请求数;那段时间,它的流量增长了约 4 倍。此后,它的增长势头一直呈指数级上升。We’re already seeing this trend play out on repositories at the top of the curve. The chart below shows daily requests to one repository on GitHub from March to May, when its traffic grew about 4x. Its growth has continued on an exponential trajectory since then.
我们必须为这样一个世界做好规划:由智能体驱动的开发继续以这样的速度加速。我们不再着眼于下一个增量,而是将目标设定为至少扩大两个数量级的规模。对于单个代码仓库,这意味着新架构需要:We have to plan for a world where agent-driven development keeps accelerating at this speed. Instead of planning for the next increment, we set a target of at least two orders of magnitude more scale. For a single repository, that meant the new architecture needed to:
- 每秒可接受数千次写入。Accept thousands of writes per second.
- Support multiple writer nodes. There are two reasons for this:
- Experience has taught us that indexing incoming packs and checking object connectivity are the most CPU-expensive parts of a write, and that cost scales with the size of the write, so a single node will become compute-bound quickly.
- Spreading that work across many nodes improves fault tolerance and shortens recovery when a node fails.
- 尽量缩短提交延迟。智能体每次推送后都要等待,才能进入下一步。Minimize commit latency. An agent waits on each push before it moves to its next step.
- 按每个引用的顺序记录更改,并能够快速跨引用进行线性化。落后的虚拟副本需要通过仅下载处理传入请求所需的数据来赶上进度。Record changes in order for each reference with the ability to quickly linearize across references. A virtual replica that falls behind needs to catch up by downloading only the data it needs to serve the incoming request.
- 当内容没有变化时,尽量降低读取开销;考虑到读写比例,这通常是常见情况。Keep reads cheap when nothing has changed, which is the common case given the read-to-write ratio.
- 让每个组件独立缩放。Let each component scale independently.
此外,该系统还必须能够提高整体可靠性,并在全球范围内扩展。On top of that, the system had to be able to improve overall reliability and scale globally.
隆重推出“Rubicon 项目”Introducing “Project Rubicon”
2026 年 5 月,紧随最初的 Azure 迁移之后,我们开始着手设计一种能够满足这些需求的方案。我们尝试了几种不同的方法。在所有方案中,pack 数据都存储在 Azure Blob Storage 中;其中一些方案还尝试将引用状态也存储在那里。下文会介绍我们发现的一些权衡取舍,最终我们选定了一种设计,认为它既能最大限度地提高吞吐量,又能满足 GitHub 这类平台对正确性、持久性、可用性和延迟的保证要求。我们将其称为“Rubicon”,以此致意业界因智能体式开发而跨越的那个不可逆转的节点。In May of 2026, hot on the heels of the initial Azure migration, we started working on a design that could meet those demands. We tried several approaches. In all of them, pack data lived in Azure Blob Storage, and in some we experimented with keeping reference state there too. We’ll cover some of the trade-offs we found below, but we settled on a design we felt maximized throughput while preserving the correctness, durability, availability, and latency guarantees a platform like GitHub requires. We called it “Rubicon,” a nod to the point of no return the industry crossed with agentic development.
让我们自上而下梳理 Rubicon。许多方面保持不变:来自 Git 客户端、API 和 Web UI 的请求仍会到达 Spokes,由它负责路由和负载均衡,并提供 GitHub 其余部分用于读取和写入仓库数据的内部 API。Spokes 也继续承担放置与负载均衡服务的职责,维护水平扩展所需的分区、隔离和多租户公平性。相比之下,Spokes 下方的数据平面是全新的。Let’s walk through Rubicon from the top down. Many things stay the same: requests from Git clients, the API, and the web UI arrive at Spokes, which still handles routing and load balancing, and serves the internal API that the rest of GitHub uses to read and write repository data. Spokes also maintains its role as a placement and balancing service, maintaining the partitioning, isolation, and tenant fairness required for horizontal scale. The data plane underneath Spokes, in contrast, is new.
Spokes 会将每个请求路由到分配给该代码库的一小组虚拟副本之一。虚拟副本构成一个统一的、可随时销毁的计算资源集群,用于处理读取、写入或两者兼有的请求。虚拟副本的本地磁盘是缓存,可随时重建。Spokes routes each request to one of a small group of virtual replicas assigned to that repository. Virtual replicas are a single fleet of disposable compute that serves reads, writes, or both. A virtual replica’s local disk is a cache that can be rebuilt at any time.
Spokes 会尽可能将仓库的流量路由到相同的虚拟副本,从而保持这些副本的缓存处于热状态并降低延迟;但请求落到哪个特定的虚拟副本上,与系统正确性无关。某个虚拟副本退出后,仓库的其他虚拟副本会继续提供服务,替代副本则会随着流量到来逐渐填充缓存。Spokes routes a repository’s traffic to the same virtual replicas when it can, which keeps their caches warm and latency low, but nothing about correctness depends on a request landing on any particular virtual replica. When a virtual replica goes away, the repository’s other virtual replicas keep serving, and a replacement fills its cache as traffic arrives.
当仓库负载增大时,我们会增加虚拟副本。此外,还有一组压缩节点在后台运行,直接操作 Blob Storage 和 Ref-CAS,合并每个仓库的 pack 文件并删除不可达对象。这项工作不会在虚拟副本上运行,因此它们的 CPU 和内存几乎可以全部用于处理请求。When a repository gets busy, we add more virtual replicas. Separately, a fleet of compaction nodes works in the background, directly against Blob Storage and Ref-CAS, to merge each repository’s packs and remove unreachable objects. That work never runs on a virtual replica, meaning their CPU and memory can be almost entirely dedicated to serving requests.
持久化状态存在于两个地方:Durable state lives in two places:
- Git 对象(以 pack 包和辅助读取加速数据的形式)存储在 Azure Blob Storage 中。Git objects, in the form of packs and auxiliary read acceleration data, live in Azure Blob Storage.
- 引用以及构成该仓库的包列表(包清单)存储在一个独立的复制日志服务中,我们称之为 Ref-CAS(“引用比较并交换”)。References and the list of packs that make up the repository (the pack manifest) live in a separate replicated log service we call Ref-CAS (for “Reference Compare-and-Swap”).
让我们从写入和读取的角度来梳理一下架构:Let’s walk the architecture from the perspective of a write and a read:
- 写入:虚拟副本会为传入的数据包建立索引并将其上传到 Blob Storage,然后向 Ref-CAS 提交一个事务,在清单中列出该数据包并更新引用。之后,压缩节点会将该数据包与其他数据包合并,以保持读取速度。Write: a virtual replica indexes the incoming pack and uploads it to Blob Storage, then commits one transaction to Ref-CAS that lists the pack in the manifest and updates the references. Later, a compaction node merges that pack with others to keep reads fast.
- 读取:虚拟副本使用 Ref-CAS 检查其参考版本,从 Blob Storage 将所需的数据包拉取到缓存中,然后从缓存中提供读取服务。Read: a virtual replica checks its reference version with Ref-CAS, pulls the packs it needs from Blob Storage into its cache, and serves the read from there.
在新架构中,我们采用了许多各不相同的方法,涵盖虚拟副本上的软件栈,以及如何针对不同用例(例如,许多小型代码仓库与一个大型代码仓库)调整流量路由和工作负载调度。接下来,我们将深入探讨架构中的两个组件,并围绕这两项设计原则讲述它们的故事。There are many distinct approaches we’ve taken within the new architecture, from the software stack on the virtual replicas to how traffic routing and workload scheduling are tuned for different use cases (e.g., many small repos vs. one large one). Let’s dive deep into two components of the architecture and tell their stories centered on the two design principles.
尽量减少协调:以高吞吐量修改引用状态Minimizing coordination: mutating reference state at high throughput
像 Azure Blob Storage 这样的对象存储服务非常擅长自身的工作,也非常适合许多数据密集型应用,例如源代码存储。它们经久耐用且经过复制,容量可满足我们的各种需求,每字节成本相对较低,并且只要流量分散到多个键上,就能提供极高的聚合吞吐量。因此,新 Git 存储架构中几乎所有持久化数据都存放在 Azure Blob Storage 中,包括:Object storage services like Azure Blob Storage are incredibly good at what they do, and natural fits for many data-heavy applications like source code storage. They are durable and replicated, hold as much as we need them to, have a relatively low cost per byte, and deliver exceptionally high aggregate throughput so long as traffic is spread across many keys. As a result, nearly everything durable in the new Git storage architecture lives in Azure Blob Storage, including:
- 由推送、压缩和垃圾回收写入的包和索引。Packs and indexes written by pushes, compaction, and garbage collection.
- 我们的维护流程基于这些包构建的各种读取加速器(例如多包索引、可达性位图和一些自定义格式)。Various read accelerators (like multi-pack indexes, reachability bitmaps, and some custom formats) that our maintenance process builds from those packs.
- 用于支持压缩和垃圾回收继续执行或审计其工作的记录,以及压缩节点用于认领任务的租约。Records that let compaction and garbage collection resume or audit their work, along with the leases that compaction nodes use to claim work.
- 对频繁重复的获取请求进行缓存的响应。Cached responses for frequently repeated fetches.
- 用于存储库参考状态的检查点,但并非用于处理请求的权威状态。Checkpoints for the reference state of the repository, though not the authoritative state used to serve requests.
其中大部分数据只会写入一个独立的键一次,此后便不会再发生变化,因此非常适合存储在 Blob Storage 中。Most of that data is written once to a distinct key and never changes afterward, which is what makes it highly suitable for Blob Storage.
引用则恰恰相反。繁忙仓库中的引用所占状态相对较小,但许多写入操作会同时争相更新它们。这种访问模式更难通过 Blob 存储来处理,我们最初的原型也让我们明白了原因。对于这类工作负载,对象存储是一个直观的选择,而且在达到一定规模之前效果很好:条件写入可以免费实现比较并交换(compare-and-swap),并且数据本身已经具备持久性和副本。不过,我们遇到了一系列棘手的取舍,下面用我们尝试过的两种方案来说明。References are the opposite. A busy repository’s references are a relatively small piece of state that many writes race to update at the same time. That access pattern is harder to serve from Blob Storage, and our first prototypes showed us why. Object storage for this kind of workload is an intuitive choice, and one that works well up to a certain level of scale: conditional writes give a compare-and-swap for free, and the data is already durable and replicated. However, we ran into a difficult set of choices, illustrated below by two approaches we tried.
我们的第一种方案是为仓库的所有引用建立写前日志,并以单个 blob 为索引。每次更新都是针对该 blob 的条件写入。这种方案是正确的,而且读取成本很低:虚拟副本只需检查该 blob 是否发生变化;如果没有,就无需再做其他操作。它的不足体现在写入上。任一时刻,针对一个 blob 最多只能有一次条件写入在进行中,因此,即使我们把一次写入期间到达的所有推送都合并到下一次写入中,仓库的写入上限仍是每次与单个 blob 完成一次往返只能写入一次。实际测得的写入吞吐量为每秒几百次的中段水平。Our first approach was a write-ahead log for all of a repository’s references, indexed by a single blob. Every update is a conditional write against that blob. It’s correct, and reads are cheap: a virtual replica asks whether the blob has changed, and if it hasn’t, it’s done. Writes are where it falls short. Only one conditional write to a blob can be in flight at a time, so even when we batch every push that arrives during a write into the next one, the repository’s write ceiling is one write per round trip to a single blob. In practice, this netted us write throughput in the mid-hundreds per second.
我们的第二种方案将引用分散到多个分段 blob 中,每个引用都会哈希到其中一个分段。对不同分段中引用的写入不再需要相互等待,从而提高了性能上限。但现在,读取必须检查每个分段,才能确定是否发生了变化,而且速度取决于最慢的分段。我们用写入延迟换来了读取延迟,而读取量比写入量高出几个数量级。我们可以通过并排展示多次写入和一次读取来直观地说明这一点:Our second approach split the references across several segment blobs, with each reference hashing to one of them. Writes to references in different segments no longer wait on each other, which raises the ceiling. But a read now has to check every segment to know whether anything changed, and it’s only as fast as the slowest segment. We’d traded write latency for read latency, and reads outnumber writes by orders of magnitude. We can visualize this by showing multiple writes and a read side by side:
这两个方案都无法满足所有要求,因此我们另行构建了一套系统:一个专用于引用的复制日志服务,也就是 Ref-CAS 服务。这就是我们在上一篇文章结尾提到的、仍然存在于技术栈某处的那个(小型)共识组。下面介绍它的工作原理。Neither option met every requirement, so we built something else: a replicated log service dedicated to references, or the Ref-CAS service. This is the (small) consensus group we said at the end of the last post was still somewhere in the stack. Here’s how it works.
Ref-CAS 中的每次引用更新都是由多数派提交的一次比较并交换操作。事务只会锁定它涉及的引用,检查每个引用的当前值是否仍与写入方预期的值一致,并在日志的大多数副本都记录该事务后生效。各个代理通常只向自己的分支推送,因此大多数更新不会发生争用,而且会并行复制。如果两个推送都更新了同一个引用,则只有一个会追加到日志中。Each reference update in Ref-CAS is a compare-and-swap committed by a quorum. A transaction locks only the references it touches, checks that each one still has the value the writer expects, and becomes visible once a majority of the log’s replicas have recorded it. Agents mostly push to their own branches, so most updates don’t contend, and they replicate in parallel. When two pushes do update the same reference, only one will append to the log.
每次向 Ref-CAS 提交都会获得一个日志序列号(LSN),而仓库的版本就是其最新一次提交的 LSN。读取时,首先会将版本与该版本进行检查。虚拟副本会发送其当前持有的引用状态的版本。如果该版本仍是最新版本,回复中就不会携带任何引用;对于未发生变化的仓库,只需进行一次比较即可。如果虚拟副本落后了,它就会收到当前的引用和版本,以及指向包数据的指针和其他需要了解的信息,例如上次垃圾回收周期发生的时间。Each commit to Ref-CAS gets a log sequence number (LSN), and the repository’s version is the LSN of its latest commit. Reads start with a version check against that version. A virtual replica sends the version of the reference state it already holds. If that version is still current, the reply carries no references at all, and an unchanged repository costs a single comparison. If the virtual replica is behind, it gets back the current references and version, along with pointers to pack data and anything else that needs to be known, such as when the last garbage collection cycle occurred.
与我们旧版架构中的共识组不同,Ref-CAS 从不持有或验证对象数据,只存储指向这些数据的指针。虚拟副本会先将一次 push 的 pack 上传到 Blob 存储,然后再提交引用事务。引用始终只会指向已经持久化的对象。Unlike the consensus group in our legacy architecture, Ref-CAS never holds or validates object data. It only stores pointers to it. A virtual replica uploads a push’s pack to Blob Storage before it commits the reference transaction. A reference only ever points at objects that are already durable.
这些方法使我们仅针对引用状态进行事务处理时,就能达到每秒数万次操作,并为在复制日志中添加更多注释提供基准,帮助读取操作判断针对给定请求需要下载哪些内容。These approaches allow us to transact reference state alone in the tens of thousands of operations per second, and provide a baseline for additional annotations on the replication log that help reads decide what to download for a given request.
但在单个存储库上支持每秒数千次写入,会带来一个衍生问题:如何维持读写性能。为此,我们需要采用不同的压缩整理方式。But supporting thousands of writes per second on a single repository creates a second-order problem: maintaining the performance of reads and writes. For that, we needed a different approach to compaction.
存储与计算解耦:每秒数千次写入下的压实Decoupling storage from compute: compaction at thousands of writes per second
每次推送都会向 Blob Storage 添加一个 pack。Git 可以通过多个 pack 提供仓库服务,但每增加一个 pack,查找操作的开销都会略微增加,因此 pack 的数量不能无限增长。在我们的旧架构中,压缩操作在处理流量的同一组副本上运行,并且必须在每个副本上运行。在新架构中,压缩操作完全在后台的独立节点上运行,直接针对持久化存储进行,并使用 Ref-CAS 服务通知虚拟副本不断演进的状态。Every push adds a pack to Blob Storage. Git can serve a repository from many packs, but each additional pack makes lookups slightly more expensive, so the pack count can’t grow without bound. In our legacy architecture, compaction runs on the same replicas that serve traffic, and it has to run on every replica. In the new architecture, it runs entirely in the background on separate nodes, directly against durable storage, using the Ref-CAS service to notify virtual replicas of the evolving state.
每个压缩节点都通过租约认领仓库中一部分数据的所有权,这使我们能够横向扩展压缩能力。下面介绍一个压缩节点如何处理仓库中一个分片的 packs:Compaction nodes each claim ownership over a subset of the repository’s data via a lease, which allows us to scale compaction horizontally. Here’s how one compaction node works through a single shard of a repository’s packs:
节点首先在 Blob Storage 中获取该分片的租约,因此同一时间只有一个节点会压缩该分片。与此同时,虚拟副本会继续上传数据包,并将其列入数据包清单。节点读取清单以查找新数据包,并将它们收集到一个开放段中;这个开放段实际上是即将压缩的数据的暂存区。当该段达到根据数据包数量、大小或存续时间设定的限制时,节点会封存该段,使其不再接收新数据包,然后将其中的数据包合并为数量更少、体积更大的数据包。压缩期间,该分片的下一个段可以开始收集输入数据包。在发布任何内容之前,节点会检查新数据包中的对象是否与输入数据包中的对象完全一致。随后,节点上传新数据包并将其添加到清单中。第二个事务会从清单中移除输入数据包,之后再由清理流程将它们删除。The node first takes a lease on the shard in Blob Storage, so only one node compacts a shard at a time. Meanwhile, virtual replicas keep uploading packs and listing them in the pack manifest. The node reads the manifest to find new packs and collects them into an open segment, which is effectively a holding ground for data about to be compacted. When the segment reaches a defined limit based on pack count, size, or age, it seals the segment so it accepts no new packs, then combines its packs into fewer, larger ones. While compaction happens, the next segment for the shard can begin capturing its input packs. Before anything is published, the node checks that the new packs contain exactly the same objects as the inputs. It then uploads the new packs and adds them to the manifest. A second transaction removes the inputs from the manifest, and cleanup deletes them later.
为了扩展处理能力,这个流程会同时在许多分片上独立运行。每个 pack 的哈希值都会映射到一个分片,因此增加分片和节点就能提升压缩吞吐量。压缩后仍未达到大小上限的 pack 会根据自身哈希值重新进入某个分片,并再次合并,因此 pack 会逐级增大,直到达到上限。最终效果是,随着推送量增加,pack 的数量基本保持不变:To scale out, this process runs independently for many shards at once. Each pack’s hash maps to a shard, so adding shards and nodes adds compaction throughput. A compacted pack that’s still under the size limit goes back into a shard by its own hash and merges again, so packs grow in tiers until they reach the limit. The net result is an effectively flat pack count while pushes climb:
压缩会合并数据包,但会保留每个对象。垃圾回收则负责移除已无人引用的对象,例如删除分支和强制推送后遗留的对象。在我们的新架构中,垃圾回收的工作方式与压缩非常相似:由专用工作进程处理计算密集型部分。它还包含一些用于安全删除数据的特殊行为,值得专门讨论。Compaction merges packs, but it keeps every object. Garbage collection is the step that removes objects nothing references anymore, like the ones left behind by deleted branches and force-pushes. In our new architecture, garbage collection works very similarly to compaction by using dedicated workers to handle the compute-heavy portion. It also has a few special behaviors for safely removing data, which are worthy of their own discussion.
通过这些方法,我们能够持续证明,随着写入量增加,延迟曲线依然平稳;此外,我们还计划了其他优化,以提升压缩和垃圾回收过程本身的性能。Using these approaches, we’ve been able to consistently demonstrate a flat latency curve as writes climb, and we have other planned optimizations to make the compaction and garbage collection processes themselves more performant.
接下来是什么What comes next
我们最初提出的两个原则,让这一架构的各个部分都能独立扩展。我们通过增加虚拟副本来扩展读写能力。Ref-CAS 对每个引用分别排序,而不是对整个仓库进行排序。我们通过增加压缩节点来扩展维护能力。我们的目标是让每个仓库——从单个开发者的业余项目到最繁忙的单体仓库——都运行在同一套架构上,无需对繁忙的仓库进行特殊处理。仓库不会一直很小。一个业余项目可能一夜之间就拥有一大批代理,而为了跟上增长,我们不应该要求用户迁移或对其进行特殊处理。采用同一套架构也意味着,我们做出的每一项改进都能同时惠及所有仓库。The two principles we started with let each part of this architecture scale on its own. We scale reads and writes by adding virtual replicas. Ref-CAS orders each reference independently instead of the whole repository. We scale maintenance by adding compaction nodes. Our goal is for every repository, from one developer’s side project to the busiest monorepo, to run on the same architecture with no special handling for the busy ones. Repositories don’t stay small. A side project can pick up a fleet of agents overnight, and it shouldn’t need a migration or special handling from us to keep up. One architecture also means every improvement we make reaches every repository at once.
这一基础让我们能够做更多事情。接下来,我们将重点推进三个方向:扩展架构,使其超越我们目前能够预见的需求;提升智能体在 GitHub 上执行工作的效率;以及推动 Git 本身演进,以适应智能体驱动的开发。This foundation lets us do a lot more. We’re focused on three areas next: scaling the architecture beyond what we can predict we’ll need today, making agents more efficient at the work they do on GitHub, and evolving Git itself for agentic development.
改进架构Improving the architecture
我们计划进一步完善这一架构。每项改进都能让代码仓库处理更多活动,同时减少每个请求背后的工作量:We have plans to take this architecture further. Each of these improvements lets a repository handle more activity while reducing the work behind each request:
- 只读取必要内容。从 Blob Storage 中提取单个对象,而不是获取包含它的整个数据包。Read only what’s needed. Fetch a single object from Blob Storage instead of the whole pack that holds it.
- 按类型组织 pack 文件。将提交、树和 blob 分别放入各自的 pack 文件。这样,许多请求需要处理的数据就会更少。Organize packs by type. Group commits, trees, and blobs into their own packs. Many requests then touch less data.
- 部分副本。无需将所有 pack 都存储在本地磁盘上即可处理请求。Partial replicas. Serve requests without every pack on local disk.
- 物化视图。将仓库数据保持为可直接使用的形式,例如预先准备好的归档文件、近实时的默认分支浅克隆,以及与每次提交一同存储的代理会话上下文。Materialized views. Keep repository data in ready-to-use forms, like prepared archives, a near-live shallow copy of the default branch, and agent session context stored alongside each commit.
- 全球副本。可在任意区域部署副本,使其靠近使用它们的工作负载。读取结果相对于最新写入的陈旧程度保持在有界范围内。Global replicas. Place replicas in any region, close to the workloads that use them. Reads stay within bounded staleness of the latest write.
- 缩至零。根据实际活跃的代码仓库扩充或缩减集群规模。Scale to zero. Grow and shrink the fleet with the repositories that are actually active.
在 GitHub 上高效运行代理操作Efficient agent operations on GitHub
扩展基础设施是支持智能体的一方面;另一方面,则是降低每次智能体操作的成本:获取更少的数据、减少往返次数,并缩短等待变更的时间。以下每项后续工作都基于本文介绍的存储改进:Scaling the infrastructure is one side of supporting agents. The other side is making each agent operation cheaper: fewer bytes to fetch, fewer round trips, and less waiting on changes. Each of these fast-follow items builds on the storage work in this post:
- 无需克隆即可工作。许多代理任务根本不需要完整的工作树,只需要少量文件和足够的上下文来进行修改。它们可以直接从服务器读取这些内容。Work without a clone. Many agent tasks never need a full working tree. They need a handful of files and enough context to make a change. They can read both straight from the server.
- 原子提交 API。一次操作即可提交多文件变更。整个变更要么全部提交,要么在冲突时被干净地拒绝。Atomic commit API. Land a multi-file change in one operation. The whole change commits, or it’s rejected cleanly on conflict.
- 事件流。智能体及其周边系统在实时信息的支持下能够发挥最佳效果。通用事件流让它们可以订阅变更,并在变更发生时立即作出响应。Event streams. Agents and the systems around them work best with real-time information. A generic event stream lets them subscribe to changes and react as they happen.
改进面向智能体的 GitImproving Git for agents
我们还需要在 Git 本身继续投入。GitHub 长期以来一直为 Git 项目贡献力量,而我们也不会就此止步。以下是一些我们期待继续推进的工作示例:We also have work to do in Git itself. GitHub has been a longtime contributor to the Git project, and we’re not stopping now. A few examples of the work we’re excited to continue:
- 轻量级克隆。部分克隆、浅克隆和稀疏检出都能让智能体获取更少的内容。每种方式都有不足,而且它们也不总能很好地协同工作。我们希望改进每个部分,让它们更好地配合。Lightweight clones. Partial clone, shallow clone, and sparse checkout each let an agent fetch less. Each one has gaps. They don’t always work well together, either. We want to improve each piece and make them fit.
- 消除隐性扩展成本。Git 中仍有一些代码路径,其速度下降得远快于仓库的增长速度。近期版本修复了其中几个问题,但我们预计还会发现更多。Remove hidden scaling costs. Git still has code paths that slow down much faster than the repository grows. Recent releases fixed several of them, but we expect to find more.
- 更快地遍历历史记录。提交图等元数据无需遍历每个提交,就能回答合并基点和可达性问题。当代理的 API 调用转化为服务器上的 Git 操作时,这一点尤为重要。Faster history walks. Metadata like the commit-graph can answer merge-base and reachability questions without walking every commit. That matters most when an agent’s API call turns into Git work on the server.
- 避免常见陷阱。智能体也会犯开发者常犯的错误。Git 可以捕捉更多这类常见问题,并在造成损害之前发出警告。Avoid common gotchas. Agents make the same mistakes developers do. Git can catch more of the common ones and warn before they cause damage.
智能体改变了软件的构建方式,GitHub 和 Git 也随之改变。我们很高兴能推动这一新架构正式启程。目前它已进入有限范围的私有预览,预计明年年初进一步推广。我们迫不及待想看看,当团队在一个代码仓库中使用的智能体数量只受创意限制时,他们能构建出什么。我们将与客户和 Git 社区携手,持续推动 Git 和 GitHub 的发展。Agents have changed how software gets built. GitHub and Git are changing with it. We’re excited to take this new architecture across the starting line. It’s available in a limited private preview now, with a broader rollout early next year. We can’t wait to see what teams build when the number of agents working on a repository is limited by their ideas. We’ll keep evolving Git and GitHub alongside our customers and the Git community.