最新 微软与美国政府警告:重大技术故障还将持续 The Verge
行业观察 ●●●○○

OpenAI 自研 Git 后端 Pando 支撑 Codex 规模开发

Scaling Git at OpenAI

摘要Summary

OpenAI 构建了兼容 Git 的新后端 Pando,用于支撑 Codex 带来的并发开发规模,现已承载其 monorepo 的全部开发工作。Pando 将推送延迟中位数降低近 5 倍,每日传输近 1 PB Git 数据,同时保持 Git 协议与客户端兼容。

OpenAI built Pando, a Git-compatible backend designed to handle the concurrent development scale enabled by Codex, and it now powers all development in OpenAI's monorepo. Pando cut median push latency by nearly 5x and delivers nearly a petabyte of Git data per day while retaining compatibility with the Git protocol and client.

  • Pando 已承载 OpenAI monorepo 全部开发
  • 推送延迟中位数降低近 5 倍
  • 每日传输近 1 PB Git 数据

全文对照Full text · 中 / EN

在投资 Git 生态系统的同时,构建智能体规模级的源代码控制系统。

Building agentic-scale scale source control while investing in the Git ecosystem.

作者:Aaron Friel、Taylor Blau 和 Ted Nyman,技术团队成员

By Aaron Friel, Taylor Blau, and Ted Nyman, Members of Technical Staff

过去一年里,我们单体仓库的规模和对它的需求都以惊人的速度增长。显然,我们需要改造源代码控制系统,使其能够扩展到 Codex 所支持的并发工作水平。

Over the past year, the size and demands on our monorepo have increased at a staggering pace. It was clear that we needed to revamp our source control system to scale to the level of concurrent work that Codex makes possible.

我们构建了 Pando,一个面向 Git 仓库的新后端,且没有中断任何工程工作,也没有改变团队使用 Git 的方式。Pando 现在支撑着 OpenAI 单体仓库中的所有开发工作。Pando 旨在实现两个雄心勃勃的目标:第一,水平可扩展的写入,针对向多个分支的并发推送进行优化。第二,最大化读取吞吐量,使客户端能够以足够快的速度下载数据,从而充分利用其可用网络带宽。

We built Pando, a new backend for Git repositories, without interrupting any engineering work or changing how our team uses Git. Pando now powers all development in OpenAI’s monorepo. Pando is designed to meet two ambitious goals: first, horizontally scalable writes, optimized for concurrent pushes to many branches. And second, maximize read throughput, so clients can download data fast enough to fully saturate their available network bandwidth.

我们在实现这些目标的同时,保持了与 Git 协议和客户端的兼容性,使我们双方的工程师和智能体都能将 Pando 无缝融入现有工作流。在生产环境中,Pando 将推送延迟中位数降低了近 5 倍。它现在每天传输近 1 PB 的 Git 数据。

We met these goals while retaining compatibility with the Git protocol and client, enabling both our engineers and agents to seamlessly adopt Pando into their existing workflows. In production, Pando cut median push latency by nearly 5x. It now delivers nearly a petabyte of Git data per day.

在这里,我们将介绍构建新源代码控制系统的动机,以及我们为何选择保持与 Git 的兼容性。我们会将我们的系统与扩展 Git 的常见方法进行比较,说明为什么 Pando 独具能力满足 OpenAI 的可扩展性需求。我们还会讨论下一步计划,以及我们将如何继续为 Git 做贡献,以支持智能体规模的工作。

Here, we’ll cover our motivations for building a new source-control system, along with why we chose to retain compatibility with Git. We’ll compare our system with common approaches to scaling Git, describing why Pando is uniquely capable of meeting OpenAI’s scalability needs. We also discuss what’s next, and how we’ll continue contributing to Git to support agent-scale work.

Codex 改变了 OpenAI 的开发规模和节奏,使工程师能够并行完成多得多的工作。这意味着更多的分支和推送、更多的合并,以及来自开发环境、研究任务和 CI 的更多拉取和克隆。

Codex has changed the scale and pace of development at OpenAI, enabling engineers to do far more work in parallel. That means more branches and pushes, more merges, and more fetches and clones from development environments, research jobs, and CI.

这些需求会叠加。一名工程师现在可以同时准备好多个变更等待 CI,而每次推送都可能触发多个任务去拉取同一个提交。

These demands compound. One engineer now has several changes ready for CI at once, and each push can set several jobs fetching the same commit.

从去年年底前后开始,支撑我们 monorepo 的系统就难以跟上需求。我们遭遇了拉取和推送缓慢以及合并失败的问题,可靠性有时甚至低于 90%。是我们触及了 Git 本身的极限,还是我们服务 monorepo 的方式达到了极限?Git 诞生于一个通过电子邮件交换内核补丁的社区。二十多年来,随着开发者构建软件的方式不断变化,他们一直在围绕 Git 调整自己的工具。当我们开始在自己的 monorepo 中感受到摩擦时,对我们来说重要的是能够继续在这一成果之上构建。

Starting around the end of last year, the systems supporting our monorepo were struggling to keep up. We suffered slow fetches and pushes along with failed merges, with reliability at times falling below 90%. Had we reached a limit of Git itself, or of the way we served our monorepo? Git grew out of a community that exchanged patches to the kernel via email. For more than two decades, developers have adapted their tools around Git as the way they build software has changed. When we started to feel friction in our own monorepo, it mattered to us that we could keep building on that work.

我们找到了一种方法,既能保留熟悉的工作流程,又能重建后端,以并行处理推送到不同分支的操作,并同时向多个读取者提供相同的历史记录。以 Git 作为我们源代码控制工作流程的基础,意味着对客户端的改进可能惠及 OpenAI 之外。我们希望把我们 Git 副本中的这些改进贡献给上游,与更广泛的社区分享。

We saw a way to keep that familiar workflow while rebuilding the backend to handle pushes to different branches in parallel and serve the same history to many readers concurrently. Building on Git as the foundation of our source-control workflow meant that improvements to the client could be useful beyond OpenAI. We wanted to contribute those improvements from our copy of Git ⁠ (opens in a new window) to upstream, sharing them with the broader community.

扩展源代码控制系统有两个关键维度:许多写入者推送到不同分支,以及许多读取者拉取相同的历史记录。Pando 针对这两方面都进行了优化。

Scaling a source control system has two essential dimensions: many writers pushing to different branches, and many readers fetching the same history. Pando optimizes for both.

首先,Pando 独立协调对每个分支的更新。对不相关分支的更新可以并行进行,而拉取某个分支的读取者会获得该修订所需的历史记录。代价是,查看多个分支的读取者可能会在不同时间点看到它们。

First, Pando coordinates updates to each branch independently. Updates to unrelated branches can proceed in parallel, and a reader fetching a branch gets the history needed for that revision. The tradeoff is that a reader looking at several branches can see them at different points of time.

其次,Pando 在多次拉取之间复用 packfile(Git 将多个对象压缩在一起的格式),而不是为每个客户端生成单独的 packfile。客户端可能会下载一些它已经拥有的对象,但服务器可以用很少的计算量向许多客户端提供相同的字节。

Second, Pando reuses packfiles (Git’s format for compressing multiple objects together) across fetches instead of generating an individual packfile for each client. A client may download some objects it already has, but the server can serve the same bytes to many clients with little computation.

这些选择让我们能够跨分支扩展写入,并从缓存中提供读取。为了了解它们如何协同工作,让我们先从 Git 如何存储和传输历史记录说起。

These choices let us scale writes across branches and serve reads from caches. To see how they fit together, let’s start with how Git stores and transfers history.

Git 必须能够保持仓库的两个部分同步:对象和引用。

Git must be able to keep two parts of a repository in sync: objects and references .

Git 仓库将文件的快照以及连接它们的历史记录为一个对象图。对象可以是 blob、tree、commit 或 tag。blob 保存单个文件的内容,tree 将名称与 blob 或其他 tree 关联起来,形成目录结构。commit 指向一个根 tree 和零个或多个父 commit,构成仓库的历史。

A Git repository records snapshots of files and the history connecting them as a graph of objects. An object may be either a blob, tree, commit, or tag. Blobs hold the content of an individual file, and trees associate names with blobs or other trees to form a directory structure. Commits point to a root tree and zero or more parent commits, forming the history of your repository.

对象通过其类型和内容的哈希值来标识。对象也是不可变的:记录一个已更改的文件会创建一个新的 blob,而未更改的文件和目录可以复用现有对象。

Objects are identified by a hash of their type and contents. Objects are also immutable: recording a changed file creates a new blob, while unchanged files and directories can reuse existing objects.

分支和标签是引用(“ref”),指向 commit。在分支上提交会创建一个新的 commit,并将该分支的 ref 更新为指向它。

Branches and tags are references, or “refs”, that point to commits. Committing on a branch creates a new commit and updates the branch’s ref to point to it.

Git 对象通过其 ID 相互引用,commit 引用 tree,tree 引用 tree 和 blob。分支 refs/heads/main 指向 commit C2,其父 commit 为 C1。C1 指向根 tree T1,其中 parser.py 引用 blob B1。C2 指向根 tree T2,其中 parser.py 引用 blob B2。在两个根 tree 中,docs/ 都指向同一个 tree T3。其 README.md 条目指向 blob B3,usage.md 指向 blob B4。

Git objects reference each other by their ID, commits to trees, and trees to trees and blobs. The branch refs/heads/main points to commit C2, whose parent is C1. C1 points to root tree T1, where parser.py refers to blob B1. C2 points to root tree T2, where parser.py refers to blob B2. In both root trees, docs/ refers to the same tree, T3. Its README.md entry points to blob B3, and usage.md points to blob B4.

Git 以“松散”或“打包”状态存储对象。松散对象存储在以其对象 ID 标识的单独文件中。打包对象一起存储在一个 packfile 中,使相似对象能够以彼此之间的增量形式存储。

Git stores objects in either a “loose” or “packed” state. Loose objects are stored in individual files identified by their object ID. Packed objects are stored together in a packfile, enabling similar objects to be stored as deltas against one another.

Git 可以将 blob 存储为单独的文件,也可以将它们打包在一起,将一个 blob 编码为相对于另一个 blob 的增量。

Git can store blobs as separate files or pack them together, encoding one blob as a delta against another.

在 Git 中,如果 Git 能够从某个 commit 出发,沿着其父 commit、tree 和 blob 的链接找到某个对象,则该对象从该 commit 可达。在 fetch 期间,客户端告诉服务器它想要哪些 commit 以及它已经拥有哪些 commit。服务器找到从所需 commit 可达的对象,排除它知道客户端已经拥有的对象,并将剩余部分以 Git 在磁盘上使用的相同格式作为 packfile 发送。完整克隆开始时没有任何对象,因此它需要被克隆历史中所有可达的对象。

In Git, an object is reachable from a commit if Git can find it by following links from that commit through its parents, trees, and blobs. During a fetch, the client tells the server which commits it wants and which it already has. The server finds the objects reachable from the wanted commits, excludes those it knows the client already has, and sends the remainder as a packfile in the same format Git uses on disk. A full clone starts without any objects, so it needs all the objects reachable from the history being cloned.

推送则通过请求服务器更新一个或多个 ref 来将对象传输到相反方向。客户端利用服务器公布的一组 ref 来避免发送服务器已拥有的对象。因此,所发送的 pack 可能依赖于已有对象:仅接收该 pack 不足以重建新的历史。

A push transfers objects in the other direction by asking the server to update one or more refs. The client uses the server’s set of advertised refs to avoid sending objects the server already has. The pack being sent can therefore depend on existing objects: receiving the pack alone is not enough to reconstruct the new history.

复制 Git 仓库意味着在多个服务器之间同时保持对象和引用可用。在副本能够提供某个引用的新值之前,它必须能够提供从该值可达的对象。该服务还需要协调相互竞争的引用更新,即试图将同一分支从同一旧顶端移动到不同新提交的推送。对所有仓库写入施加单一顺序的系统,会使对无关分支的推送相互等待。

Replicating a Git repository means keeping both objects and references available across multiple servers. Before a replica can serve a reference’s new value, it must be able to supply the objects reachable from that value. The service also needs to coordinate competing reference updates , i.e., pushes that try to move the same branch from the same old tip to different new commits. Systems that impose a single order on all writes to a repository can make pushes to unrelated branches wait on one another.

在设计 Pando 时,我们评估了使用 Git 扩展源代码控制的常规方法:一种使用三阶段提交(3PC,一种跨多个节点协调提交的协议)在仓库副本之间协调 ref 更新,另一种通过 blob 存储中的共享预写日志(WAL,在应用更改之前写入的更改记录)对更新进行排序。

While designing Pando, we evaluated conventional approaches for scaling source control using Git: one that coordinates ref updates across repository replicas using three-phase commit (3PC, a protocol for coordinating a commit across multiple nodes), and one that orders updates through a shared write-ahead log (WAL, a record of changes written before they’re applied) in blob storage.

在我们建模的三阶段提交设计中,Git 服务在多个副本上保留仓库的完整副本。当任何服务器收到推送时,传入的 packfile 会被复制并并行发送到所有副本。要发布该推送,必须有多数副本接受 ref 更新。管理此过程的服务器是协调者,它需要协调者与每个其他副本之间进行多轮通信。

In the three-phase commit design we modeled, the Git service keeps a complete copy of the repository on several replicas. When any server receives a push, the incoming packfile is copied and sent to all replicas in parallel. To publish the push, a majority of replicas must accept the ref update. The server managing this is the coordinator, and it requires multiple rounds of communication between the coordinator and each other replica.

为了接受引用更新,每个副本会锁定其 ref 副本,并检查它是否仍指向客户端所期望的提交。然后,协调者向接受的副本发送预提交消息。一旦多数副本确认预提交消息,协调者便指示它们执行更新。此后,任何已更新的副本都可以从其本地仓库副本公布新的分支顶端。

To accept a reference update, each replica locks its copy of the ref and checks that it still points to the commit the client expects. The coordinator then sends a pre-commit message to the replicas that accept. Once a majority acknowledges the pre-commit message, the coordinator tells them to perform the update. Any up-to-date replica can then advertise the new branch tip from its local copy of the repository.

保留完整副本使得在本地提供读取服务成为可能,并保证无论客户端选择哪个副本,都能获得所有引用的一致视图。因此,引用是一次更新一个的,而每次推送都需要多次往返,以在副本之间协调引用更新。

Keeping complete replicas makes it possible to serve reads locally, and guarantees that clients get a consistent view of all references no matter which replica they pick. As a consequence, references are updated one at a time, and each push requires multiple round trips to coordinate the ref update among replicas.

等待法定人数会将副本磁盘性能和通信延迟引入推送路径。随着写入量增长,副本必须跟上传入的包以及读取流量。

Waiting for a quorum puts replica disk performance and communication latency on the push path. As write volume grows, the replicas must keep up with incoming packs as well as read traffic.

在我们建模的基于 WAL 的设计中,Git 服务使用 blob 存储中的共享清单来对仓库中的更新进行排序。当服务器收到推送时,它会将传入的包文件上传到 blob 存储,并在其本地仓库副本中准备引用更新。为了发布该推送,它会向存储在 blob 存储中的共享清单添加一个条目,记录引用更新并指向该包文件。随后,Git 服务器使用比较并交换操作更新该清单。这会原子性地替换清单,否则就拒绝该更改。如果在此期间另一个写入者更新了它,服务器会读取其间产生的条目,检查其引用更新是否仍然有效,并使用它已经上传的包文件重试。

In the WAL-based design we modeled, the Git service uses a shared manifest in blob storage to order updates across the repository. When a server receives a push, it uploads the incoming packfile to a blob store and prepares the ref update in its local copy of the repository. To publish the push, it adds an entry to a shared manifest stored in the blob store that records the ref update and points to the packfile. The Git server then updates the manifest using a compare-and-swap operation. This atomically replaces the manifest, or otherwise rejects the change. If another writer has updated it in the meantime, the server reads the intervening entries, checks that its ref update is still valid, and retries using the packfile it already uploaded.

写入者可以并行上传各自的包文件,但即使推送到不相关的分支,也需要更新同一个清单。成功完成比较并交换的往返时间限制了仓库发布新清单的频率。低延迟的 blob 存储使这一步变得很快。批处理让一次清单更新可以同时更新多个引用,代价是更新需要排队并增加延迟。

Writers can upload their packfiles in parallel, but even pushes to unrelated branches require updating the same manifest. The round-trip time for a successful compare-and-swap limits how often the repository can publish a new manifest. A low-latency blob store makes this step fast. Batching lets one manifest update several refs at the same time, at the cost of queueing updates and increasing latency.

blob 存储可以并行接收包文件,但对共享清单的更新仍然会相互竞争。仅增加 blob 存储的容量并不能解决这一瓶颈。每个副本仍然需要先从 blob 存储读取并索引包,然后才能在本地提供这些包。如果传入写入的速度超过这项工作,副本就会落后,客户端获取新推送提交的等待时间也会更长。

The blob store can receive packfiles in parallel, but updates to the shared manifest still compete with one another. Increasing the blob store’s capacity alone doesn’t resolve that bottleneck. Each replica still needs to read and index packs from the blob store before it can serve them locally. If incoming writes outpace that work, replicas fall behind and clients wait longer to fetch newly pushed commits.

这就引出了 Pando。Pando 是一种用于托管 Git 仓库的新架构,目标是扩展到大量客户端同时推送的场景。其工作原理如下:

That brings us to Pando. Pando is a new architecture for serving Git repositories with the goal of scaling to many clients pushing simultaneously. Here’s how it works:

在开发 Pando 之前,我们有一个预感:我们可以在不牺牲 Git 的前提下满足自身需求,但确实需要在某些方面做出妥协——而这些方面是大多数 Git 系统默认视为需求的前提:

Prior to developing Pando, we had a hunch that we could meet our requirements without compromising on Git, but we did need to compromise on some of the things that most Git systems assume to be requirements:

仓库级一致性:要提供所有 ref 的一致、某一时间点的快照,需要在整个仓库范围内进行协调。在一个将所有 ref 更新统一排序的系统中,推送到互不相关的分支也会在同一个协调点上产生争用。

Repository-wide consistency : Providing a consistent, point-in-time snapshot of all refs requires coordination across the repository. In a system that orders all ref updates together, pushes to unrelated branches contend on a single coordination point.

为每个客户端生成唯一的 packfile:如果两个本地历史不同的客户端获取同一个分支,服务器可能需要为每个客户端生成不同的 pack,以避免发送它们已经拥有的对象。生成这些响应会消耗 CPU 和磁盘 I/O,因此难以扩展到大量读取者。

Unique packfiles for every client : If two clients with different local histories fetch the same branch, the server may need to generate a different pack for each to avoid sending objects they already have. Creating these responses costs CPU and disk I/O, making it difficult to scale to high volumes of readers.

因此,Pando 提供一种宽松的一致性模型(因果一致性)来扩展写入,并复用 packfile 来扩展读取。

Instead, Pando provides a relaxed consistency model (causal consistency) to scale writes, and reuses packfiles to scale reads.

当客户端推送到某个分支时,Pando 将传入的 packfile 作为不可变 blob 存储在 blob 存储中。每当分支发生移动,Pando 会在元数据存储中记录一个 ref 版本,其中包含新的 tip、提供该 tip 的 pack,以及该 pack 所依赖的任何更早的 ref 版本。blob 存储和元数据存储均可水平扩展。

When a client pushes to a branch, Pando stores the incoming packfile as an immutable blob in a blob store. Each time the branch moves, Pando records a ref version containing the new tip, the pack that supplied it, and any earlier ref versions the pack depends on in a metadata store. Both the blob store and metadata store are horizontally scalable.

从 Pando 获取某个提交或引用,需要向客户端重放一组 ref 版本(packfile),重建出创建所获取 ref 版本的那个客户端的状态。这在整个仓库范围内提供了一种较弱的一致性形式,同时对单个 ref 的更新提供可串行化。只有当客户端同时推送到同一个 ref 时才会发生冲突。读取多个分支的客户端不能假定这些读取描述的是整个仓库在某一时间点的状态。

Fetching a commit or reference from Pando requires replaying a set of ref versions (packfiles) to the client, reconstructing the state of the client that created the ref version being fetched. This provides a weaker form of consistency across the entire repository, while providing serializability for updates to individual refs. Clients only conflict when pushing to the same ref simultaneously. A client reading several branches cannot assume those reads describe a single point in time across the repository.

向主干推送会添加一个增量包,其中包含一个或多个提交。每次向侧分支推送都会再次包含该主题的早期提交,因此拥有所公布主干版本的客户端可以在一个包中获取该主题。

A push to trunk adds an incremental pack, containing one or more commits. Each push to a side branch includes the topic’s earlier commits again, so a client with the advertised trunk version can fetch the topic in one pack.

这是一种因果一致性形式。为了获取某个引用,读取方会观察到产生该引用的写入方的历史。在推送过程中,Pando 控制客户端和服务器就哪些共享历史达成一致,确保客户端生成更易于共享的包文件。

This is a form of causal consistency . In order to fetch a reference, the reader observes the history of the writer that produced it. During a push, Pando controls what shared history the client and server agree on, ensuring clients produce more easily shared packfiles.

因此,Pando 在 Git 操作期间不提供所有引用的时间点状态,也不提供克隆或获取过程中引用更新的顺序。具体而言,假设分支 foo 和 bar 在一次完整克隆的协商过程中都被更新。在协商期间,一个客户端可能观察到 foo 为版本 1、bar 为版本 2,而另一个客户端观察到 foo 为版本 2、bar 为版本 1。在实践中,用户和代理并不关心引用更新的全局顺序,而是依赖于对单个引用的更新顺序。

As a consequence, Pando doesn’t provide a point-in-time state of all references during Git operations or an ordering of ref updates within a clone or fetch. Concretely, suppose that branches foo and bar are both updated during the negotiation of a full clone. During the negotiation, one client may observe foo at version 1 and bar at version 2, while another client observes foo at version 2 and bar at version 1. In practice, users and agents are agnostic to the global ordering of ref updates, and instead depend on the order of updates to a single reference.

在三种一致性模型的这次模拟中,我们配置了 1,000 个客户端,每个客户端选择一个不同的分支,然后反复推送唯一的提交,测量总挂钟时长和推送至获取的延迟。后者是工作负载的一项重要指标,因为它衡量用户和代理协作或使用其他依赖版本控制的系统时的往返时间。该模拟对从普通到高端的虚拟机和 blob 存储系统的硬件进行了建模。在这次模拟中,我们为三阶段提交放宽了仓库范围的一致性。

In this simulation of the three consistency models we configure 1,000 clients to each select a distinct branch and then repeatedly push unique commits, measuring total wall clock duration and push to fetch latency. The latter is an important metric for workloads, as it measures round trip time for users and agents to collaborate or to use other systems which rely on version control. The simulation models hardware ranging from commodity to premium virtual machines and blob storage systems. In this simulation, we’ve relaxed repository-wide consistency for three-phase commit.

跟踪每个写入方经历反复推送的过程,并单独测量独立的读取方何时可以检出每个提交。

Follow each writer through repeated pushes, and separately measure when an independent reader can check out each commit.

每个方块代表一个写入方。所有选定的架构运行相同的工作负载。随着推送被确认,方块会变亮,当写入方完成时变为蓝色。该图表显示了写入方在模拟时间内完成的情况;独立的读取方之后可以继续获取。使用方向键选择写入方,Home 或 End 跳转,Escape 清除。

Each square represents one writer. All selected architectures run the same workload. Squares lighten as pushes are acknowledged and turn blue when a writer finishes. The chart shows writers finished over simulated time; independent readers can continue fetching afterward. Use arrow keys to select a writer, Home or End to jump, and Escape to clear.

已确认 0 / 10,000 次推送 · 已获取 0 次

0 / 10,000 pushes acknowledged · 0 fetched

合成教学模型,而非生产基准。获取的平均推送覆盖主题推送,从首次尝试到重试,直到独立读取者验证该提交。它包括等待读取者槽位,但不包括构建和测试。启用合并后,写入者完成包括所需的获取和主干合并。

Synthetic teaching models, not production benchmarks. Mean push to fetch covers topic pushes, from the first attempt through retries until an independent reader verifies that commit. It includes waiting for a reader slot and excludes builds and tests. With merges enabled, writer completion includes the required fetches and trunk merge.

播放对比以查看记录的结果。

Play the comparison to see the recorded results.

运行此模拟,将 Pando 与另外两种方法进行比较。从普通到高级硬件选择基础设施、客户端数量以及更多设置,以查看它们的比较情况。

Run this simulation comparing Pando with two other approaches. Choose infrastructure from commodity to premium hardware, number of clients, and more settings to see how they compare.

建模的三阶段提交系统显示,在磁盘饱和时,负载下的写入延迟显著更高;同时,预写日志系统出于同样原因显示读取延迟显著更高,因为服务器难以跟上从日志读取。在我们 monorepo 的真实世界测试和此模拟中,Pando 都支持数千个客户端能够并发推送,而不会在负载下影响性能。

The modeled three-phase commit system shows significantly greater write latency under load as their disks saturate; meanwhile, write-ahead log systems show significantly greater read latency for the same reason, as servers struggle to keep up with reading from the journal. In both real world testing on our monorepo and in this simulation, Pando supports many thousands of clients able to push concurrently without impacting performance under load.

在处理推送时,Pando 在将传入的包文件流式传输到 blob 存储的同时进行验证,而不将其解包到本地仓库。当客户端开始获取时,Pando 选择读取者所需的已存储包,读取者下载它们。没有服务器需要将包文件应用到本地仓库或执行昂贵的解包和打包操作。由于这些服务器主要执行协商和包文件选择,Pando 服务器可以在普通硬件上运行。

On handling a push, Pando validates the incoming packfile while streaming it to blob storage, without unpacking it into a local repository. When a client begins a fetch Pando selects the stored packs the reader needs, and the reader downloads them. No server needs to apply packfiles to a local repository or perform costly unpack and packing operations. Because these servers primarily perform negotiation and packfile selection, Pando servers can run on commodity hardware.

这允许 Pando 扩展到客户端、客户端与 Pando 之间的网络以及 blob 存储服务的极限。有足够容量时,在独立分支上工作的客户端可以各自以自身连接允许的速度传输包。要以该速率服务更多客户端,我们可以添加 Pando 服务器,并随之扩展元数据存储和 blob 存储。

This allows Pando to scale to the limits of clients, the network between clients and Pando, and the blob storage service. With enough capacity, clients working on independent branches can each transfer packs as fast as their own connection allows. To serve more clients at that rate, we can add Pando servers and scale the metadata store and blob store alongside them.

Pando 将写入者的包文件存储在 blob 存储中,并在 Turtle 中记录引用版本。获取时,Pando 选择读取者所需的包,并由 Express 提供它们。

Pando stores the writer’s packfile in blob storage and records the ref version in Turtle. On fetch, Pando selects the packs the reader needs, and Express serves them.

一个 agent 在本地编辑文件并创建提交,然后运行 git push,这会将这些变更打包成一个 packfile 以更新某个分支。Pando 接收该 pack 并将其流式传输到 blob 存储。在通过单次解码验证传入的 push 之后,Pando 使用多键事务在元数据存储中记录一个 ref 版本,并原子性地更新 ref 指针。这使得 Pando 能够提供“读己之写”一致性。整个写操作需要 O(1) 次元数据读取和写入。

An agent edits files and creates a commit locally and runs git push , which creates a packfile of those changes to update a branch. Pando receives the pack and streams it to blob storage. After validating the incoming push with a single pass decode, Pando uses a multi-key transaction to record a ref version in our metadata store and atomically update the ref pointer. This enables Pando to provide “read-your-own-write” consistency. This entire write operation requires O ( 1 ) O(1) O ( 1 ) metadata reads and writes.

当另一个客户端拉取该分支时,Pando 根据客户端已有的历史选择一组已存储的 pack。此操作需要 O(log Δ) 次元数据读取,其中 Δ 是客户端已有内容与客户端所需内容之间在 ref 版本上的最短距离。服务器返回 packfile URI,客户端通过一个名为 Express 的服务下载它们,该服务将 packfile 存储在区域缓存中。

When another client fetches the branch, Pando selects a set of stored packs using the history the client already has. This operation requires O ( log ⁡ Δ ) O(\log \Delta) O ( lo g Δ ) metadata reads, Δ \Delta Δ being the shortest distance in ref versions between what the client has and what the client wants. The server returns packfile URIs, and the client downloads them through a service, Express, that stores packfiles in regional caches.

这一设计依赖于 Pando 架构的三个核心服务:push、fetch 和 compaction。

This design relies on the three central services of Pando’s architecture: pushes, fetches, and compaction.

当客户端执行 push 时,传统 Git 服务器就像一个亮出所有底牌的扑克玩家,向客户端暴露它拥有的每一个分支。然后客户端收集 commit、tree 和 blob,创建一个排除了它已知服务器已有对象的 packfile。

When a client pushes, a conventional Git server is like a poker player showing all of its cards, revealing to the client every branch it has. The client then gathers the commits, trees, and blobs to create a packfile that excludes objects it knows the server already has.

公布更多的 ref 可以使 push 更小。它也可能使 pack 更难被复用,因为另一个客户端可能缺少写入者省略掉的对象。

Advertising more refs can make the push smaller. It can also make the pack harder to reuse, because another client may be missing objects the writer left out.

Pando 采取了不同的方法。它不亮出全部底牌,而是只向客户端公布一组选定的分支。这样做有两个原因:

Pando takes a different approach. Instead of showing its full hand, it only advertises a select set of branches to the client. This is done for two reasons:

通过只向客户端提供 ref 的一个子集,客户端生成的 pack 将只依赖于服务器明确允许客户端排除的内容。跟踪这些依赖关系使 Pando 能够复用客户端在一次 push 中生成的 packfile,将其作为后续 fetch 的响应来提供。

By providing only a subset of the refs to the client, the client will generate a pack that depends only on what the server explicitly allows the client to exclude. Tracking the dependencies allows Pando to reuse the packfile a client generates in one push by serving it as the response to a subsequent fetch.

当 Git 服务器公布更多 ref 时,推送的客户端就有更多来源可用于排除对象,从而生成更小的 pack。然而,复用这些 packfile 要求服务器能够证明获取的客户端拥有每一个依赖项。否则,packfile 可能会遗漏客户端所需的对象。

As a Git server advertises more refs, clients pushing have more sources from which to exclude objects, enabling them to produce smaller packs. However, reusing these packfiles requires the server to be able to prove the clients fetching have each of the dependencies. Otherwise, the packfile may omit objects the client needs.

另一方面,如果 Git 服务器完全不公布任何 ref,客户端就会生成一个包含仓库完整历史的 packfile。该 packfile 可供任何其他客户端使用,但代价显著:获取任何分支实际上都变成了完整克隆。

On the other hand, if a Git server advertises none at all, the client would generate a packfile containing the repository’s full history. That packfile can be used by any other client, but at the significant cost of making fetching any branch effectively a full clone.

公布更多 ref 会得到更小的 packfile。大部分体积缩减可能仅来自公布一个 ref。

Advertising more refs results in smaller packfiles. Most of the size reduction can come from advertising just one.

这会导致后续的分支推送更大,包含可能冗余的对象,并占用额外的客户端带宽。在我们的 monorepo 中,以这种方式生成的 packfile 中位数低于 20 KiB,第 99 百分位低于 3 MiB。对我们来说,这是一个合理的权衡,因为已经拥有所公布主干历史的读取者可以用那一个 packfile 获取该分支。

This causes successive branch pushes to be larger, containing potentially-redundant objects, and uses additional client bandwidth. In our monorepo, the median packfile produced this way was under 20 KiB, and the 99th percentile was under 3 MiB. For us, this was a sensible trade-off because a reader that already has the advertised trunk history can fetch the branch with that one packfile.

在选择好要向客户端公布的 ref 集合后,Pando 接受推送并更新其元数据存储。Pando 将元数据更新拆分为同步和异步两部分。同步元数据更新确保客户端能够立即获取新更新的提交。这会写入一个新的 ref 版本,并将 ref 指针映射更新到该新版本,其中存储新的 tip、用于协商 packfile 的依赖项,以及指向所推送 packfile 的链接。

After choosing the set of refs to advertise to the client, Pando accepts the push and updates its metadata store. Pando splits the metadata update into synchronous and asynchronous portions. The synchronous metadata update ensures clients can immediately fetch the newly updated commit. This writes a new ref version and updates the ref pointer mapping to that new version storing that new tip, the dependencies used to negotiate the packfile, and a link to the packfile that was pushed.

同时,异步工作记录在同一事务中,例如调度压缩。对于非常大的推送,只有一部分提交被同步写入。这使我们无论推送大小如何,都只需要对元数据存储进行常数次数的读写。

At the same time, asynchronous work is recorded in the same transaction, such as scheduling compaction. For very large pushes, only a subset of commits are written synchronously. This allows us to require only a constant number of reads and writes to the metadata store, regardless of the size of the push.