微软杰出工程师 Stephen Toub:为何以及如何将整个代码库迁移到 Rust
原题Microsoft Distinguished Eng: Why And How To Port Your Entire Codebase to Rust | Stephen Toub
推荐理由微软的 Stephen Toub 从 Copilot 运行时为何需要更容易嵌入讲起,复盘了团队如何选择 Rust、让新旧实现并行,并分段替换。迁移以功能对等为目标,独立的端到端测试由团队维护。智能体可以参与实现,原有系统的实际行为仍由这套单独维护的测试基准来检查。对准备迁移遗留系统的团队,这场访谈可以拿来做评审。第一段该从哪里切?怎么证明新旧行为一致?发布后发现差异,又能退到哪里?
看前速览
Stephen Toub 复盘 Copilot 运行时的渐进式 Rust 迁移,说明可嵌入性、独立端到端测试、智能体引导与分阶段发布如何共同决定收益与风险。
从业务约束出发,而非先选语言
运行时需要在多种环境中以更低开销被嵌入,团队通过原型比较性能与互操作特征。
渐进替换以临时互操作换取更小风险
持续发布使各组件变更分别接受现实检验,比一次性切换更容易定位回归。
验证必须独立于智能体的修改
端到端测试是核心保障,否则智能体可能修改测试或利用 CI 豁免,让通过状态失去意义。
严格功能对等能减少意外行为变化
本应保持行为的移植中,未经要求的清理、修 bug 与过度采纳评审意见,都曾造成回归。
迁移成本取决于变化中的范围与人的引导
代码库在项目中不断增长,人的工作主要是把握架构、边界与取舍,而非逐行阅读全部代码。
完整摘要
Stephen Toub 解释,Copilot 运行时迁移的出发点是可嵌入性、启动开销、内存占用与跨语言复用,而非偏爱 Rust。原型比较后,Rust 与原生 AOT 的 C# 成为主要候选,团队技能和生态条件最终促成 Rust 的选择。团队在持续日常发布的同时逐步替换组件,接受临时互操作代码,以缩小每次回归的影响范围。他强调独立端到端测试、禁止智能体修改验证基准、严格保持功能一致,以及由人审查架构决定的重要性。他报告使用约 1360 亿 token,按公开模型价格估算约 12 万美元,个人投入约三周时间,分散在整个项目期间。访谈还讨论范围增长估计不足、并发风险、切换模型,以及重写必须由业务价值证明合理。
文字稿
简要描述Brief Description
微软杰出工程师:为什么以及如何将整个代码库移植到 Rust | Stephen ToubMicrosoft Distinguished Eng: Why And How To Port Your Entire Codebase to Rust | Stephen Toub
目录Table of Contents
- 简介Intro
- 为什么 Copilot 运行时需要用 Rust 重写Why the Copilot runtime needed a Rust port
- 他为什么选择 RustWhy he chose Rust
- 讨论发布策略Discussing rollout strategies
- 他如何发现回归问题How he caught regressions
- 指导智能体Guiding the agents
- 在上线前捕获回归问题Catching regressions before prod
- 他使用了哪些模型Which models he used
- 最终收益和成本The end benefit and costs
- 何时进行全面重写When to do a full rewrite
- 迈向杰出工程师之路的职业心得Career learnings on the way to Distinguished
- 首选技术书籍推荐Top technical book recommendation
- 给年轻工程师的建议Advice for young engineers
- 结尾Outro
简介Intro
总计大约是 1360 亿个 token,费用约为 12 万美元。这位是微软杰出工程师 Steven Tob,他独自一人用 Rust 重写了一个拥有 40 万行代码的代码库。我向他详细询问了他从这一过程中学到了什么。过去负担不起的这些项目,如今已经完全可以实现了。All told, it was about 136 billion tokens. It came out to approximately $120,000. This is Steven Tob, distinguished engineer at Microsoft, who single-handedly rewrote a 400,000line codebase in Rust. And I asked him all about what he learned from the process. These projects that were once unaffordable are now quite doable.
你是如何在过程中发现并修复回归问题的?How did you discover and and fix regressions along the way?
我逐行阅读并不能避免 bug。事实上,让智能体逐行阅读要有效得多。如果让我重来一次,有件事我会做得不一样——这是完整的一集。我想把这次对话的重点放在你为 GitHub Copilot runtime 做的移植上,基本上就是把它重写成 Rust,因为我觉得,随着近期这些模型的发展,这类新型项目现在已经可行了。所以我想,业内会有很多人尝试做类似的事,也许是把他们的遗留代码库迁移到某种性能更高的语言上。Me reading every line would not prevent bugs. In fact, agents reading every line is a lot more effective. Something I would do differently if I had to do it again was here's the full episode. I wanted to focus this conversation around the port that you did for the GitHub copilot runtime and basically rewriting it into Rust because I think this is a new type of project that is now feasible with the the recent models. So I imagine a lot of people in industry are going to uh attempt something similar maybe with their legacy code bases into some more performance language.
为什么 Copilot 运行时需要移植到 RustWhy the Copilot runtime needed a Rust port
那么我想先问问你,这个项目是什么?你为什么要用 Rust 把所有东西都重写一遍?你当时要解决什么问题? 是啊,这是个很好的问题。尤其是我觉得,有时候人们会以为现在把东西重写成 Rust 是一种潮流。所以他们会觉得——或者我也被问过类似的问题——“哦,你这么做只是因为你能这么做,所以就这么做了。”但这完全不是当时的情况。So I want to start off with asking you what was the project and why did you rewrite everything in Rust? What was the problem that you were solving? Yeah, that's a great question. Especially because people sometimes I think assume that rewriting things into Rust is kind of all the rage these days. And so people assume uh or I've had questions that assume like oh you're doing this just because or like you can and so you will and uh that is not at all what this was.
你知道,当前这个项目本来可以采用某些形态,那样的话,重写它根本就不会成为一个话题。但推动我们这么做的主要原因,是众所周知,AI 一直在飞速发展。过去几年里,AI 所带来的能力突飞猛进。因此,在 GitHub 和微软内部,许多项目都从零开始蓬勃发展,将 AI 能力融入其中。There were you know there are certain shapes the current the project could have existed in where rewriting it wouldn't have been a conversation at all but the impetus is largely that AI has been this incredibly fastm moving target as we all know and over the last few years the the capabilities that it has enabled has skyrocket skyrocketed and so [clears throat] across GitHub across Microsoft there are all of these projects that have um kind of blossomed from the ground up to incorporate AI capabilities into them.
它们基本上都是从这样的想法开始的:哦,我们可以调用这些 LLM。哦,我们得在外面包一层……你知道,胶水代码。我们得在周围再加点东西,再加点东西,逐步搭建出现在所谓的 agentic harness(智能体框架)、agentic loop(智能体循环)或 agentic runtime(智能体运行时)之类的东西,随你怎么称呼。嗯,最后我们搞出了很多种,因为每个人基本上都有自己从头搭建的实现。这不是个好局面,尤其是当你希望它们都能做到一流水平、走在最前沿的时候。在 AI 这个领域,新模型每周都会推出,甚至可能每天都有。And all of them basically started from oh we can make these LLM calls. Oh, we have to wrap a little bit of you know goo around it. We have to add more around it and more around it and building up effectively what is now called agentic harnesses or aentic loops or aentic runtimes whatever you want to call them. Um, and we ended up with a lot of them because everyone kind of had their own homegrown implementation. And that's not a good place to be, especially when you're trying to have all of them kind of be best of breed and be on the forefront. And in this world of AI, like there are new models coming out weekly, if not daily.
就像,你知道,大概几周前,OpenAI 和 Anthropic 接连发布了一堆东西,彼此较劲、互相超越。嗯,一个月前还只是研究成果的新技术,如今每个 harness 都必须具备,否则马上就会过时。Like, you know, a couple weeks ago, there were all these releases from both OpenAI and Enthropic, you know, oneuping each other. And um there are new techniques that a month ago were research and today every harness has to have or they're immediately out of date.
而且你也不希望有一大堆不同的实现都需要持续更新。所以你真正想要的是少数几个——理想情况下是一个——可扩展的框架或运行时,让所有人都能使用,并根据自己的需求进行定制和扩展。不过,当时用于 Copilot CLI、GitHub 应用,以及 Copilot 云端代理的 Copilot 运行时——比如你在 GitHub 上让 Copilot 帮你做事或进行代码审查时用到的那个——是用 TypeScript 编写的,基于 Node 和 V8,这就会影响它作为可嵌入式库的适用范围。And you don't want this myriad of different implementations all needing to stay up to date. And so you really want a small number, ideally one, but a small number of extensible harnesses or runtimes that everyone can use and customize and extend to their needs. But the the Copilot runtime that was being used for the Copilot CLI and the GitHub app uh and uh Copilot cloud agent like when you're on GitHub and you ask Copilot to do stuff or code review like um that was written in Typescript um using Node using V8 uh and that has implications for where you can use that as an embeddible library.
所以,那个运行时无法在我希望它能适用的所有地方使用,一个主要的障碍,说到底在于它是用什么框架实现的、依赖什么运行时,诸如此类。解决办法基本上不是转向 Rust,而是从 TypeScript 和 Node 转向一种更容易嵌入、效率更高、工作集更小、吞吐量更快的方案,也更容易集成到各种各样的环境中,不论这些环境是用什么语言实现的,也不论它们使用什么框架。So as a like one of the main blockers for that runtime being able to be used everywhere I wanted to be usable was fundamentally what it was implemented in the frameworks it was using the runtimes it was using and so on and that that basically not moving to Rust but rather moving away from Typescript and Node to something that was more embeddible had better efficiency, lower working set, faster throughput, um better able to be consumed into any myriad of environments regardless of what language they're implemented in, regardless of what frameworks they're using.
嗯,这基本上就是促成这件事的催化剂。正如你刚才提到的,人们想要进行这类移植或迁移,原因有很多。这在整个行业都非常常见。无论是从一个已弃用的框架迁移到较新的版本,还是从一种语言迁移到另一种语言,抑或是把一个已经变得难以驾驭、乱成一团的遗留代码库,改造成更整洁、现代、焕然一新的代码库,这类迁移和移植随处可见。很多时候,人们只是因为成本太高而不愿着手去做。它们耗时太久;一两年前,我们也会面临这种情况。但有了现代模型和现代运行框架,这些曾经负担不起的项目,如今完全可以在很短的时间内完成。Um that was basically the the catalyst for for this. And to your point earlier, there are any number of reasons folks might be looking to do these kinds of ports or migrations. They are incredibly common across the industry. Whether moving from one deprecated framework to a newer version or from one language to another or from a legacy codebase that has become an unwieldy, you know, mess of spaghetti to something cleaner and modern and fresh. These migrations and ports are everywhere and a lot of times people just don't take them on because they are too expensive. They take too long and we would have been in that situation a year or two ago as well. But with modern models and modern harnesses, these projects that were once unaffordable are now quite doable in a in a very small period of time.
他为什么选择 RustWhy he chose Rust
在你写的那篇帖子里,我看到有一行写着:“我并不是一开始就打算转向 Rust。我一开始是想离开 Node.js 和 V8。”嗯,这让我想知道,如果你不一定非得转向 Rust,你有没有考虑过其他替代方案?为什么最后偏偏选择了 Rust?In the post that you wrote, I saw that there was a line. It said, "I didn't set out to move to Rust. I set out to move away from Node.js and V8 and uh that makes me wonder if you didn't need to go to Rust did you consider other alternatives and why did you end up going to Rust specifically?
所以,我做的第一件事基本上就是借助智能体创建原型,因为现在可以非常快地创建原型——仍然用 TypeScript,不过可以换用不同的运行时,比如 Node、Bun 之类的。我想我还用了 Python、Go、C、Java 和 Rust。然后,我为其中一个系统搭建了一条很小的端到端纵向链路,后端由一个本地的聊天补全模拟服务器提供支持。每个原型大概有 5,000 到 10,000 行代码。接着,我从端到端性能和工作集吞吐量等方面对它们进行了评估,也测试了在施加大量负载时能达到多大规模。So my the very first thing I did was basically create a prototype agentically because you can now create prototypes super fast in um still with TypeScript but with different runtimes. So, you know, node versus bun versus whatever. Uh, as well as I think I did Python, Go, C, Java, and Rust. Um, and created a very small end-to-end sort of steel thread through uh, one of these systems kind of backed by a local um, chat completion, you know, dummy server. um probably 5 to 10,000 lines for each of them. Uh and looked at them in terms of endto-end performance uh in terms of uh working set throughput uh what kind of scale that we could get if we threw a lot of load at it.
嗯,然后还有,它是否真的能满足需求,以及要让它实现这一点需要付出什么。我们目前有六种语言的 SDK,它们都是构建在 Copilot 运行时之上的轻量绑定。要让所有这些 SDK 都能使用它,会是什么样子?尤其是现在,我们不想把 Node 强行引入使用方应用的进程中——或者说,以前我们不想这么做——所以 SDK 基本上会另外启动一个进程,来承载会话的实际执行。但我们也很希望能把进程内运行作为一种选项,就像世界上几乎所有其他库一样。Uh and then also what kind of whether it could actually meet requirements and what it would take for someone for us with we have um currently have six language SDKs that are thin bindings on cross on top of the copilot runtime um what it would look like for uh this to be usable from all of those and in particular right now because we don't want to force or previously because we didn't want to force node uh into the consuming applications process the the SDK basically spawned another process to host the the actual execution of the sessions, but we'd really like as an option for it to be in proc as well, like pretty much every other library in the world.
嗯,所以基本上就是根据这些性能目标和限制来评估所有这些语言和运行时,看看数据,了解哪些方案有效,以及效果如何。Um, and so basically evaluating all of these languages and run times uh against these performance goals and constraints and just looking at the data to see what worked and then how well it worked.
总体来说,从性能和可嵌入性目标来看,TypeScript 和 Python 很快就被排除在外了。嗯,Go 的性能相当不错,[嗤笑] 而且代码库也很干净。不过它并不是为可嵌入性而设计的。互操作并不是它的强项,对吧?也不是说做不到,只是有点逆着它的设计来。嗯,Java 在这方面也不太理想。JavaScript 还可以。最后的两个主要候选方案是 C,尤其是使用 Native AOT 的 C#,这样就能提前编译成汇编代码;另一个是 Rust。从性能角度来看,两者在几乎所有指标上都不相上下。有些方面 Rust 稍好一些。And for the most part, TypeScript and Python were very quickly out uh from uh kind of all of the performance perspective and the the embedability goals. Um, Go had pretty good PF. Um, [snorts] and you know, had a pretty clean code base. Um, but it's not really designed for embedability. It's not really like interop is not its raet, right? It's it's uh you can do it, but you're kind of cutting against the grain. Um, and then and Java is also not not great for that. Um, JavaSc was okay. Uh, the two main contenders ended up being C, in particular C# with native AOT, um, so that it could be compiled ahead of time down to assembly and, uh, and Rust. And from a PF perspective, uh, they were both very much on par with each other, uh, across pretty much all the metrics. In some places, Rust was a little better.
在某些方面,C# 稍微好一些。嗯,回到你之前的问题,如果这个项目原本是用 C 写的,我们就不会讨论这个话题了。我们会继续用 C,也就没有理由重写它。但事实并非如此。于是,最终还是要看这些标准。从性能角度来看,两者表现都不错。嗯,从可嵌入性角度来看,两者也都不错。嗯,C# 的互操作能力也很强。最后,主要还是取决于一些较为软性的因素。比如,GitHub 上还有其他用 Rust 构建的项目,而用 C 实现的项目则很少。GitHub 上懂 Rust 的人更多,懂 C 的人更少。In some places C# was a little better. Um, and so to your your you know question earlier, if the project was already in C, we wouldn't be having this conversation. We would have stayed with it. There would have been no reason to rewrite it. But it wasn't. And so that it came down to these criteria. So from a perf perspective, they were both they both look good. Um, from an embeddability perspective, they both look good. Um, C# has very strong interop characteristics as well. And then it came down to primarily softer factors. So uh there are other projects around GitHub in particular that are built in Rust and very few that are implemented in C. There are more people around GitHub that know Rust and fewer that know C.
显然,微软内部并非如此,而 GitHub 内部是这样。嗯,综合考虑这类标准后,我们最终选择了 Rust。That's not the case within Microsoft obviously but uh within GitHub. Um and so factoring in those kinds of criteria we ended up going with Rust.
我知道 Anders 最近做了……我想这个项目启动得比你们的项目早一点,不过他和团队一起把 TypeScript 编译器从用 TypeScript 编写移植成了用 Go 编写。我很好奇你有没有和他交流过心得。I know Anders recently did I think the project started a bit before your project started, but he did a port with the team of the TypeScript compiler from type being written in Typescript to uh being written in Go. I was curious if you compared notes with him.
确实。是的。这是一个很好的例子,说明不同项目可能会得出不同的结论,而且都可能是对的。没有要求必须把 TypeScript 编译器嵌入到其他应用程序中。嗯,反过来说,类型检查和编译 TypeScript 这类工作的形态,与向 LLM 发送请求、调整提示词、处理沙箱以及诸如此类的工作的形态非常不同。嗯,这些项目的性质本质上是不同的。Definitely. Yeah. And this is a great example where that different projects can have can reach different conclusions and and be right. there's no requirement to embed the TypeScript compiler into other applications. Um, and conversely, the shape of the um the shape of the work that is type compiling TypeScript looks very different from the shape of the work that is um sending requests to an LLM and manipulating prompts and dealing with sandboxes and and all that kind of stuff. um the nature of the projects was fundamentally different.
不过有意思的是,过去几周里出现了好几个由智能体驱动的移植项目。你可以去 X,或者说现在叫什么来着,搜一搜,就能找到有人在把 TypeScript Go 编译器移植到 Rust,而且速度非常快,这得益于现代模型,也和代码库的规模及其整洁程度有关。Um although interestingly in the last few weeks there have been several uh uh agentic ports of uh which you can you know if you search X or Twitter or whatever it's called now um uh you know you can find people that are porting the TypeScript Go compiler into Rust um and doing so very fast with modern models uh given the size of the codebase and the cleanliness of the codebase and
讨论发布策略Discussing rollout strategies
呃,所以看到这个还挺有意思的,有意思。Uh so it's interesting interesting to see.
所以,在你们确定这个项目有其动机,而且要解决的问题也很明确之后,我想问问迁移策略方面的事,因为我在不同项目中见过不同的策略。比如,你之前提到了 Bun。看起来他们基本上是搭建了一条巨大的新分支,整个分支都完全用 Rust 编写,然后在稳定版 Rust 发布时一次性全部推出。而我读到你们所做的工作时,感觉你们的做法要渐进得多,是一点一点推进的。嗯,你们是如何权衡这些不同策略的?什么时候会选择一种,而不是另一种?So once you decided that there was motivation for the project and it was clear problem to solve. I wanted to ask you a little bit about the migration strategy because I've seen different strategies in different projects. So for instance you mentioned bun earlier. Bun it looked like they kind of built up a giant basically a new branch that's just completely entirely in rust. and then they shipped all in all at once uh stable rust release and they did it all in one one go whereas when I was reading what you had done it looked like a lot more incremental and little by little. Uh how did you think through the the different strategies and uh when might you select one versus the other?
Bun 有意思的一点是,首先我很喜欢写那篇 Bun 博文的 Jared。我很喜欢他写的那篇文章。那篇文章让人特别兴奋,因为我之前不知道他们在做这个移植。那篇文章是在我们的迁移进行到一半左右时发布的,看到另一个项目的代码量大致在同一个数量级,却用另一种语言实现,真的很酷。他们用的是 Zig,而不是 TypeScript,不过他们也认为这样做是合理的,而且已经完成了移植。在那篇文章里,他们提到,我记得他们花了 11 天左右,就让大概 98% 的测试通过了之类的,这真的很酷。正如你所说,他们基本上是采用了一种大规模重写、推倒重来的方式。The interesting thing about bun first I loved uh Jared who wrote the the bun post. I loved the post that he wrote. It was really exciting because that post I wasn't aware that they were doing that port and then that post came out about halfway through our migration and it was really cool to see that this other project of approximately you know order of magnitude same amount of code in implemented in a different language. they were in Zigg rather than TypeScript, but um that they had, you know, thought that this was a sensible thing to do and had landed it. And in the post, they talk about it taking, I think, 11 days for them to get to like 98% of their test passing or something like that, which is really cool. And to your point, like they did it sort of in a an onmass like rewrite the world and and go.
这挺有意思的。我并没有参与这个项目,所以不清楚幕后发生的所有细节,但有一点让我觉得挺有意思:如果你看看他们的 npm 页面,会发现他们几乎每天都在发布构建版本——我想,大多是 Canary 构建——一直持续到 4 月中旬左右。很长一段时间里都是每日构建,然后到了 4 月中旬就停了。之后他们提到进行了为期 11 天的移植工作,这确实很了不起:11 天里,从零开始把一个 50 万行的代码库移植到 Rust,而且测试通过率达到 98% 或 99%。但接下来两个半月里,他们就没有再发布任何形式的 npm 版本了,至少据我所见是这样。It is interesting. I I am not involved in the project so I don't know all the details of what's going on behind the scenes but it is interesting to me that um if you look at their npm page they were shipping near daily builds uh I think you know a lot of canary builds basically through midappril like for a long time daily builds and then midappril it stops uh and then they talk about doing the you know the 11 days of porting which is an impressive of feet to get from nothing to this, you know, a 500,000line codebase ported to Rust in 11 days and have a passing 98 or 99% of the tests. But then they didn't have another npm release of any kind, at least as far as I could see, for another two and a half months.
嗯,当时有这么一段时间,没错,核心移植花了不短的一段时间,但之后似乎还进行了一些稳定化之类的工作,所以两次发布之间隔了三个月。有意思的是,这大约也正好是我移植 Copilot 花的时间——我花了 14 周半。所以,造成差异的原因有很多,但从根本上说,感觉花的时间差不多,只是我们选择了不同的做法。在那篇帖子里,Jared 提到,他不想采用 Copilot 那种渐进式的做法,因为那会带来很多临时的中断和杂项。Um so there was this window where yes the the core port took a small period of time but it seems then like there was some aspect of stabilization and things like that happening such that there was this 3mon gap between releases um which interestingly is also approximately the same amount of time that it took co-pilot you know the 14 and a half weeks that I spent uh porting co-pilot so you know there's lots of reasons why they differ but fundamentally mentally it seemed to be about the same amount of time and we just chose sort of different ways of going about it. In the post, uh Jared makes a point about um not wanting to do the incremental approach that Copilot did because it would incur lots of temporary interrupt junk.
他说得对,确实如此。嗯,我们选择那种做法时,完全清楚自己会面对什么,因为我们当时受到种种限制。And he's right, it did. um we just chose that approach knowing full well what we were getting ourselves into because of the sort of the constraints that we were under.
所以,呃,你知道,对于 JavaScript 运行时来说,修 bug、增加新功能,这些显然都很有价值。不过,你可以停上 3 个月,世界也不会因此天翻地覆,对吧?3 个月前的 JavaScript 和今天的 JavaScript 并没有太大区别。你也可以采取一种推倒重来、重写一切的做法:把所有事情都暂停,等做完了再继续发布。但到了 2026 年夏天的 Agentic Harnesses 领域,如果你停上 3 个月,等你发布时,面对的世界将和你开始时大不相同。因此,试图暂停很长一段时间——你知道,即使只是几天——也不是我们愿意考虑的做法。So uh you know for a JavaScript runtime um obviously fixing bugs and new features like that's all valuable. Um but you can pause for 3 months and the world isn't going to fall over, right? JavaScript 3 months ago isn't all that different from JavaScript today. And you can do sort of a a rewrite the world approach. Uh pause everything and then continue shipping when you're done. Uh Agentic Harnesses in the summer of 2026, if you pause for 3 months, the world you ship into will be very different from the world that you started in. And so trying to pause for for a long peri you know a period of time even if it's a few days was not something that we were willing to entertain.
嗯,你知道,即使我们能在两周内完成,那也意味着要么让整个团队停滞两周,要么就得应对庞大的代码库中源源不断涌入的变更,并且还得梳理这些变更,再把它们作为移植内容合并进去。Um and you know even if we've been able to do it in two weeks that would have been two weeks worth of either blocking the whole team or uh dealing with a constant influx of of changes across a very large codebase and having to rationalize and you know um all of those changes in and merge all those changes in as ports.
嗯,我们选择了另一种做法。我觉得这种做法对 Copilot 来说是合理的,对 Bun 来说就没那么合理了:我们在主分支的正式代码库中,把代码一点一点地从 TypeScript 迁移到 Rust,同时每天发布版本。刚开始时,代码 100% 是 TypeScript,0% 是 Rust;到最后则变成了 100% 是 Rust,0% 是 TypeScript。整个过程就是随着时间推移,逐步完成迁移,而且大体上进展得相当顺利。不过,正如 Bun 那篇文章提到的,这确实意味着会有大量临时代码不断加入又被移除,对吧?Um instead we opted for the approach which I think made sense for co-pilot and made less sense for bun uh where we just incrementally moved the codebase more and more from TypeScript to Rust in pieces in Maine in the shipping codebase shipping releases daily. And it's just that at the beginning it was 100% TypeScript and 0% Rust and at the end it was 100% Rust and 0% TypeScript and it was just you know more and more over time and for the most part it worked out quite well. It did mean that there was to the point of the post of the the bun post there was a lot of temporary code that came in and left, right?
我想当时我们嗯,我们在 TypeScript 和 Rust 之间互操作时用的是 napi-rs。数量最多的时候,我们有好几千个互操作签名——我想大概有两千到三千个,用于两者之间的调用。后来到最后,这个数量降到了零,因为已经不再需要互操作了。I think at we um we were using uh nappy nappy rs for interop between typescript and rust and at the peak point we had several thousand interrupt signatures for I think two two or three thousand for calling between them and then by the end it had dropped to zero because there was no more interrupt required.
所以,对于这个项目来说,这么做很有意义。还有其他方案。你可以彻底重写。也可以让所有人停下手头的工作,直接在主分支上重写。你还可以建一个功能分支,让主分支继续推进,同时不断把改动合并进来。至于渐进式方案,你可以像我们那样做;不过,不必像我选择的那样,把 TypeScript 原子式地替换成 Rust,也可以采用一种 A/B 方案,让 TypeScript 和 Rust 组件并存,发布时同时带上两者,再通过功能开关在它们之间切换,并对这两个组件并行进行分批发布和实验。So for for this project it made a lot of sense. There are other approaches. You could do a a rewrite the world. You could do, you know, um have everyone stop what they're doing and just rewrite in Maine. You could have a feature branch and allow Maine to keep going and then constantly be taking ports in. And for the incremental approach, you can do what we did, but rather than do the approach of uh what I chose, which was sort of atomically swap uh TypeScript with Rust, you could have sort of an AB thing going where you you have both the TypeScript and the Rust component and you ship with both and you have a feature flag that allows you to ship between them and do sort of uh flights uh and experiments of those components side by side.
选择哪种方案有各种各样的原因,我觉得我们最终选的方案对我们来说效果不错,不过,嗯,其他所有选项也都可行,或者可能更适合其他项目。There are, you know, various reasons you might choose which and I think what we chose ended up working out well for us, but um all the other options would be valid or probably better for other projects.
所以听起来,在采用 A/B 方案时,你们也会保留一个临时测试框架,用来比较两边的表现。总之,如果你们有一个单独的分支,而旧项目(或者说主分支)上又不断有新提交进来,就需要持续把这些提交移植过去。我想,用现代模型来做应该也相对容易,因为移植每个单独的提交对模型来说大概都很简单。你们考虑过这种做法吗?或者说,和承担互操作成本相比,哪种方案的成本更划算?So it sounds like that that AB approach, you would also still have some uh temporary testing harness that would be comparing the two legs. Anyways, well in the case where you have a a separate branch and then new commits that come in on the old project or I guess main need to be continuously ported. Um I I imagine that would be relatively doable with modern models as well cuz each of those single commit ports is just uh probably trivial for a model. Did you consider doing that one or how did the math compare between doing that versus incurring the interop costs?
这里有几个问题。这不只是保留一个单独的功能分支,然后把所有东西都合并过来。如果我们维护一个单独的功能分支,最后再进行这样的切换,一次性部署整个新技术栈,那我们就只能把所有东西一起放到真实环境中测试,这样做风险相当大。嗯,而我们选择这种做法的一大好处是,实际上我们能够利用生产环境完成最后阶段的测试,并且让每次部署都只是在上一次部署的基础上做少量改动。我想,在整个迁移过程中,我们大概发布了 130 个版本左右,每个版本都只是在原有基础上逐步增加了一点内容。So there there's a couple questions there. It it's not just about the having a separate feature branch and bringing everything over. If we had a separate feature branch that we were maintaining and at the end we did this swap where we deploy like the whole new stack, we would only be testing in the wild everything all at once and that's a pretty risky gambit. Um whereas if you uh one of the big benefits of the approach that we chose was we were effectively able to use production for the last mile of testing and have each deployment be a small diff on top of what the previous one was. So over the course of the port I think we shipped about 130 releases something like that each one of which contains just incrementally more.
因此,如果出现问题,即使完全不使用电脑,也能很直接、迅速地找到问题的根本原因。And so if there were issues, it was very pretty straightforward and fast to root cause those issues even without using computer at all.
比如有人报告了一个问题,你就会说:“哦,对,我完全知道这是怎么回事,对吧?”然后你就能很快地缩小排查范围。而要是整个世界都重写一遍,就很难进行这种验证了。嗯,确实因此出现了一些回归问题。其中相当一部分是因为合并 main 分支的改动时出了问题,因为你知道,我当时还是有功能分支的。只是它们的时间跨度短得多,不再是几周,而是一天,比如用来移植一个组件。但就在这一天里,可能还是会有 10 到 20 个 PR 改动了这个组件。相当一部分回归问题,是因为代理在合并过程中漏掉了某些东西。嗯,也就是同时进行移植和合并时出了纰漏。Like someone reports an issue, you're like, "Oh yeah, I know exactly what that is, right?" And then you can very quickly narrow it down. Whereas the the whole rewrite the world, it's harder to do that kind of validation. Um, and there were absolutely regressions that came about from this. A good chunk of those were because of issues with merging in changes from main because, you know, I still had feature branches. They were just much more time boxed. Instead of being weeks, they were a day for, you know, porting a component, but within that day, there might still be 10 or 20 PRs that came in and touched that component. And a a non-trivial percentage of the regressions were places where the the agents just missed something as part of doing the the merge. Um and and the port and the merge at the same time.
嗯,采用原子式的方式把 TypeScript 替换成 Rust,而不是同时运行 A/B 两套方案,有个好处是,代理被要求在移植完成后立刻删除被替换掉的 TypeScript 代码。这样做在某种意义上反而让合并主分支时产生了冲突,因为只要主分支中的任何代码改动涉及已移植的 TypeScript,就会立刻引发冲突,从而亮起红旗,让代理注意到那段代码。反过来,如果我们不删除这些代码,主分支中对 TypeScript 的更多改动就很容易混进分支里那份尚未动过的 TypeScript 代码。Um, one of the the nice things about sort of the atomic uh replacing from Typescript to Rust versus having an AB thing going is um the agents were instructed to delete the TypeScript that they were replacing the moment that they ported it. And that in a good way created conflicts for those merges from Maine because it meant that if any code in Maine touched any of the TypeScript that had been ported, it instantly created a conflict which sort of raised red flags and pointed the agents attention at that code. Whereas if we weren't deleting it, it would have been very easy for more changes in main to that TypeScript to find their way into the existing untouched TypeScript in the branch.
这样一来,智能体就得仔细分析它移植过来的所有代码,找出需要修改的地方并把这些修改合并进去;而我们当时正在进行这项替换工作,所以它几乎能立刻定位到这些地方。And then the agent would have to reason about, you know, all of the code that it had ported looking for changes to that to bring that in versus it was sort of instantly uh pointed to those places because we were doing this swamp at the time.
他是如何发现回归问题的How he caught regressions
是的,我能想象很多人——很多团队或工程师——想要重写整个代码库时,最大的顾虑可能就是正确性。代码实在太多了,你根本不可能奢望有人把代码都读一遍来确认它是正确的。那么,你们一路上是怎么发现并修复回归问题的?最重要的是我们的端到端测试、集成测试,或者你想怎么称呼都行。Copilot 的测试基本上有两种。我们有单元测试,这些测试大多是在代码库中测试一些微小的功能,而且很多测试可以访问内部实现,因此能够测试某个没有对外暴露的小函数,或者某段没有对外暴露的代码。Yeah, I can imagine a lot of people uh a lot of teams or engineers that want to rewrite their entire code base probably the biggest concern is the correctness concerns which is there's so much code that you don't have the luxury of a human even reading the code to confirm that it's correct. So um how did you discover and and fix regressions along the way? So the the most important thing was our um endto-end tests, our integration tests or whatever you want to call them. Um the we basically had two flavors of tests for copilot. We had unit tests which were largely sort of you know they're they're they're testing micro functionality throughout the codebase and a lot of them have internals access. So they're able to test this little function here that's not exposed or that piece of code there that's not exposed.
嗯,然后还有端到端测试,分别在运行时层、SDK 层,或者 CLI 层——它们都在同一个代码库中。因此,CLI 的端到端测试实际上也会测试运行时。虽然这并非百分之百准确,但大体上可以把 CLI 看作是以尽可能底层的方式,通过人机界面来呈现运行时的能力。嗯,所以我们有所有这些端到端测试来验证各种行为。总的来说,虽然不是百分之百,但我们遇到的绝大多数回归问题,都是因为没有端到端测试覆盖相应的功能。Um and then there are the endto-end tests either at the the runtime level, the SDK level or uh the CLI is in the same codebase. And so its endto-end tests also effectively exercise the runtime. And this isn't 100% true, but the CLI can largely be thought of as sort of a just um exposing the runtimes capabilities as sort of the lowest layer possible in a in a human interface. Um and so we had all of those endto-end tests to uh validate behaviors. And by and large, it's not 100% but the vast majority of regressions that we had were because we didn't have endto-end tests covering that functionality.
嗯,我们通常有单元测试覆盖它,但这种情况下单元测试的问题在于,它们本身也是用 TypeScript 实现的,用来测试 TypeScript,而且可以访问内部实现。因此,在很多情况下,代码移植的同时,这些单元测试也不得不重写。Um, we generally had unit tests covering it, but the problem with unit tests in this situation is they were also implemented in Typescript testing TypeScript uh with internals access. And so those in many situations those unit tests had to be rewritten at the same time that the code was being ported.
现在,由于我们采用了这种实现方式,如果我替换掉下面这小部分,然后再处理 TypeScript,那么这部分现在就是 Rust,而它上面的 TypeScript 则通过互操作与它交互。这个部分有自己的单元测试,因此这些单元测试仍然可以间接验证受支持的 Rust 组件。我们从中获得了这些好处,但真正的保障是覆盖所有内容的集成测试或端到端测试。我还为团队写了一份文档,说明这次移植的动机,并详细列出了我们希望如何推进、预计时间安排、采用的方法、策略和技术等。Now because of how we did it, we got the benefit of um if I replace this little piece down here and then the typescript so this is now Rust and the TypeScript sitting above it was interacting with this through interop. This guy had its own unit tests and so indirectly those unit tests are still validating the supported Rust component. So we got benefits from that but the safeguard was the the integration test or the endto-end tests across everything and I had written a document for the team sort of motivating this port and laying out exactly how we would want to go through it and approximate time frames and approach and strategies and technology we would use and so on.
被指出的一件事是,我们需要加强端到端测试。我把这当成最先要做的事,也确实这么做了。我觉得自己做得不够好的一点,也是如果重来一次我会采取不同做法的地方,就是我会做得更多。One of the things that called out was we needed to beef up our endto-end tests as the very first thing we did and I did. I think one of my failings and something I would do differently if I had to do it again was I would have done it more.
嗯,因为再次强调,绝大多数情况下这其实不言而喻:如果你为某件事编写了测试,而这些测试没有出现回归,那么只要测试覆盖了所有你关心的行为,这些行为就是正常的。所以我们出现了回归,这多少凸显出测试存在漏洞。当然,这并非百分之百正确。我们遇到过一些情况,其中最有趣(或者说最令人难过)的情况是,我们忘了阻止智能体在修改被测试行为的同时重写端到端测试。你知道,智能体的目标就是让测试通过。所以如果你放任它们,它们就会篡改判定标准,也就是在修改代码的同时改动测试,好让代码通过。我们还有一个案例,呃,这个问题倒是没漏过去。Um because again the vast majority it kind of goes without saying but if you have tests for something and those tests don't regress then like the behavior is good as long as you have tests covering all the behaviors you care about. And so the fact that we had any regressions sort of highlights that there were gaps. Now that's not 100% true. We had cases, the funniest or saddest cases were where we um neglected to prevent the agents from rewriting the endto-end tests at the same time that they were changing the behavior that was being tested. You know, the agents want to get to green like that's their goal. And so if you let them, they will change the oracle like they will change the tests at the same time as that the code to make it pass. Or we had one case where uh this one didn't slip through.
我注意到了这个问题:智能体在做修改,结果改动了一些公共 API。CI 发现后就说:“不行,不行,不行,不能这么做。”不过 CI 里有个应急通道:如果有人确实知道自己在做什么,就可以给 PR 加个标签,基本上就是在说:“不,这个特定的破坏性改动是可以接受的。”而智能体发现了这个通道,就加上了标签,表示:“哦,这个破坏性改动没问题。”尽管你知道,它其实并没问题。嗯,还有些事情对你来说就是特别难。你可以做端到端测试,但它们往往深入到很多细节里。比如说,你把数据发送到线上,并确保在所有可能的情况下,你发出去的每个字节,最终在链路另一端收到的都符合预期。I noticed this one, but like the the agent was making changes and it ended up changing some public APIs and uh CI caught this and said, "No, no, no, you can't do that." But we have an escape hatch in CI where if someone really knows what they're doing, they can put a label on the the the PR to basically say, "No, this particular break is okay." And the agent found that and applied the label to say like, "Oh, this this break is okay, even though it, you know, it wasn't." Um, and then there are other things that are just really hard for you. You could have endto-end tests, but they're sort of in the weeds. Uh, things like, you know, you're you're sending data out on the wire and making sure that every bite that you send in all possible situations is what's expected at the end of the end of the wire.
这需要一套非常全面的测试。如果存在任何测试盲区,就可能有问题漏网。此外,TypeScript 和 Rust 的线程模型、并发模型也截然不同。尽管很多人喜欢说,只要 Rust 代码能编译通过,它就是正确的,而且能避免所有这类 bug,这话没错,但它并不能避免所有类型的 bug。仍有很多并发 bug 会漏过去。因此,许多问题都与生命周期和并发有关,这些都不是 Rust 编译器能捕获的。当你从一种基本上是串行的单线程执行模型,转向一种我们有意设计来实现更好可扩展性的模型时,我们希望任务能够并发运行。That requires an extensive suite. And if you have any gaps, there's the potential for things to slip through. And then there's also, you know, there's a TypeScript and Rust have very different threading models, um, and concurrency models. And, uh, as much as people like to say that, you know, if your Rust compiles, it's correct and it prevents all these kinds of bugs, that's true, but it doesn't prevent like uh, you know, all kinds of bugs. And there are plenty of concurrency bugs that slip through. Um, and so a bunch of the issues were lifetime issues, concurrency issues, things that the Rust compiler does not does not catch. Um, and when you're coming from a a largely serialized singlethreaded execution model and going to one where on purpose we wanted much better scalability, we wanted things to run concurrently.
嗯,里面会冒出很多问题。嗯,所以,回到你的问题,最重要的一点是确保你关心的所有行为都通过测试编码下来。然后让智能体在确保所有测试持续通过的同时移植代码。嗯,还要设置好防护措施,确保它们不会同时改动你用来验证的东西,而你又需要这项验证保持正确。Um, there are plenty of of issues that that creep in there. Um so anyhow to to your question the the number one thing is to make sure that um all of the behaviors that you care about are encoded in tests. Um and then let the agents port the code while maintaining you know keeping everything passing. um and making sure that there are guard rails in place to make sure that they don't change the thing that you're using for the validation at the same time that you need that validation to be correct.
我还是觉得回归问题似乎在所难免,因为测试覆盖率,呃,有点像是需要主动选择的,得靠人来指出哪些东西重要,但总有可能会忘掉一些东西。嗯,所以我有点想知道,这种类型的项目是不是注定总会出些问题。It still feels like a regression is inevitable because the test coverage is uh it's like um it's optin kind of where it relies on a human saying these are the things that are important but you could always forget something. Um, so I I kind of wonder if this type of project, it's just inevitable that there will be some breakage.
我想是这样。我的意思是,这很难想象。谁知道一年后会是什么样子呢?变化真的很快。但就目前而言,没错,百分之百会出现回归问题。如果没有,我会非常惊讶。嗯,呃,除非我们说的是那种特别特别小的代码库,但你说的是重写几十万行甚至几百万行代码。这就是大数定律。如果智能体有 99.99% 的时间都能做对——这可能比大多数人高一个或两个 9——嗯,那仍然意味着有 .01% 的时候,它们会以某种方式出错。而如果你处理的是百万行代码,那么这 .1% 就是一个很小、但确实存在的数字。你可以多派一些智能体来处理。I think so. I mean, it's it's hard to imagine. I mean, who knows what things will look like in a year. Things are moving really fast. But right now, yes, 100% there will be regressions. If there aren't, I would be astounded. um uh unless we're talking about like you know a tiny tiny little codebase but you're talking about rewriting hundreds of thousands or millions of lines of code. It's just law of numbers. If if the agents get it right 99.99% of the time, which is probably uh a nine or two higher than most humans, um that still leaves.01% of the time where they're going to get it wrong in some way, shape, or form. And if you're dealing with million lines, that.1% is a very real small but real number. You can throw more agents at it.
我们确实做了,你知道,我们就是在合并前进行大量的智能体审查,然后在合并后运行智能体,持续查找 bug、并发问题之类的。它们确实能发现一些问题,但从来都做不到——至少据我的经验,在这么庞大的代码量下,它们不可能百分之百完美。And we did you you know we just you know be before merge doing lots of agentic reviews and then after merge running agents to to continually look for bugs, look for concurrency issues, look for whatever and they find things but they never find it's never at least in my experience it's not 100% perfect for such a huge volume of of code.
我猜大部分内容都没有经过人工审核。你们是如何大规模进行代码审查的?还是说根本没做过代码审查?I imagine most of it wasn't human reviewed. How did you handle code review at scale or did you do any at all?
是的,所以我肯定做了一些,嗯,但我没有逐行阅读。那是不可能的,而且即使我真的这么做了,也是在浪费时间。嗯,我逐行阅读并不能避免 bug。事实上,让智能体逐行阅读,不仅快得多,在质量上也比我自己逐行读更有效。嗯,我确实看过我提交的每个 PR 的代码,但我更关注的是整体层面的问题,对吧?嗯,这个方向对不对?架构对不对?组件化做得对不对?嗯,采用的方法和算法是否合适?Yeah, so definitely did some um but I did not read every line. That would be impossible and if I did it would also be a waste. Um there's no like me reading every line would not prevent bugs. In fact, agents reading every line is a lot more effective uh not just faster but more effective in quality than me doing so. Um, I I absolutely looked at the code for every PR that I put up, but I was focusing more on big picture stuff, right? Uh, is the direction of this correct? Is the architecture of this correct? Are is the component you componentization of this correct? Uh, is the approach are the algorithms that are being used appropriate?
呃,有什么可疑的地方吗?你知道,我很多时候都是从三万英尺的高度扫一眼,看看两个代码库,想想有没有哪里不对劲,然后依靠智能体去关注逐行的细节。在很多情况下,我会很快滚动浏览一遍所有改动,看看有没有什么特别显眼的地方,可能会注意到零星的一些问题,但大多数时候,一个非常优秀的智能体审查员在逐行细节方面肯定比我强得多,我甚至会说,比大多数人都强。呃,不过在宏观层面,有很多时候我基本上会叫停智能体,说:“等等,这个方向不对。”呃,反过来也有这种情况:智能体会停下来,说:“我们做完了。”Uh is there anything fishy about like you know if I a lot of it is like squinting at a 30,000 foot level and looking at the two code bases and does anything look off right and then relying on the agents to focus on the line by line details and in many situations I would sort of do a quick scroll through all the changes to just see if anything popped out and I might notice a few things here and there but for the most part a really good agentic reviewer is going to be way better at sort of the line level details than certainly me and I would argue most humans. Um, but at the macro level, there are lots of times when I basically stopped the agents and said, "Whoa, there like this is this is not the direction to be going." Um, or the inverse where the agents would stop and be like, "We're done."
我就会说:“不,你不是。呃,这个,这个不是我们想要的。嗯,所以这涉及的是更大的整体视角,而不是那种微观层面。”And I'd be like, "No, you're not. uh the this this is this is not what we're we're going for. Um and so it was a bigger picture uh than sort of the the micro level.
引导智能体Guiding the agents
我在那篇博客文章里看到,你有一张很酷的柱状图,基本上把你发给各个智能体的每一条消息都分类了,还标明了你的意图。看着这张图,回想你是怎么引导这些智能体的,你的大部分时间都花在了哪里?哪些时候你介入并做出调整,影响最大?我做的事情里,还有两三类更高层次的类别。嗯,我觉得其中一两类反映了当下模型和运行框架在处理长周期任务方面的状况:我对它们的进展方式感到不满,不管具体是哪种情况,要么在它们停下来时以某种方式让它们继续,要么在它们沿着错误的方向越走越远时叫停。I saw in the blog post that you you have this cool bar chart where you basically categorized every single message from you to the agents and what your intent was. Looking over that and reflecting on how you guided the agents, where was most of your time spent and what were the most impactful times where you would step in and change something? There were two or three even higher level categories of things that I was doing. Um, there was one or two categories where I think this just speaks to the the state of sort of long horizon tasks with models and harnesses today where it was me being frustrated with their progress in one way, shape or form and either telling them to keep going in some fashion when they had stopped or telling them to stop when they were going off down, you know, bad paths.
不过,大多数情况更……嗯,属于那种需要权衡取舍的类别。我想确保,理性的人或智能体可以选择多种路径,而我们也能确保自己走的是正确的一条。嗯,很多时候,我会直接和主智能体聊一聊,评估我们目前的进展、需要做出的决策,并结合当时的情况,像橡皮鸭调试那样,把这些选择的利弊逐一梳理清楚。这其中有些也涉及你前面问到的那些问题,比如是采取渐进式方案,还是暂停一切、进行一次大爆炸式重写。But the the majority were more um were in a category that was more of um there were tradeoffs to be made and I wanted to make sure and reasonable people or reasonable agents could choose multiple paths and I wanted to make sure that we were going down the right one. Um, and a lot of that would be times where I would just have a conversation with the the main agent to basically evaluate where we were, the decisions that were needed to be made and look and kind of talking through rubber ducking through sort of the pros and cons of those choices given the current situation we were in. And some of that to the to your earlier questions about sort of the the incremental versus uh sort of pause the world or big bang rewrite approaches.
其中有些与其说是着眼于端到端,不如说是关注我想为我们正在推出的这一部分做些什么。Some of those were less about the end to end and more about where we like what I wanted to do for this one slice that we were putting up.
嗯,你知道,智能体会在某个地方停下来,说“这个组件我已经做完了”。我看了之后会说,从它与其他系统的关联来看,这里不是个适合收尾的地方。你知道,这些关联可能只是暂时的;也可能我们还需要再多做一点,越过这道架构边界,这样就能理顺不少东西,等我们合并时,代码库也能处于一个比较合理的状态。Um, so you know the the agents would pause at a particular place saying you know I'm done with with this component and I'd look at it and say this is not a good place to leave things in terms of the the the tendrils that this has into other systems you know temporarily or either maybe we need to do just a little bit more to kind of get beyond this architectural boundary and then that'll clean up a bunch of stuff so that when we merge this the codebase is in a reasonable place.
嗯,很多时候它会有点儿宣布这一部分已经成功了;如果你眯起眼来看,嗯,行吧。但如果它再多做一点点,或者有些情况下回退一下、少做一点点,代码库的状态就会更好;也有些时候,它实际做的比我希望的更多。比如,我通过指令设定的一条规则,它并不总是遵守:我希望这些移植尽可能严格。Um, a lot of times it it would sort of declare success for the slice and if you squint, yeah, okay, but if it were do just a little bit more or in some case revert and do a little bit less, it would have left the codebase in in a better place or situations where it actually tried to do more than I wanted it to do. Like one of the one of the rules that I put in place with instructions that wasn't always abided by was I wanted these ports to be as strict ports as possible.
不移除功能,不增加功能,不做任何重大改动或算法层面的调整,也不顺手修复过程中遇到的任意 bug。我会让它把这些问题记下来,方便我之后单独处理。但我希望这些改动尽可能严格地做到功能一对一移植。有时我会发现它违反了这些规则。嗯,我基本上会让它撤回这些改动,恢复到之前的状态,或者至少让它说明自己做了什么,以确保我认可将那项改动纳入其中。嗯,我们遇到的回归问题中,有相当一部分是因为它违反了这些规则,而我没有注意到,结果它把一些本不该做的修复也包含了进来。Not removing functionality, not adding functionality, not making any huge changes and algorithmic approaches, not trying to fix arbitrary bugs that it comes across along the way. I would have it note those for me so I could revisit those separately. But I wanted these to be very strictly as onetoone functionality ports as possible. And there were times when I would see it violating those rules. Um, and I would basically have it back off from that and go back to what it previously had or at least talk through what it did to make sure that I was comfortable with that particular change being included. um a non-trivial percentage of the regressions that we have had were from places where it violated those rules and I didn't notice and it included fixes uh for things that um shouldn't have actually been done.
事实上,只有一个。我……总体来说,我们现在已经看不到更多来自移植阶段的回归问题报告了。我们一直都会遇到回归问题。这就是每天把数百个 PR 合并到代码库中的必然结果。不过,你知道,这是意料之中的。我们通常会在发布前修复它们,而我们只是在主分支上发现这些问题,In fact, there was just one I for the most part we're not seeing any more uh regressions being reported from the porting phase. We see regressions all the time. That's the nature of merging hundreds of PRs a day into a repo. But um you know it's just to be expected. Um and we fix them generally before they ship and it's just where we see them in Maine,
对吗?right?
嗯,不过昨天还是前天,我们遇到了一个非常特殊的边界情况。我看了一下,心想这真奇怪。我不太……它说是我加了这个,但我不记得自己加过这个。呃,于是我回头看了看这是怎么回事。我之前在一项移植工作中创建了一个 PR,最初的 PR 里并没有这个。后来,一位同行或他所用的 agent 给了一些反馈,建议做点什么,而 agent 对此的回应基本上就是通过收紧某项设置来解决这个安全方面的反馈。不过,它收紧得比实际需要的程度更严,结果就是一些移植前一直正常工作的东西,移植后就不能用了。嗯,弄清楚这些情况是怎么发生的,确实很有意思。Um but we had one yesterday or the day before where there was this really corner case thing and I looked at I was like that's really weird. like I don't it's saying that I added this and I don't remember adding this uh and looked back what it was. So I had I had created a PR as one of the porting efforts and it wasn't in the initial PR uh and then some feedback from uh a peer or a peer's agent came in recommending doing something and the uh agentic response to that was to basically address this security feedback by locking something down. Um, but it locked it down a little bit tighter than it needed to be locked down and that resulted in some things that had been working before the port, you know, no longer working after the port. Um, and uh, those are really interesting things to go and figure out how how they happened.
这很有意思。所以,你的代理会自动应用并监听 PR,如果它认为合适,可能会在没有你参与的情况下采取行动。是这样吗?That's interesting. So, your agent will auto apply and auto listen on the PR and if it seems reasonable may take action without your input. Is that right?
所以,呃,我大部分时候用 GitHub Copilot 应用,它有一个代理合并功能,基本上可以让它自动处理各种事情,监控一个 PR。它可以在出现冲突时自动变基,或者在出现冲突时自动合并。呃,它可以自动让 CI 通过。所以如果测试失败了,它就会修复测试。它还可以自动处理收到的审查反馈,并且在一切都通过后自动合并。对于这四件事,你可以分别选择要启用哪些。大部分时候,我会勾选其中三项,除了最后一项。这样,呃,在一切都通过之后、我点击合并按钮之前,我就有时间回去检查它为了让这个 PR 通过都做了些什么。So, uh for the most part I use the um the GitHub copilot app and it's got this agent merge functionality where you can basically have it automatically do various things watching a PR. It can um automatically rebase if there are conflicts or merge if there are conflicts. Uh it can automatically drive CI to green. So if tests are failing, fix the tests. It can automatically address uh review feedback that comes in and it can automatically merge once everything is green. And you can for each of those four things you can choose which ones you want. For the most part, I leave all three of those checked except for the last one. So that um I can I have a time where after everything is green and before I click the merge button, I go back and I review to see everything that it did to drive this PR to green.
它修复了哪些测试?收到了什么反馈?又是如何处理这些反馈的?这样我就能大致了解它做了什么,而不用逐行检查。嗯,我记得确实读过这一段,但没有完全理解它把限制收得有多紧、拦截了多少东西。呃,因为如果我当时明白了,我就会说:“其实,那些情况没问题,让它们通过吧。”嗯,然后让它放宽一些。What tests did it fix? What feedback came in and how did it address it to make sure that I know again at a high level, I'm not reviewing every single line, what it did. Um, and this particular one I remember actually reading, but I didn't fully comprehend how how much it was locking things down and how much it was blocking. Uh, because if if I had, I would have said, "Actually, those cases are okay. Let those through." Um, uh, and and had it back off from that.
是啊,是啊。如果你把那些都勾选完成了,我……我想没人、没人会这么做,因为他们是你团队的人。不过,想象一下我在你团队里。我大概可以写一条恶意的 PR 评论吧,我猜。你知道,就像:“嘿,这听起来挺合理的,但我确实要求你把几乎所有东西都删掉,或者……”Yeah. Yeah. If you had all of those checked off, I I no one no one would do this because they're on your team. But yeah, imagine I was on your team. I could probably craft a PR comment that is malicious, I guess. You know, it's like, "Hey, it sounds reasonable, but I did request you to delete like everything or
是啊,我确实让你格式化 C 盘了。你没格式化 C 盘吗?"Yeah, I did ask you to format your C drive. Did you not format your C drive?"
对,对,没错。把所有选项都关掉。对。而且你知道,不同的项目,我勾选的选项肯定也会不一样。比如这是个开源项目,呃,我唯一会考虑保持勾选的就是 CI 那项。你知道,驱动……我绝不会……也许还有变基,但我绝不会允许它自动处理 PR 上收到的任意审查反馈,更不会让它自动合并。要是在一个私有的闭源项目里,我信任……你知道,我信任那些我认识、参与项目的人,风险就没那么高。不过即便如此,最后那个复选框,我还是得非常非常信任它才敢勾选。Yeah. Yeah. Exactly. Just take everything down. Yeah. And you know, certainly different projects I would I would have different boxes of those checked. Like if this was an open source project, uh the only one I would consider leaving checked would be the CI one, you know, driving I there's no way uh and maybe rebasing um but there's no way that I would allow it to automatically address arbitrary review feedback coming in on a PR and certainly not automatically merge um on a closed on a private closed source thing where I trust uh you know the trust the people that I know to be working on the project. Um it's it's less risky, but even then I still, you know, the that less check box you have to be very very trusting.
嗯,是的,我也喜欢这个应用的一点是,Agent Merge 内置了一些提示,用来说明那些不同功能是什么;不过,它也允许我针对这些不同能力添加自己的提示。Um yeah, the one of the things I like about the app as well is it does you there there are built-in prompts as part of agent merge for what those different things are, but the app does permit me to add my own prompting for those different capabilities.
因此,对于代理要完成的每一项工作,我还会提供额外的约束和指导,说明它应该如何执行。比如,其中一项要求始终使用 rebase,而不是 merge;对于代码审查反馈,我希望你在不加思考地接受之前先批判性地评估;而对于另一些建议,则可以直接采纳并处理。诸如此类。OpenAI、Anthropic 和 Cursor 都在使用这款产品,让工作更轻松。WorkOS 是一个 API 平台,可为你的应用添加 SSO、SCIM 和 RBAC 等企业级功能。这些功能是你需要向其他公司销售的,但并非你正在构建的产品的主要重点。And so I have additional constraints and guidance for the agent as part of doing each of those things about how it should do it. Like you know always rebase instead of merge for for one of them or for review feedback. Here are the kinds of things I want you to think critically about before you just blatantly accept it and these are the ones where it's okay just go ahead and address it. You know those sorts of things. OpenAI, Enthropic and Cursor all use this product to make their lives easier. Work OS is an API platform that adds enterprise features like SSO, skim, and arbback to your app. These are things that you need to sell to other companies, but aren't the main focus of what you're building.
此外,他们还增加了对 AI 代理的支持。例如,面向代理的 OAuth 会为每个代理分配独立身份,并使用短期有效的限定范围令牌,而不是长期有效的 API 密钥。And now they've added more support for AI agents. For instance, O for agents gives each agent its own identity with short-lived scope tokens instead of a longived API key.
所以,如果出了问题,你可以撤销一个会话,它下面的一切都会随之失效。他们还有一个叫 Airlock 的功能,它是一层授权机制。[嗤笑] 智能体执行的每一项操作都会根据你用日常英语编写的规则进行检查。这样既不会对所有操作一概盖章放行,也不会让智能体在无人监管的情况下运行。最后,他们还有 Pipes,可以将你的智能体连接到 300 多种第三方工具,而你完全不必管理令牌。So if something goes wrong, you can revoke one session and everything under it dies. Another feature they have is airlock, which is an authorization layer. [snorts] Every action agent takes is checked against rules that you can write in plain English. So it's not rubber stamping everything and it's not running unsupervised either. And lastly, they have pipes which connects your agents to over 300 third party tools without you ever needing to manage a token.
在上线前发现回归问题Catching regressions before prod
所以,如果你在构建 SaaS 或 AI 智能体并向企业销售,WorkOS 只需几行代码就能填补所有这些空白。去 workos.com 看看,了解更多并开始使用。也感谢他们赞助我的节目。我们刚才聊了[哼笑]一些回归问题,你提到其中很多似乎是在上线到生产环境之前就被发现了。我觉得很多人听到“回归问题”时可能会想:“哦,你们把应用搞垮了”,或者“事情总是在失控”,又或者“出了事故”。你能不能讲讲,端到端测试之后还有哪些额外的保护措施,能确保这些回归问题不会造成严重影响?我想,我所说的这些问题中,大概有三分之二是在合并到主分支后不久、发布任何预发布版本之前就被发现了。So if you're building SAS or AI agents and selling to enterprises, work OS fills all these gaps in a few lines of code. Check them out at work os.com to learn more and get started. And I appreciate them for sponsoring my show. We talked [snorts] a bit about regressions and you mentioned that a lot of them were caught uh before they went out to prod it sounds like. Um and I think a lot of people might hear regressions and they think oh you're you're taking down the app or you know things are exploding all the time or their incidents. Could you explain maybe the the further protections after end to end testing that made it so these aren't bad regressions? I would say probably twothirds of these things that I'm calling regressions were caught very soon after merging to main and before we shipped any pre-release.
嗯,虽然目前我们每天会发布大概三个预发布版本,所以这些问题很快就被发现了。嗯,之后有一些问题进入了预发布版本。你知道,我们通过 CLI 进行的环形部署基本上分为预发布版和稳定版:某一天的预发布版可能会触达 5% 到 10% 的客户群,而另外 90% 或 95% 的用户只会使用稳定版。因此,相当一部分这类问题——具体比例我不太确定,可能是 10% 到 20%——还是进入了预发布版。接着很快就会有人提交问题,或者有人说:“嘿,我发现行为有所不同。”Um even though we're shipping at this point we're shipping I think three pre-releases a day. So they were caught like very quickly. Um then there was there were some that made it into a pre-release and um you know our form of ring deployments with the CLI is basically pre-release and stable where pre-release on any given day is probably hitting 5 to 10% of the um the audience um of the customer base and then you know 90 or 95% is only unstable and so a a a reasonable number of these issues uh I don't know exactly what percentage 10 20% um found their way into a pre-release. And then pretty quickly we'd get an issue opened or someone saying, "Hey, like I'm seeing this difference in behavior.
这是有意为之的吗?”所以其中很多事情都不一样,不一定是坏事,但差异大到有人注意到了,然后问我们:“这是故意的吗?Was this by design or not?" And so a lot of these were things that were different, not necessarily bad, but different enough that someone noticed and then asked us like, "Was this on purpose?"
嗯,其中一些情况是我没能阻止代理在移植过程中顺手修复漏洞。因而,其中有些改动实际上是有益的,但我们当时并没有打算这么做;你知道,这些改动并非有意为之。嗯,后来有不少改动进入了稳定版。由于我们在 main 或预发布版本中都没注意到它们,所以它们往往会留在稳定版里,很长一段时间都无人察觉。嗯,这基本上就是过去一段时间里我们陆续看到的情况;你知道,现在已经不太常见了,但一个月前,我们在几周内看到的就是这种零星情况。Um, and some of those cases were ones where I failed to prevent the agent from fixing bugs as part of the port. And so it it some of them were actually desirable changes, but we hadn't intended to, you know, they they weren't purposeful in that regard. Um, and then there there were a a number that made it into stable releases. And the ones that made it into stable releases, because we hadn't noticed them in either main or pre-release, they often ended up staying in and being unnoticed in stable releases for quite a while. Um, and this is mostly the trickle that we have been seeing over the last, you know, well, you don't really see much anymore, but a month ago would have been the trickle that we were seeing, you know, over a few weeks.
有时候某些特别极端的边缘情况会表现得有点不一样,然后就有人提了个 issue,说:“嘿,这个东西的行为和我预期的不一样,这是故意的吗?”通常都不是故意的,我们一听说就会修复。还有一些问题是我们通过各种遥测系统发现的,比如监控异常、崩溃之类的。显然,这些也都不是故意的,我们会把它们修好。uh where some super corner case thing just behaved slightly differently and then we get an issue open like hey this this isn't working the way I expected you know is this on purpose or not and often times they weren't and we'd fix them as soon as we heard about them um there were also ones that we would see from various telemetry systems you know uh monitoring for exceptions crashes uh things like that and obviously those are unintentional and we fix those.
他使用了哪些模型Which models he used
在那篇帖子里,你分享了这张图,展示了整个项目期间你使用过哪些模型。嗯,我想这是一张挺不错的柱状图,显示了每周的 token 中有多少是由 Claude 或 GPT 消耗的,少数情况下还有 Gemini。项目刚开始时,几乎全都是 Claude;到了项目结束时,几乎全都变成了 GPT。那么,是什么让你在项目进行到一半时把首选模型换成了 GPT?In the post, you you shared this graphic of which models you used throughout the course of the project. So, you have this nice um I guess bar chart that's showing what portion of each week's I guess tokens are consumed by either Claude or or GPT and in rare cases Gemini. At the beginning of the project, it was almost entirely Claude and then by the end of the project, it was almost entirely GPT. So what made you shift your model of choice in the middle of the project to GPT?
嗯,大多数时候我一直在尝试不同的模型。你知道,那段时间两家实验室都在以非常快的速度发布新模型。所以我一直在试用,当我换到某个模型并发现它表现不错时,就会继续用,直到有什么地方让我不满意,然后再试试别的。嗯,所以这完全不代表我有某种长期偏好。更多是看当时哪个模型最适合我。嗯,刚开始的时候,我想我主要用的是 Opus 46 或 Opus 48,效果很棒。后来 GPT,呃,是哪个来着?5.5、5.6 之类的,它在这些特定工作负载上的表现更好了。于是我就换过去了。然后 Opus 5 发布了,我当时就想,哦,这不错。Um for the most part I was constantly trying different ones and uh cuz you know over that period like both labs were releasing new models at a very fast pace. And so I was experimenting and when when I would move to one and I found it to work well, I would stick with it until uh something bothered me and then I would try a different one and then you know so um it doesn't in any way reflect sort of a long-term preference. It was more of at that moment what was working best for me then. Um, and so at the beginning of it, I think I was on mostly Opus 46 or Opus 48, and it was working great. And then GPT uh, what was it? 5.5, 5.6, one of those, and that started working even better for the these particular workloads. So then I jumped to that. And then Opus 5 came out, and I was, oh, this is cool.
然后切换到那个,对吧?最近我用 61 Saul 的效果一直很好。我会用 Opus 55 来审查我用 61 Saul 完成的工作代码。所以我会在这两者之间分配任务。有时候,如果我对某件事特别恼火——在整个移植过程中,这两个模型(GPT 和 Claude)都曾在某些时候表现出一些很让人恼火的特性。比如在某个特定阶段,或者我连续用某个模型处理一段时间后,它可能就会卡住;无论我怎么做,它都会一直盯着某个点,不肯跳出来从整体上看问题。And jump to that one, right? And then um recently I've been having a lot of luck with uh 61 Saul. Um and I'll use uh I'll use Opus 55 for code review uh for the work that I've done with 61 Saul. Um and so I'll like I'll sort of split the balance there. Um sometimes if I get really frustrated with something like both over the course of the port both models both GPT and Claude would exhibit some very frustrating traits at certain points like um a particular point or if I was working on it for some period of time one of the models might get stuck and kind of like no matter what I did it kept kind of refocusing on a particular thing and not stepping out and looking at the forest for the trees.
嗯,在那种情况下,我会做各种尝试。有时我会先保留代码改动,然后开启一个干净的会话重新开始,试着借此清空上下文窗口,让它重置自身。Um, and there are various things I would do in those situations. Sometimes I would start like keep the code changes but start over with a clear session and try and use that to, you know, clear context window and try and use that to get it to reset itself.
但它经常又会陷入僵局。所以遇到这种情况时,我会切换模型,然后继续用新模型,直到它开始表现出一些令人沮丧的行为;接着我就会换成别的模型。我也试过用 Gemini 和 Grock 作为主要模型。不过,我通常会把它们用于多模型代码审查。But often it would find itself back into a rut. And so in those situations, I would switch models um and then keep going with the new model until it found itself exhibiting some frustrating behavior and then I would, you know, switch to something else. Um I did experiment using Gemini and Grock as my main drivers. Um but I would often leave those to be um as part of like a multimodel code review.
嗯,我做的很多审查工作,主要会用 GPT 或 Claude 来完成。然后我会用来自不同系列的三四种模型,逐行审查移植的内容。我会非常频繁地这么做,至少每次我 rebase、把最近合入主分支的变更带进来并添加额外功能时都会做,而且通常比这还要频繁。Um so a lot of the the reviewing that I had that I was doing I would be using either GPT or Claude as or for the main work. um and then use three or four different models from different families to do a line by line uh you know review of the the porting that was done and I would do that very frequently um at at least as frequently as every time that I was rebasing to bring in additional functionality from uh you know changes that had been coming into Maine but often uh even more frequently than that.
是的,我确实看到你有一个提示词,我想是在 rebase 时自动应用的,或者类似的操作;你要求对它进行审查,嗯,我想是以对抗性的方式审查,或者说让所有模型同时审查。你为什么会得出这个结论,而不是用同一个模型做代码审查,只是让每个线程关注不同的方面? 是的,基本上就是为了获得不同的、实际上是不同的视角。你知道,对一个非确定性系统做的每一个小改动,最后都会让它走上不同的路径,去关注不同的东西。而你能做的最大改动之一,就是彻底换掉模型。嗯,我发现,要获得不同的意见,并让它们关注不同的方面,最好的办法就是使用不同的模型,尤其是和我一开始使用的模型不同的模型。Yeah, I did see that you had a prompt that was I guess auto applied on rebase or something like that where you requested it to be reviewed um I guess adversarially or you know all all of them at the same time. What made you come to that conclusion rather than I guess code review with the same model but I don't know different focuses for each thread? Yeah, it's it's basically to get different effectively different perspectives. You know, every every little change that you make to a non-deterministic system ends up sending it down, you know, different paths and looking at different things. And one of the biggest changes you can make is completely changing the model. Um and so the best way to get different opinions and focusing on different things I that I found is by having um different models especially than the one that I used initially.
最终收益与成本The end benefit and costs
那么,嗯,你知道,重写完成之后,具体产生了什么影响,成本又是多少?从商业角度来看,这个项目带来了什么收益,又付出了什么成本?收益非常明显。我的意思是,GitHub 和 Microsoft 的所有这些产品、服务和团队,都可以依赖一个共享的测试框架;它始终处于业界领先水平,而且每天都在不断改进,这样他们就不必投入自己的资源去做同样的事情。他们可以专注于自身的业务价值,并复用这个组件。这和你希望依赖任何一个库的道理一样。而这个库尤其庞大,对吧?So um you know after you finished the rewrite what was the concrete impact and the cost? So if you look at it from a business perspective what was the benefit and the cost of this project? So the benefits are stark. I mean the benefits are the ability for all these products and services and teams across GitHub and Microsoft to be able to rely on a shared harness that is constantly sort of, you know, best of breed and getting better and better every day and not have to spend their own resources trying to do the same thing. they can focus on their business value and in and reuse this component. It's the same as with any library that you want to rely on. And this library is a particularly large library, right?
你希望能够专注于自己的业务价值,同时复用由一个全身心投入于此的人持续完善的成果。You want to be able to focus on your business value and reuse the constantly evolving work for someone that is spending all their time focusing on on that thing.
因此,从商业价值的角度来看,GitHub 和微软都能利用这个共享的运行框架,其价值简直难以估量。嗯,而在移植之前,要让人接受并证明这件事的合理性,会困难得多。其中一部分原因在于确实存在一些成本,比如性能成本。你知道,假设某项工作的工作集要大 10 倍——我这里只是粗略估算——那就意味着密度低 10 倍,也就意味着需要的服务器数量多 10 倍。诸如此类。嗯,如果你能提高同一台机器上可以同时运行的用户数量,就会影响你的利润底线。如果你能把吞吐量提高,并将延迟降低 5 到 6 倍,或者无论具体是多少,那都会带来实实在在的好处。And so from a business value perspective, it's it's like incalculable across GitHub and Microsoft being able to leverage this shared harness. Um whereas before the port, a lot of that would have been a harder sell and harder to justify. And um part of that is because of very real uh costs uh like uh performance costs. So you know something that was taking 10 times as much working set waving my hands means 10 times less density which means 10 times as many servers. You know those sorts of things. Um and uh if you can you know make the um if you can scale the number of users that are able to be on the same machine running concurrently that has impacts on your your bottom line. If you can scale the you know the throughput and reduce the latency by five or 6x or whatever it is that has real benefits.
嗯,从性能角度来看,这些系统带来的最大影响之一是,很多这类系统,尤其是服务,会收到一个请求,然后需要启动 agent 循环,再进行一轮处理;而这可能只是非常短暂的一步,之后请求就结束了。因此,对这类系统来说,启动成本最终会成为主要因素之一。Node 应用的启动与原生 Rust 或 C 应用的启动之间,差异很大。我们说的是数百毫秒的差距,有些情况下甚至是几秒。按单个请求来算,这种延迟非常容易测量,而且对最终效益的影响也极大——前提是你能够采用它,因为你可能根本无法采用。那样的话,你就又回到了我之前说的那种状态。Um one of the the biggest impacts from a Perf perspective um a a lot of these systems especially services will do um you know a request will come in and the the agent loop needs to be started to make one more turn which could be a very short thing and then the request is done. And um so for these things the startup cost ends up being one of the dominant factors and the startup of a node application versus the startup of a a a native Rust or C application is there's a big difference there. we're talking hundreds and hundreds of milliseconds uh difference or or in some cases seconds um on a per request basis that latency can be extremely measurable and extremely impactful for bottom line if you're even able to adopt it because you might not be able to and then you're back in the previous world that I was talking about.
所以从商业角度来看,完成这次移植非常值得。至于实际成本,我们保存了这项工作中全部(或约 99%)的会话日志。根据这些日志,我得以推算出新 token、缓存写入、缓存读取以及输出 token 的数量。总计大约有 1,360 亿个 token。按照当时这些模型的公开定价计算,费用约为 12 万美元。这还没有计入企业可能享有的任何折扣或其他价格优惠。So from a business perspective, it's worth a lot to to do this port. Um, in terms of what it actually cost us, um, it was about if I so I I stored all of my session logs or 99% of my session logs from this effort. And from those session logs, I was then able to sort of deduce the token counts for fresh tokens, cash rights, cash reads, uh output tokens. And all told, it was about 136 billion tokens broken up in such a way that if you were to use the public pricing um of those models at those times, it came out to approximately $120,000. Um this is not factoring any discounts or things that companies might have for what those tokens cost.
嗯,这只是大致参考了 OpenAI 和 Anthropic 网站上的信息,再加上我自己的时间投入。你知道,这花了大约 14、15 周,不过我同时还在做其他事情。你知道,很多这类智能体项目……如果我看看现在屏幕上的 Copilot 应用,我目前有大约 35 个正在处理的会话,其中一些属于同一个领域。Um and uh this is just sort of what's on the website of you know open AI and anthropic plus my time which you know the it took it was about 14 15 weeks um but I was doing other things at the same time you know a lot of these uh agentic projects if if I look at my my co-pilot app that I currently have on my screen I've got about 35 sessions right now for things that I'm working on some of them in the same area.
其中一些是,呃,分布在不同的项目中。嗯,所以我不是……开发者不再一次只做一件事了。所以,如果你看一下提交的 PR 百分比,粗略估算一下我投入的时间:在同一时期内,我提交的 PR 大约有五分之一(上下浮动)与这个项目有关,另外 80% 左右是其他事情。嗯,所以你算一下,大约 15 周的 20%,也就是我在三个月里总共投入了大约三周的时间。嗯,另外还要算上 token 成本。而且成本还在不断降低。模型的价格正在以惊人的速度下降。我想,比如 OpenAI 发布……我记不清具体数字了,但我觉得 61 Saul 的价格是 6 Saul 的一半,而 6 Saul 的价格又是 56 Saul 的一半。Some of them are uh across different projects. Um and so I'm not developers are no longer working on one thing at a time. So if you look at the percentage you just as a rough estimate for my time if you look at the percentage of PRs that I was submitting over that same period about a fifth of them give or take was to do with this this project and about 80% was for other things. Um and so if you figure you know about 20% of about 15 weeks you end up with about three weeks of my time spread out over three months. um plus the the token costs. Um and it's only getting cheaper. The the the models are becoming like at cheaper at an astronomical rate. I think like when OpenAI released I'm not going to remember the exact, but I think like 61 Saul is half the price of six Saul and six was half the price of 56 Saul.
就像,它们只会变得越来越便宜。而且模型也在变得越来越好,这意味着我需要花在引导模型正确完成任务上的时间也在不断减少。所以,迁移这些代码的成本、进行这些迁移的成本,随着时间推移只会越来越低。哇。所以,花三周的开发人员时间,再加上 12 万美元,就能重写整个代码库。如果在 AI 出现之前,你要规划这个项目,比如说你想着手做这件事,那会是什么样子?首先,这事根本不会发生。Like the they're just getting cheaper and cheaper and cheaper. Um, and the models are also getting better and better and better, which means that the amount of time that I need to put in to steer the models to do the right thing is also decreasing. Um, and so the costs of these ports, the cost of these migrations is only getting cheaper over time. Wow. So, three weeks of uh I guess of developers time plus $120,000, you're able to rewrite the entire codebase. Um uh if you were to scope this out preai, let's say you wanted to undertake this, what would that look like? First, it wouldn't have happened.
嗯,对于……而且我其实是说,就这件事而言,这种情况本来不会发生,因为等我们做完的时候,我们移植的东西就已经不对了。这个领域变化太快了,我们基本上永远也做不完。Um for and I'm actually ser like for this particular thing the it wouldn't have happened because by the time we were done, we would have ported the wrong thing. like the this space is moving so fast that we would have basically never finished.
我觉得其实你能从博客文章里的图表中看出来:在移植工作的大部分时间里,Rust 代码量一直在增加,而 TypeScript 代码量基本保持不变,只是略有增加。这是因为移植过程中,代码仓库里不断加入大量新功能,对吧?移植工作刚开始时,由于代码库的大部分是 TypeScript,所以新加入的代码大部分也是 TypeScript。到项目后期,代码库的大部分已经是 Rust,新加入的代码也大部分是 Rust。但如果你看图表的前半段,那时 Rust 通常占比不超过 50%,你会发现 TypeScript 代码量是这样变化的,而 Rust 代码量则是那样变化的。I think in fact you can kind of see that in the charts in the blog post in that for a good portion of the porting effort the amount of rust is increasing and the amount of TypeScript is largely remaining the same but increasing a little bit and that's because as the port was happening there was just a huge amount of new functionality coming into the repo right and at the beginning of the porting effort because the majority of the codebase was Typescript the majority of the new incoming code was also Typescript. By the end of the project where the majority of the codebase was Rust, the majority of the new incoming code was Rust. But if you look at like the first half of the graph where we're generally 50% or less Rust, the amount of TypeScript was doing this even as the amount of Rust was, you know, doing that.
你知道,即便情况并非如此,我们说的也有大约 45 万行 TypeScript 代码,只算生产代码,还没算那些移植过来的测试。我想当时还有几十万行 TypeScript 单元测试,也需要移植到 Rust。嗯,想想一个开发者的效率——就算是顶尖开发者,一天之内合理来说能完成多少工作。我们说的是要让整个开发团队花上一两年,才能做成这样的事,对吧?即便有可能做到,这也会是一项巨大的投入。而且,我都很难想象自己要怎么写那份提案,因为我知道那样看起来会很糟——我肯定会立刻被否决,人家会说:“我们当然不会这么做。”You know, even if that wasn't the case, this we're talking it was about 450,000 lines of Typescript, just production source, never mind tests that were ported. I think there was a few hundred,000 lines of unit tests there in Typescript as well that also needed to be ported to Rust. Um, just think about the productivity of an individual developer and how much they can reasonably do in a given day if they're top-notch. And we're talking a whole team of developers for a year or two to do something like this, right? It's it is a if you're able to do it at all, it is it would have been a monumental investment. And like I I struggle to think about even writing that proposal because I know that it would be sort of I would look bad like I would be dismissed immediately as of course we're not doing that.
嗯,而这是一项提案,比如说,我打算在3个月内投入20%的时间,到最后整个项目就会迁移完成,而且大多数情况下,团队里的其他人都不会受到影响。嗯,你知道,这并不完全属实,但我可以笼统地说几句,然后说几个月后我们就能获得这些业务收益。嗯,而且,你知道,这就是成本。这样的提案要容易写得多。即便你真的支付的是未打折的公开 token 费率,也就是12万美元,把它和一名资深开发人员一年的成本相比——包括所有福利和奖金——你知道,甚至这都算划算。Um whereas this was a proposal like I'm going to take you know 20% of my time over 3 months and by the end this whole thing is going to be moved over and for the most part no one else on the team is going to be impacted. Um, and you know, that's not 100% true, but like waving my hands and we'll have all these business benefits in a few months. Um, and it, you know, this will be the bill. That's a much easier proposal to write. And even just the even if you were paying that actual, you know, uh non-disounted public-f facing uh token rates of $120,000, you compare that to the cost of a senior developer, you know, for a year, uh with all their benefits and their bonus, like even that is a good deal.
听起来,至少对于这类工作来说,我们想要的东西非常明确,而且已经编码在现有功能的某个地方。It sounds like at least for this type of work where it's super what we want is very obvious and encoded somewhere in the existing functionality.
所以像这类工作,成本至少低一个数量级,甚至可能更低。我的意思是,如果你有一支工程师团队,而工程师的薪酬大概是每人 20 万到 40 万美元左右,那么这 12 万美元简直微不足道。你当初提出这个项目时,在着手之前,对它会消耗多少 token 有概念吗?So like this type of work is at least one order of magnitude cheaper maybe even more. I mean, if you had a team of engineers and they're, you know, engineers maybe two to 400K or something like that per this is a drop in the bucket, the 120K. When you were proposing the project, did you have a sense of how much this would cost in tokens before you went and did it?
是的。最后账单比我预想的要高。嗯,主要是因为代码行数比我预想的要多。我当时没有充分考虑到需要迁入的代码量会以多快的速度增长。所以,这件事嘛,我觉得有几方面我做得不错,也有几方面做得不够好,毕竟现在回头看,很多事都显而易见了。其中一件我已经提过了:我没有花足够的时间把端到端测试设计得更完善,确保覆盖尽可能全面。这方面我本来可以做得更好。另一件我本来可以做得更好的事,是充分考虑需要移植的代码量会如何增长。我写这份提案时看了代码库,当时生产环境中的 TypeScript 代码大约有 15 万行。Yes. And the bill ended up being larger than I expected. Um mostly because the line count ended up being larger than I expected. Um I hadn't fully factored in the growth rate of how much incoming code there would be. So this was you know there were there were a few things I think I did a lot of things right. I did a few things wrong and you know 2020 hindsight and all that. One of them I already mentioned I didn't spend enough time uh really fleshing out the endto-end tests to make sure that they were as comprehensive as they could have been. I could have done that better. The other thing I could have done better was really factor in the growth rate of code that would need to be ported. So when I looked at the the code base as part of writing this proposal, it was somewhere on the order of 150,000 lines of production TypeScript.
30 左右吧,大概是这样。我不记得确切数字了。嗯,根据这个数字,再加上一些粗略估算,并看看之前提到的那些原型花了多长时间才完成——你知道,就是用不同语言做原型,以便大致衡量性能之类的——我当时估计大概需要六到八周才能完成。嗯,但当你看看我们实际需要移植的内容时,我漏算了几件事。第一,有几十名开发者在使用智能体,非常迅速地为代码库添加各种额外功能。嗯,还有,你知道,这个代码库并不是公开的开源项目,但实际上它属于内部开源。30 something like that. I don't remember the exact number. Um and based on that and some back of the napkin calculations and looking at how long it took to create the prototypes that I'd alluded to earlier for you know in the different languages to sort of measure Perf and things like that, I think I'd estimated about um six to eight weeks uh to get it done. Um, but when you look at what we actually needed to port, I didn't factor in a few things. One, that there were, you know, tens of uh developers using agents uh very quickly augmenting the codebase with lots of different additional functionality. Um, and uh, you know, this codebase is one that's it's not public open source, but it's effectively internal open source.
所以会有很多人加入进来,添加他们需要的东西,然后核心团队会协助审核这些内容。So there's a bunch of folks that come in and add the things that they need and then the core team is helping to review all that.
嗯,所以有大量非常重要的功能涌入,而这是我之前没考虑到的。我也没考虑到,由于代码库形成的方式,CLI、Copilot CLI 和运行时之间的耦合程度相当高,远超理想情况。Um and so there's this very significant influx of functionality that I hadn't accounted for. I also hadn't accounted for the fact that the because of how the code base came about. Um the CLI, the Copilot CLI and the runtime were kind of very intertwined more so than they ideally should have been.
所以,为了只移植运行时,嗯,如果你愿意,CLI 也可以单独移植;但要真正把它们拆分开,做到不需要 CLI,也不必将 CLI 作为使用运行时的应用程序的一部分进行部署,就需要努力把它们拆开。与此同时,还需要把那些实际上不必放在 2e 中、可以由运行时共享的功能下移。而我没能估算出目前标记为 CLI 的代码中,究竟有多少其实适合下移。And so in order to port just the runtime um and you know the CLI can be ported separately if you wanted to but to actually tease them apart to the point where you don't need the CLI you don't need to deploy the CLI as part of your application that's using the runtime there's this effort of teasing them apart but then there's also an effort of moving functionality that really doesn't need to be in the 2e and that could be shared in the runtime down and I failed to account for how much of the code that was currently marked as CLI would actually be beneficial to move down.
因此,在这项工作过程中,也有代码陆续传下来。到最后,我们移植了大约 40 万到我想是 45 万行 TypeScript,大约是我预估的三倍,这既影响了完成这项工作的端到端耗时,也影响了 token 数量。And so over this effort, there was also code that was coming down. So by the end um we ported somewhere between four and I think 450,000 lines of Typescript. So about three times what I'd estimated um which impacted both the endto-end time that it took to do it and then also uh sort of token counts.
何时进行全面重写When to do a full rewrite
所以,经历了这个过程之后,如果某个团队里的软件工程师正在考虑做某种重写,他们应该看哪些标准,来判断这件事值不值得做?归根结底,真的要看商业价值吗?我是说,有些事情你可以纯粹为了好玩去做,花的是自己的钱,值不值得由你自己决定。嗯,就像我真的不太喜欢去赌场,因为我不喜欢按我的理解那样赌博输钱;但我的一些朋友很喜欢,他们觉得这是花钱买一晚上的娱乐。他们不是在输钱,而是在为乐趣买单,对吧?所以,如果你有自己的个人开发项目,想花些 tokens 把它移植到别的平台上,那很好。So after having gone through this process, if there was a software engineer out there on some team considering doing some sort of rewrite, what criteria should they look for to decide if it's worth undertaking it or not? It it really comes down to what is the business value? I mean, there's there's the ones you can do for fun where it's your dime and you get to decide, you know, what fun is worth. Um, just like, you know, I I really don't like going to casinos because I really don't like what I consider to be losing money gambling, but friends of mine love it and they consider it paying for a night's worth of entertainment. They're not losing money, they're paying for fun, right? And so if you're if you've got your own personal development project and you want to spend tokens on porting that to something else, great.
玩得开心。这听起来确实很棒。但但你需要弄清楚收益是什么。对你来说,收益就是乐趣;而对企业来说,关键是这件事能带来什么业务价值。然后,和其他事情一样,还要考虑成本是多少,以及投资回报是多少。这一点必须非常明确。世界各地的人和企业在智能体出现之前,就已经在做很多这类迁移项目了;他们评估过成本,并认定投资回报非常值得。我经常看到这种情况,比如人们从 .NET Framework 迁移到 .NET Core。Have fun. Like that sounds awesome. But but the benefit you need to understand what the benefits are. The benefits are your enjoyment. When it comes to a business, it's what is the business value that this is occurring to. And then like anything else, what is what is it going to cost? Uh and what is the return on that investment? And that needs to be very clear. And there are lots of these migration projects that are people all over the world and businesses all over the world are doing even before agents where they have done that cost assessment and they've decided that the return on investment is very much worthwhile. Um I saw this a lot with net with you know people moving from net framework to net core.
嗯,而且我们在让 .NET Core 变得极快这件事上投入了很多。因此,进行这次迁移确实能带来非常实在的性能收益。Um, and because we invested, you know, a lot in making.NET Core incredibly fast. And so there would be very real performance benefits that would come from doing that migration.
他们可以算出相关成本:嗯,我们现在每年要花 X 百万美元来运行我们的服务。通过迁移,也就是进行这次移植,我们每年可以节省 300 万美元。而这次移植需要一年时间,也会占用一名开发人员一整年。所以他们算了算,你知道,这绝对值得。And they could figure out the cost associated with, well, we're spending X millions of dollars running our services today. And we would save $3 million a year by moving, you know, by doing this port. And this port is going to take a year and it's going to cost us a developer for that year. So they do the math and you know this is this is absolutely worthwhile.
嗯,即使是在更微观的层面,也不只是针对移植项目:你会选择投入哪些功能?比如,我以前花很多时间做 .NET Regex 引擎时,就可以看看我们公司每年在运行正则表达式上花了多少钱,或者某项具体服务每年为此花了多少钱。如果我花两周时间改进 .NET Regex 引擎,让它们使用的模式运行速度提升四倍,那就……Um even at a a more micro level not even for ports like what features do you invest in? when I was um spending a lot of my time working for example on the net um reax engine uh you know I I could look to see how much are we spending we as a company you know or how much is this particular service spending on running on regular expressions every year if I invest two weeks in making these changes to the net reax engine and it makes the the patterns that they're using four times faster.
我投入这两周能获得什么回报?作为一项服务,它们在一年内能帮我们节省多少钱,对吧?这类权衡无处不在。你只需要清楚地说明为什么要做这件事、它需要花多少钱,以及你能从中得到什么。如果你能把这些都写下来,并且论证充分,那这就是一个值得做的好项目。如果你无法证明它值得做,那就很可疑了。What is the return on investment for my two weeks and how much they save as a service over the course of the year, right? That these kinds of trade-offs are everywhere. And you just need to be very clear about why you're doing it, what it will cost, and what you get for it. And if you can write all that down and you can justify it, then it's a good project to do. If you can't justify it, it's very suspect.
迈向杰出级别之路上的职业心得Career learnings on the way to Distinguished
为这次采访做准备时,我了解了一下你的职业经历。嗯,你的 LinkedIn 上没有相关信息,不过我找到了一段你接受的采访,采访者是……When I was doing research for this interview, I looked into your career. Well, on your LinkedIn there's no information, but I found an interview you did with
是啊,我非常……我基本上,我在微软已经待了 25 年。我很喜欢这里。我在公司内部换过很多岗位,但我从来没兴趣去别的公司,所以也就没怎么花心思保持 LinkedIn 个人资料的更新。不过,我后来做了一番调查,也听了你关于不同岗位的访谈。你的晋升为杰出工程师的经历真的很有意思,因为你做过很多不同的工作,并不是只是在 A 团队做 Sui,然后又在 B 团队做 Sui。你做过各种各样的岗位,最开始几乎像是一名前线部署工程师、咨询工程师。对。Yeah, I'm very I'm I basically I I've been at Microsoft for 25 years. I love it. I've jumped around a lot internally, but I've had no interest in going to different companies and so I haven't really invested in keeping my LinkedIn profile up to date. But so when I when I did the digging though or like listened to an interview that you had done about the different roles, your path to distinguished engineer is really interesting because you did a bunch of different roles and it wasn't just sui on team A and then Sui on team B. You held a variety of ones starting as almost a like a forward deployed engineer, consultant engineer. Yeah.
然后你后来做过一段时间的技术写作,之后又当过副总裁的顾问——技术顾问。哦,你还在某个时候转去做了 PM。你尝试过这么多不同的岗位,你觉得哪个最值得推荐给别人去尝试一下?如果他们想试试不同方向,而不是做纯粹的 SU 岗位的话。And then you did technical writing at some point and then you were an adviser to a a technical adviser to a VP. Oh, and you also jumped to a PM at some point. From all those different roles that you tried, which of them would you say was the most um like you would recommend someone dabble in that direction if they wanted to try something that wasn't the pure SU roll?
是的,我做过的每一份工作都教会了我不同的东西。所以从这个角度来说,我非常尊重那些大学毕业后想成为开发者、成为工程师,并且一直沿着这条路走下去的人。这对我来说是一条完全可行的道路。我觉得自己走了一条更迂回的路,因此掌握了很多不同的技能。比如,你提到我做过前线部署工程师。当时那更像是微软的咨询部门,所以我会在某个客户现场待上三周到三个月,帮他们解决问题,同时也会深入了解他们所在的行业。Yeah, every role that I did taught me something different. And so from that perspective like I have great respect for people that you know are come out of college and want to be developers and become an engineer and that's and that's what they do and they just stay on that path like that's a very valid path for me. I think I picked up a whole bunch of skills by having more of a ciruitous route. So like you you mentioned as a forward deployed engineer it was more at the time was Microsoft's consulting arm and so I would spend anywhere from three weeks to three months at a particular customer site helping them solve their problems and I would learn a whole lot about their industry.
我会学到很多很多关于他们那类特定问题的东西。我会从外部了解微软提供的产品和服务,了解它们出色的地方,也了解不那么出色的地方。I would learn a whole about a bunch a whole lot about their particular breed of problem. I'd learn about Microsoft's offerings from the outside and places that it was great and places that it wasn't so great.
嗯,了解客户真正的困境、他们正在应对的问题,并能把这些经验带回来,之后再为他们构建解决方案,这非常有价值。嗯,后来我参与了《MSDN Magazine》的工作,做了很多技术写作和技术编辑,也琢磨自己想和大家分享什么、想怎么分享;此外还做了一些开发工作,构建一些东西,再以此为话题进行交流。通过这些经历,我逐渐掌握了一些技能,懂得如何思考什么真正有趣、什么真正相关,如何清晰地表达,哪些内容不需要说,哪些内容必须说,以及如何讲述一个真正能引起共鸣的故事。um and learn how our customers like their their real struggles and and what they were dealing with and being able to bring that back to then later building solutions for them was incredibly valuable. Um, when uh I then worked on like MSDN magazine and was doing a bunch of technical writing and technical editing and figuring out what I wanted to share with people and how I wanted to share it and um some amount of development building things to then talk about like I I gathered a set of skills around how to think through what was really interesting, what was really relevant, uh how to communicate it in a clear fashion. uh what didn't needed to be said, what did need to be said, how to tell a story that would really resonate.
嗯,从产品经理的角度来看,问题就变成了:我该怎么——我们该怎么弄清楚实际需要构建什么,以及要把哪些部分整合起来,才能真正交付这个东西。Um from a PM perspective, it became, you know, how do I how do we figure out what actually needs to be built and what are all the pieces that need to come together to really deliver this thing.
嗯,显然从开发者的角度来说,所有编码、设计、架构之类的事情都很有意思。我觉得对我来说最有意思的角色,是担任微软一位副总裁的技术顾问。我非常感激自己做过这件事,也很庆幸自己做过,不过绝不会再做第二次。那是一段很棒的经历。我在那里待了几年,像是他的得力助手,也是隐形的搭档,跟进他所做的一切,帮他代笔;每次开完会,我们都会稍微回顾一下,梳理听到了什么、觉得该怎么应对,再互相交流想法。Um obviously from a dev perspective all the coding and the design and the and the architectural and all that kind of stuff. The most interesting role for me I think which I am incredibly thankful and glad that I did and will never do again uh was being um sort of as technical advisor for a VP at Microsoft. Um it was an amazing experience. It was a couple years where I was there right-hand sort of like invisible partner um shadowing everything they were doing and ghost writing and after every meeting having a little you know review kind of going through what we heard and what we think we need to do about it and bouncing ideas back and forth.
嗯,这让我对事情实际如何运作、决策实际是如何做出的有了非常深刻的了解。嗯,我也参与了一些原本不会有机会参与的事情,至少要很多很多年之后才有机会。Um it was incredibly insightful into how things actually work, how decisions actually get made. um being a part of things that I wouldn't otherwise have been a part of, at least not for many, many years later.
嗯,那真的很棒。不过也特别消耗精力,特别需要无私奉献。呃,这件事确实让我付出了很多。所以我很珍惜那些经历,以及从中学到的东西。我也强烈建议任何有机会的人,都去做一段时间这样的事。Um it was awesome. It was also incredibly draining, incredibly selfless. Uh and it it took a lot out of me. Um and so I cherish those experiences and what I learned from them. And I would highly encourage anyone who has the opportunity to do so to do that kind of thing for a period of time.
这个职位真的很有意思,因为听起来你基本上就像是某位身居高位、又懂技术的人的幕僚长。所以你不是那种高管助理,而是会参与所有那些——我想应该算是——非常机密的谈话,并提供他们做决策所需要的信息。你提到自己学到了事情实际上是怎么运作的。嗯,你能举些例子吗?比如说,如果有人担任类似的职位,可能会学到些什么,或者有什么东西对你特别有帮助?That role is really interesting cuz it sounds like you're uh you're basically a chief of staff to someone super high up but technical. So you're not like an executive assistant. you're like the you're pulled into all the really I guess privileged conversations and you're providing that that information that they need to make the calls. You mentioned that you learned how things are like really done. Um do you have some examples of stuff that someone might learn if they were kind of in that that role or something that was really helpful for you?
很多时候,如果你只是公司里一名普通工程师,看到这些决策被做出——比如发邮件宣布我们要采用某条新路线、建立某项合作关系、进行某笔投资、完成某项收购、逐步停止某款产品、投入资源开发新产品,或者组建一支新团队——你会觉得这些事情好像都是凭空冒出来的。它们就这么被自上而下地传达下来,仿佛这是一个已经尘埃落定、成熟定型的决策。There are lots of times where if you're sort of rank and file engineer at a company and you see these decisions that get made, an email gets sent out about some new path we're following or some partnership we're forming or some investment that we're making, some acquisition that is being done, winding down a certain product, investing in a new product, spinning up a new team, like all of those things look like they just sort of come out of thin air and they're, you know, they're just sort of handed down as this is the finished decision and it's fully formed.
你其实无法真正了解一路走到那一步的所有情况,也不知道曾经考虑过哪些备选方案、又为何将它们排除,以及其中权衡了哪些利弊;也不了解行业里的资深人士是如何分析这些备选方案和问题的,他们选择把注意力放在哪些事情上,又认为哪些事情无关紧要。嗯,这些都是我以前接触不到的。而能够像一只壁上观的苍蝇一样——呃,虽然这么说有点混用比喻,不过你知道,就是把这一切都吸收进去,然后还能就此展开讨论。比如,我们开完会出来后,他基本上就会问:“那么,你听到了什么?你觉得呢?”You don't really get insights into everything that led up to that point and all of the alternatives that were considered and dismissed and why and what the trade-offs were that were factored in and how experienced people in the industry are thinking through those alternatives and those problems and h which things they're choosing to focus on, which things they consider to be irrelevant. Um, all of that is stuff that I didn't have exposure to. And being able to be a fly on the wall, uh, just soaking in, not to mix metaphors, but, you know, soaking in all of that and then being able to have conversations about it to, you know, I we'd get out of a meeting and he'd basically say, "So, what did you hear? What do you think?
“就像,帮忙,你知道,帮我理理思路。”有时候我会提出有价值的见解,有时候他会说不。Like, help, you know, help reason through it." And sometimes I would have valuable insights and sometimes he would say no.
我们并不是这样看待这些事情的。而且,每一件事对我来说都是一次学习经历。That's that's not how how we think about these things. And and every one of those was a learning experience for me.
是啊。我也听工程师们类似地说过,尝试做管理是有价值的,即使他们最终发现自己讨厌管理、不想再做第二次——你……是啊。作为管理者,你能更深入地了解事情背后的运作方式。你会看到管理组织时做出的种种决策,这些经验有助于你做好运营工作,也会对你的整个职业生涯有所帮助。Yeah. I've heard engineers say similarly about the value of trying management even if they ultimately decide they hate it and they don't want to do it again is you Yeah. You get to see how the sausage is made a little bit more as a manager. you see all those decisions uh in managing the org that can be helpful in operating uh just in your your career in general.
是啊。而且你知道,我之前没提过,我当时也觉得自己真正想做的是管理者。所以我基本上就安排好了这些事。后来在某个时候,我在微软内部换过不少岗位,转到了一个新职位,当时我们口头约定,六个月后我就能转到一个带团队的主管岗位。我把这些都安排妥当了,结果也很顺利,我成了主管。做主管六个月后,我开始想:我不确定这是不是我原本以为的那样。又过了六个月,我就觉得:不,这肯定不是我想要的。这不适合我。后来我又花了大约一年,才稳妥地转回个人贡献者(IC)岗位,并一直做到现在。Yeah. And you know I also I I'm I didn't mention it before but I also did that like I I thought that what I really wanted to be was a manager and um so I basically set things up whereas a certain point I trade you I jumped around a lot internally at Microsoft and I changed to a role where I had sort of handshake agreement that six months later I would be able to sort of shift into a lead position and have a team of of people. And I arranged all that and it all worked out and I became a lead. And six months into being a lead, I was like, I'm not sure if this is actually what I thought it was. And six months after that, I was like, nope, it's definitely not. This is not for me. Um, and then it took me about a year after that further to sort of um, safely work my way back to uh, an IC role where I've been since.
嗯,另外,正如你刚才所说,我真的非常感激这段经历,也特别感激微软设有个人贡献者职业发展通道,让人可以在整个职业生涯中不断进步、持续获得晋升之类的,同时又不必直接管理下属。对我来说,我后来意识到,我喜欢管理工作的原因,或者说我当初以为自己想当经理的原因,是我觉得只有这样才能帮助别人,才能为别人提供职业指导、帮他们解决问题之类的。但这是我当时的误解。直到我成为经理之后,我才意识到,作为个人贡献者,我也能做到这些。而我喜欢的那些管理工作,其实并不需要当经理也能做。Um, and again to your point like super grateful for the experience, incredibly grateful to Microsoft for having the for having an individual contributor career track that allows one to sort of progress their whole career and continue to be promoted and whatnot, but still not have to have direct reports. For me, what I realized was the thing that I loved about or that I thought the reason I wanted to be a manager was because I thought it was how I could help others and how I could kind of provide uh career guidance or help other people solve problems or whatever it was. And that was misguided on my part. And it took becoming a manager to realize that I could do all of that as an individual contributor. And the things that I that I loved about being a manager were things that I didn't have to be a manager to do.
最佳技术书籍推荐Top technical book recommendation
有没有一本你特别推荐、并且可能对你产生过影响的书?Do you have any top book recommendation that maybe impacted you?
是啊,我是说,这本书现在已经算是老书了,但我读过好几遍。嗯,我真的特别喜欢。查尔斯·佩措尔德有一本书叫《编码》。大概是2003年出的吧,我也不确定,差不多那个时候。不过我很喜欢它,而且我特别看重的一点是,它能把复杂的概念解释得很清楚,不需要读者事先了解你在讲什么。Yeah, I mean it's old at this point, but I've read it several times. Um, and I absolutely love it. There's a book by Charles Petzold called Code. It's probably from what 200 three maybe, I don't know, something in that time frame. But I love it and it is one of the things that I really value is being able to explain complicated concepts in a way that doesn't require the person to know anything about what you're talking about.
我认为这是一项很有价值的技能,即使你是在和那些确实懂你所讲内容的人交流也是如此。能够把复杂的概念拆解成清晰、简洁的部分,并清楚地表达出来,再从一个很高的层面进行阐述,是让所有人达成共识、论证自己的观点,并推动事情朝着你希望的方向发展的好方法。《编码》这本书里,查尔斯基本上就是这么做的:他从基础原理出发,讲解计算机是如何工作的,带着那些对计算机一无所知、也没有技术经验的读者,逐步了解二进制、逻辑门、电路、编程、计算机和互联网,从零开始,一步步建立起对这一切如何运作的基本认识。I think that is a valuable skill even if you're talking to people that do know what you're talking about because being able to break down complicated concepts into very clear concise pieces and communicate that clearly and then at a 30,000 ft level is a is a great way of getting everyone onto the same page and sort of arguing your case and pushing things in the direction that you want them to And code is a book where Charles basically does that where he talks about how computers work from the ground up teaching people that know nothing about computers that aren't technically experienced about binary about logic gates about circuits about programming about computers about the internet and kind of building things up from basic principles from nothing to a reasonable understanding of how everything works.
嗯,这本书让我大为震撼,之后我又重读了好几遍。虽然我已经知道书里的所有内容,但我就是很喜欢它表达这些内容的方式。所以,如果只能推荐一本,那就是它。Um, and I was blown away by the book and I've since reread it on multiple occasions. Even though I know everything that's in there, I just love the way that it communicates things. So, if I had one recommendation that that's it.
给年轻工程师的建议Advice for young engineers
回顾你的整个职业经历,你在这个行业工作也有一段时间了。对于如今刚进入这个行业的年轻工程师,你有什么认为可能会有帮助的职业建议吗?这是个很好的问题,也是我一直在纠结的问题。嗯,几年前,我可能会给出一个清晰得多的答案,但有了 AI 之后,我还是不知道正确的答案是什么。嗯,很多时候,我花时间与 AI 智能体协作,都会调动自己 25 年的经验——不管是好是坏——以便能非常迅速地看出它们做得对不对,或者判断我该如何引导它们。或者某个智能体会说:“我有 100% 的把握,正确答案是 A。”而我会说:“好吧,不过你有没有考虑过 B、C 和 D?因为这些取舍可能并不存在。”Looking back on all your experience, you've kind of been working in the industry for a while. What professional advice would you give a young engineer just entering the industry today that you believe could be helpful? That's a great question and it's one I've been struggling with. Um, a couple years ago I would have had a much more clear answer, but with AI, I still don't know what the right answer is. Um, a lot of the times that I spend working with AI agents, I'm bringing to bear 25 years of experience for better or worse in being able to very quickly sniff out things when they're doing the right thing or they're doing the wrong thing or how I want to guide them. Or an agent says, I'm 100% confident that the right answer is A. And I'll say, "Yeah, but have you also considered B and C and D because these trade-offs might not be there?"
对吧?当然。就像,要能通过这些小事正确地引导他们,你自己就得亲身经历过。而我担心,随着 AI 智能体不断发展,人们会失去亲身经历这些过程的机会。我还不知道该怎么解决这个问题。嗯,我非常坚信,人们确实应该扎实地学习基础知识,从核心原理出发,一步步构建起自己的理解。所以,比如学习一门编程语言时,我仍然认为学习 C 这样的语言很有价值,也适合作为起点,因为这样你才能理解计算机实际上是如何工作的,明白内存管理意味着什么,也能了解不同算法之间的各种权衡,而不是在一个把许多底层细节都隐藏起来的层次上工作。Right? And oh, of course. Like just those little things being able to guide them in the right way requires you to have gone through it. And I'm concerned that because of what AI how AI agents are progressing that they're taking away the opportunities to have gone through it. And I don't yet know what the answer then is. Um I am a very firm believer in um really learning kind of the basics and building everything up from core principles. And so like when you know learning a language, I still think it's valuable to learn and to start out with a language like C because you're understanding how computers actually work and you understand what memory management means and you learn about all the various trade-offs between this algorithm and that algorithm rather than working at a layer where a lot of that is obscured from you.
呃,编程语言和运行环境会为你提供大量服务,但你未必理解正在发生的一切。所以从这个角度来说,我仍然认为,专注于那些核心概念,并真正内化算法以及机器实际如何运作,是有价值的;还要能够据此进行推理和推演。我猜,无论你身处哪个领域,这些关于分布式系统或数据库的核心基础知识——这些基础性的东西——都会帮助你在这样一个世界里取得成功:绝大多数代码实际上都是由智能体编写,而你则负责引导它们。不过我也不确定这一点。uh where the language and environment are providing a ton of services to you but you don't necessarily understand everything that's happening and so from that perspective I still think that there's value in focusing on those core concepts and really internalizing algorithms and how machines actually work um and being able to reason and extrapolate from that and I suspect that that will in whatever domain you're in. That kind of core primitive knowledge about distributed systems or about databases like that foundational stuff will help to be successful in a world where the vast vast vast majority of the code is actually being written by agents and you're helping to guide them. But I don't know that for sure.
而这些智能体学习和进化的速度如此之快,我不知道两三年或四年后世界会变成什么样。And at the rate that these agents are learning and evolving, I don't know what the world's going to look like in two or three or four years.
嗯,我觉得它会和现在大不相同。我想,接下来会是一段疯狂的旅程。Um, I suspect it'll look vastly different than it does today. I think we're in for a wild ride.
太好了。嗯,非常感谢你今天抽出时间,Stephen。真的非常感激。Awesome. Well, yeah, thank you so much for your time today, Stephen. I really appreciate it.
很高兴与你交谈。这次对话很愉快。谢谢。Pleasure. This has been a fun conversation. Thank you.
结尾Outro
嘿,感谢你收看这期播客。如果你喜欢节目,也希望它越办越好,请留言或点赞支持一下。另外,如果你有什么想让我邀请来做客的人选,也欢迎留言告诉我。像 Barbara Liskoff、Mike Stonereaker、Mark Brooker 这样的嘉宾,都是因为有人留言推荐,我才邀请他们来的。 另外,除了做播客,我还在着手打造一款我一直希望存在的人体工学键盘。来看看原型吧。它是一款分体式键盘,有左右两部分。呃,这个原型装在外壳里,不过我们已经在 Kickstarter 上发起众筹,而且上线八小时内就达成了目标。Hey, thank you for watching this podcast. If you liked it and you want to see the show grow, please support with a comment or a like. Also, if you have any recommendations for people you want me to bring on, please drop a comment. Guests like Barbara Liskoff, Mike Stonereaker, Mark Brooker, these were all people that I brought on because someone left a comment. On another note, aside from the podcast, I'm working on building the ergonomic keyboard that I wish existed. Here's a glance at the prototype. It's a split keyboard, so there's two sides. Um, this is in the case, but yeah, we launched on Kickstarter and we hit our goal within eight hours of launching.
如果你是早期购买者之一,我真的非常感谢。嗯,我们现在正着手开启一段漫长的旅程,打造相关的工具,所以如果你还想买一台,我已经在 Kickstarter 上开放了逾期支持,你可以在那里购买。I really appreciate it if you were one of the people who grabbed one of the early units. Um, we're now working on the long journey of building the tooling now and so if you still want to pick one up, I've left the late pledges open on Kickstarter, so you can grab one there.
我会把链接放在简介里。再次感谢大家收看这期播客,我们下期再见。I'll put a link in the description. Thank you again for watching the podcast and I'll see you in the next