# 派珀（源代码控制系统）

**派珀**（Piper）是谷歌内部自建的集中式版本控制系统，将公司几乎所有源代码存储于单一巨型仓库（monorepo）中。它取代了谷歌自弃用 CVS 以来一直使用的商业 Perforce 服务器，并由谷歌工程师 Rachel Potvin 与 Josh Levenberg 在 2016 年《ACM 通讯》的文章《为什么谷歌将数十亿行代码存储在单一仓库中》中公开介绍。<sup>[1](https://research.google.com/pubs/pub45424.html?hl=nb)</sup><sup> • </sup><sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> 大多数开发者通过一个名为“云中客户端”（Clients in the Cloud，CitC）的配套系统访问派珀，该系统将云端托管的工作区呈现为本地目录。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 谷歌自研的集中式版本控制系统，作为分布式微服务运行在谷歌生产基础设施上<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup> |
| 仓库规模（2015 年 1 月） | 约 10 亿个文件、900 万个唯一源文件、20 亿行代码、86 TB 内容、历史上约 3500 万次提交<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> |
| 日常活动（2015 年） | 每个工作日约 4 万次变更，其中约 1.6 万次来自工程师、2.4 万次来自自动化系统；平均每秒约 50 万次文件读取，峰值接近 80 万次<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> |
| 用户 | 2.5 万余名开发者，约占当时谷歌软件开发人员的 95%<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> |
| 访问模式 | 大多数用户通过 CitC 工作，其后端为云存储，前端为仅限 Linux 的 FUSE 文件系统；截至 2016 年，超过 80% 的派珀用户使用 CitC<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup> |
| 开发风格 | 在单一主线上进行主干开发，变更须经强制代码审查后以变更列表（CL）形式提交<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup><sup> • </sup><sup>[5](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/0449374e831a796a5e88f92380c64e7e090c6dfa.pdf)</sup> |
| 显著例外 | Chrome 与 Android 在巨型仓库之外的独立 Git 仓库中开发<sup>[6](https://singhajit.com/how-google-manages-its-monorepo/)</sup> |

## 历史

谷歌的源代码控制谱系从 CVS 到 Perforce 再到派珀。关于巨型仓库论文的公开记述称，代码库于 1999 年从 CVS 迁移至 Perforce，单一仓库策略即始于那次迁移。<sup>[7](https://gist.github.com/roninjin10/75ead3a978a0cf16b917e66fa7f74bac)</sup> 一位谷歌工程师在 Hacker News 上的记述将采用 Perforce 的时间定在 2000 年，并回忆道 2011 年整个 google3 代码树仍存放在一台巨大的 Perforce 服务器上，每天早上所有人同步当日工作时，服务器都会陷入停滞。<sup>[8](https://news.ycombinator.com/item?id=48126002)</sup>

巨型仓库论文称，谷歌约在 2012 年改用自研的源代码控制实现来托管中央仓库；这个为存储、版本管理和分发代码库而构建的专有系统被命名为派珀。<sup>[7](https://gist.github.com/roninjin10/75ead3a978a0cf16b917e66fa7f74bac)</sup> 一份关于该时期的综述称，谷歌保留了类 Perforce 模型，因为约在 2010 年 Perforce 达到极限时，拆分为多个 Git 仓库的替代方案被否决了。<sup>[10](https://gist.github.com/stakiran/63c4cb929db73c4dbc4e92e3a38ce090)</sup>

## 规模

Potvin 与 Levenberg 论文中 2015 年 1 月的数据仍是参照基准，因为此后谷歌公布的可比数据甚少。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> 仓库当时约有 10 亿个文件，包括配置、文档和已删除文件，其中约 900 万个为唯一源文件，合计约 20 亿行代码，存储量 86 TB，历史上约 3500 万次提交。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> 作为对比，当时的 [Linux 内核](https://www.edgepedia.org/zh/linux-kernel)在约 4 万个文件中包含约 1500 万行代码。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup>

**自动化主导了提交流。** 2015 年典型工作日提交的约 4 万次变更中，约 2.4 万次来自自动化系统，可见机器提交量已超过人类。提交自动化于 2012 年引入，此后自动化提交量急剧上升。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup><sup> • </sup><sup>[11](https://www.school.ctc-g.co.jp/columns/nakai2/nakai220.html)</sup> 在 2015 年的一个典型周内，约 25 万个文件中的约 1500 万行代码发生了变更。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup>

由谷歌工程师撰写的《谷歌软件工程》一书报告了更晚也更大的数字：巨型仓库由约 5 万名工程师共享，每个工作日处理 6 万至 7 万次提交。<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup>

## 设计

派珀是集中式版本控制系统，与 Git 等分布式系统相对——在分布式系统中每位开发者都持有仓库及其历史的完整副本。以谷歌的规模，在本地克隆超过 86 TB 的仓库不可行，这是公司构建并保留集中式设计的核心原因之一。<sup>[12](https://summaries.fyi/t/software-engineering-at-google-by-titus-winters-tom-manshreck-hyrum-wright/18)</sup> 派珀被构建为在谷歌生产环境中运行的分布式微服务，有记述称其存储层建立在 Spanner——谷歌的全球分布式数据库——之上。<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup><sup> • </sup><sup>[6](https://singhajit.com/how-google-manages-its-monorepo/)</sup>

**云中客户端。** 大多数开发者通过 CitC 访问派珀，CitC 由基于云的存储后端和仅限 Linux 的 FUSE 文件系统组成。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup> CitC 工作区是仓库的写时复制快照，通过网络挂载在 Linux 工作站上，因此开发者可以像整棵代码树在本地一样搜索、浏览和编辑文件，而只有被修改的文件才存入云存储；平均每个工作区保存的文件不足十个。<sup>[11](https://www.school.ctc-g.co.jp/columns/nakai2/nakai220.html)</sup><sup> • </sup><sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> CitC 将每次文件保存——包括通常每 30 秒一次的编辑器自动保存——记录为新快照，从而提供比派珀修订本身更细粒度的文件演化记录。<sup>[5](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/0449374e831a796a5e88f92380c64e7e090c6dfa.pdf)</sup> 派珀也可在不使用 CitC 的情况下使用，此时工作区存储在本地机器上。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup>

**安全与所有权。** 由于谷歌的源代码是公司最重要的资产之一，安全塑造了派珀的设计：它支持文件级访问控制列表。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup> 默认情况下所有工程师均可访问，所有操作均有日志记录，仅极少数高度机密文件作为例外受到限制。<sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup> 由于派珀是自研产品，谷歌可以强制执行其选择的任何源代码控制策略；在文件层级的每一层，OWNERS 文件列出允许批准该子树内提交的工程师，版本控制系统本身在提交时强制执行所有权。<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup>

**延迟。** 对日常用户而言，系统操作保持快捷：在主干上创建新客户端、添加一个文件、并向派珀检入一个未经审查的变更，合计约需 15 秒。<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup>

## 工作流程

谷歌在派珀之上实践主干开发：绝大多数用户在代码单一副本的头部——称为主干或主线——工作，变更以单一串行顺序落地，长期存活的开发分支极为罕见。发布分支作为头部的快照切出，附带少量拣选提交。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup>

变更以变更列表（CL）形式提交，相当于 Git 提交或 [Subversion](https://www.edgepedia.org/zh/subversion) 修订版。<sup>[13](https://opensource.google/documentation/reference/glossary?authuser=371)</sup> 变更列表是对一个或多个文件的事务性更新，只有在谷歌的代码审查工具 Critique 中经至少一位同行审查后方可提交。<sup>[5](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/0449374e831a796a5e88f92380c64e7e090c6dfa.pdf)</sup> 配套系统包括：Tricorder 静态分析平台，将分析评论发布到审查中；预提交基础设施，在变更落地前对其进行测试和分析；自动回滚系统，回滚导致大范围构建失败的变更；以及 Rosie，一个大规模清理工具，将大型补丁拆分为小块，分别审查和提交。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup><sup> • </sup><sup>[13](https://opensource.google/documentation/reference/glossary?authuser=371)</sup>

单一代码树模型还支撑着谷歌的“单一版本”政策：仓库中的每个依赖只能有一个可选版本，从而消除菱形依赖冲突——即两个库要求第三个库的不兼容版本。<sup>[4](https://abseil.io/resources/swe-book/html/ch16.html)</sup><sup> • </sup><sup>[2](https://acraske.com/ideas/how-google-does-monorepo)</sup>

## 例外与互操作性

巨型仓库并非谷歌的全部。Chrome 与 Android 是显著例外，使用 Git 在独立仓库中开发，部分原因是它们与外部合作伙伴和开源贡献者协作，且发布节奏不同；谷歌的生产 Git 服务名为 git-on-borg。<sup>[6](https://singhajit.com/how-google-manages-its-monorepo/)</sup><sup> • </sup><sup>[13](https://opensource.google/documentation/reference/glossary?authuser=371)</sup> 派珀本身与 Git 的互操作性有限。<sup>[3](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)</sup> 第三方代码在代码树内有自己的约定，路径 `//piper/.../third_party` 和 `//piper/.../vendor_src` 分别用于针对 google3 构建的包和独立引入的包，Copybara 工具则用于将外部 Git 仓库中的代码提取为派珀变更列表。<sup>[14](https://opensource.google/documentation/reference/thirdparty/vendorsrc)</sup>

## 影响

派珀与 CitC 在 Jujutsu 版本控制项目中被引为混合云设计的范例，该项目将其用户界面和版本控制算法与存储后端抽象分离，并将派珀/CitC 与 [Mercurial](https://www.edgepedia.org/zh/mercurial)、Breezy 并列为具有自身数据和网络模型的后端示例。<sup>[15](https://github.com/jj-vcs/jj)</sup> 一位 Jujutsu 贡献者在 LWN 上指出，派珀与 Git 在设计上差异很大，却支持许多相同的工作流程，并列举了原生后端可以提升为一等公民、而在 Git 数据模型中难以实现的功能，包括访问控制列表、大文件分块、云存储、虚拟化 FUSE 检出和保存即提交，其中若干项派珀已在实践中展示。<sup>[16](https://lwn.net/Articles/958902/)</sup>

## References

1. [Why Google Stores Billions of Lines of Code in a Single Repository, Rachel Potvin and Josh Levenberg, Communications of the ACM 59 (2016)](https://research.google.com/pubs/pub45424.html?hl=nb)
2. [How Google Does Monorepo, Antoine Craske](https://acraske.com/ideas/how-google-does-monorepo)
3. [Potvin and Levenberg, contributed article PDF (CACM 2016)](https://bowringj.people.charleston.edu/classes/csci%20362/docs/GoogleCodeRepo-78-potvin.pdf?id=0B2El51RQ1MQnTTVWYVNiOWhuX0U)
4. [Software Engineering at Google, Chapter 16: Version Control and Branch Management](https://abseil.io/resources/swe-book/html/ch16.html)
5. [Resolving Code Review Comments with Machine Learning (ICSE-SEIP 2024)](https://storage.googleapis.com/gweb-research2023-media/pubtools/pdf/0449374e831a796a5e88f92380c64e7e090c6dfa.pdf)
6. [How Google manages billions of lines of code in one monorepo, Ajit Singh](https://singhajit.com/how-google-manages-its-monorepo/)
7. [CitC and Piper research, GitHub gist](https://gist.github.com/roninjin10/75ead3a978a0cf16b917e66fa7f74bac)
8. [A History of IDEs at Google, Hacker News thread](https://news.ycombinator.com/item?id=48126002)
9. [Inside iOS at Google Scale, Jeff Adler](https://jads.app/blog/building-ios-at-google-scale)
10. [Japanese summary gist of Potvin and Levenberg 2016](https://gist.github.com/stakiran/63c4cb929db73c4dbc4e92e3a38ce090)
11. [Googleのソースコード管理システム ― Piper/CitC, CTC教育サービス (2017)](https://www.school.ctc-g.co.jp/columns/nakai2/nakai220.html)
12. [Software Engineering at Google summary, Summaries For Your Information](https://summaries.fyi/t/software-engineering-at-google-by-titus-winters-tom-manshreck-hyrum-wright/18)
13. [Glossary, Google Open Source documentation](https://opensource.google/documentation/reference/glossary?authuser=371)
14. [Vendor Source, Google Open Source documentation](https://opensource.google/documentation/reference/thirdparty/vendorsrc)
15. [Jujutsu (jj) README, GitHub](https://github.com/jj-vcs/jj)
16. [Jujutsu: a new, Git-compatible version control system, LWN.net (2024)](https://lwn.net/Articles/958902/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Version control and collaboration platforms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/piper-source-control-system

English original: https://www.edgepedia.org/piper-source-control-system
