We should be more ambitious with the software we build

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Since early this year, Michael Malis (of pgrust) has been showing me interesting things he’s done and saying: “[W]e should be more ambitious with the software we build.”

自今年年初以来,Michael Malis(pgrust 的开发者)一直向我展示他所做的有趣工作,并表示:“我们应该在构建软件时更有野心。”

There is, understandably, a lot of skepticism about projects like pgrust because there are so many low-quality AI-generated projects out there. If I didn’t know Malis and didn’t look into it, I would just assume that pgrust was another vibe slopped project that’s never going to work. But I know Malis well enough to trust his work without looking into it, and if you look into it a bit, you’ll see that in testing pgrust, he’s testing thoroughly enough that he’s even uncovering real bugs in Postgres, such as this numerical bug that can cause valid SP-GiST operations to fail, this format cache bug that can cause incorrect results from JSONPath, this pgcrypto bug that can cause later operations to fail, multiple memory safety bugs in the dictionary loader, this money overflow bug, etc.

可以理解,人们对 pgrust 这类项目存在很多怀疑,因为市面上充斥着大量低质量的 AI 生成项目。如果我不认识 Malis 且没有深入研究,我也会认为 pgrust 只是另一个注定失败的“糊弄”项目。但我很了解 Malis,足以在不深究的情况下信任他的工作。如果你稍微研究一下,就会发现他在测试 pgrust 时非常彻底,甚至发现了 Postgres 中真实的漏洞,例如导致有效的 SP-GiST 操作失败的数值错误、导致 JSONPath 返回错误结果的格式缓存错误、导致后续操作失败的 pgcrypto 错误、字典加载器中的多个内存安全漏洞,以及这个金额溢出错误等等。

This isn’t to say that pgrust is bug free, but it does indicate that there’s a substantial amount of testing happening and, even if pgrust itself is never successful, just making the attempt will have improved Postgres in a durable way. The main pitch for pgrust is actually performance, and that’s where the really interesting work is happening; if pgrust fails, it’s possible that some of the optimizations they’ve demonstrated will make it into Postgres, Clickhouse, etc., but that’s obviously less direct than filing Postgres bugs which get fixed.

这并不是说 pgrust 没有漏洞,但这表明该项目进行了大量的测试。即使 pgrust 本身最终没有成功,仅仅是这次尝试也已经以持久的方式改进了 Postgres。pgrust 的主要卖点其实是性能,这也是最有趣的工作所在;如果 pgrust 失败了,他们所展示的一些优化方案仍有可能被整合进 Postgres、Clickhouse 等项目中,但这显然不如直接提交并修复 Postgres 漏洞来得直接。

That being said, I find it understandable that, every time I see pgrust discussed on a news aggregator, most people dismiss it as vibeslop garbage because almost all of these rewrite projects are slop. If I didn’t know Malis, I would make the same assumption, because who has the time to look into all of these projects? Because I know Malis, I didn’t bother to look at it; I just trusted him (I only found the above because I wanted to check on pgrust before using it as an example for this post).

话虽如此,我完全理解为什么每次在新闻聚合网站上看到关于 pgrust 的讨论时,大多数人都将其斥为垃圾,因为几乎所有这类重写项目确实都是粗制滥造的。如果我不认识 Malis,我也会做出同样的假设,毕竟谁有时间去研究所有这些项目呢?正因为我认识 Malis,我才没费心去查看,直接信任了他(我之所以发现上述内容,只是因为我想在将 pgrust 用作本文示例之前先核实一下)。

As a consumer of software, everywhere you look, there’s slow software that the creator is claiming is fast because the creator is touting some slop benchmark, e.g., here’s one of multiple examples I saw yesterday, and of course low-quality software that doesn’t work is more common than ever.

作为软件消费者,无论你往哪里看,到处都是运行缓慢的软件,而开发者却因为吹嘘某些拙劣的基准测试而声称其速度很快。例如,这是我昨天看到的多个例子之一,当然,无法正常工作的低质量软件也比以往任何时候都更常见。

But, as a builder of software, it doesn’t matter that almost all of these projects are vibeslop, that other people are out there shoveling out huge piles of crap and calling it gold. You can build things like pgrust or other projects that would’ve been too large to really be feasible in the past and, if you do a reasonable job with testing and benchmarking, that stuff can actually be good-enough quality to use.

但是,作为软件构建者,其他项目是否粗制滥造、别人是否在倾倒垃圾并将其称为黄金,这些都不重要。你可以构建像 pgrust 或其他在过去因规模太大而无法实现的项目,只要你在测试和基准测试方面做得合理,这些东西实际上可以达到足够使用的质量。

If I were writing it, I would say “we can be more ambitious with the software we build” and not “we should”, but Malis has been casually chatting with me when he’s said this, so maybe he would say the same in an actual post; don’t read too much into should vs. can here. What’s interesting to me is how capabilities have advanced such that we can do a lot more.

如果是我来写,我会说“我们可以在构建软件时更有野心”,而不是“我们应该”,但 Malis 说这话时是在与我闲聊,所以也许他在正式文章中也会这么说;不必过度解读“应该”与“可以”的区别。让我感兴趣的是,技术能力已经进步到我们可以做更多事情的程度。

Just for example, after hearing that OpenAI was going to use Cerebras for their SOTA models and not just fast-but-low-quality models like 5.3-Codex-Spark, I looked at where time on my computer would go if I was using a SOTA model, but 10x to 100x faster; some things that were already sometimes a bottleneck that would only get worse with a faster model were:

举个例子,在听说 OpenAI 将使用 Cerebras 来运行其最先进(SOTA)模型,而不仅仅是像 5.3-Codex-Spark 那样快速但低质量的模型后,我研究了一下如果我使用一个快 10 到 100 倍的 SOTA 模型,我电脑上的时间会花在哪里;一些原本有时就是瓶颈,且在模型变快后只会变得更严重的问题包括:

At the level of a “works for me” project, these are all things that can seriously be improved. I don’t have much spare time at the moment but, even so, I built this regex engine that can be tweaked to be faster than other general-purpose regex libraries on any particular workload I care about, this ripgrep fork that uses the native code compiler from the regex engine and is faster for my codex ripgrep workloads (of course a text index is the better solution, but I’ve already worked on text indexing and this was a “just for fun” project where I wasn’t trying to do the optimal thing), and a Rust that sped up builds for my projects (huge improvement for cold builds, moderate for warm, limited by wanting to avoid forking the Rust compiler front-end). For syscalls and filesystem overhead, just switching development from Mac to Linux improved this a lot, and of course this is another thing that can be sped up a lot as well, especially when agents are hammering lots of small filesystem operations (it’s not uncommon to see my machine waiting on filesystem ops because the standard OS filesystem interface wasn’t designed with modern disk performance in mind). With modern disks, there’s no reason to use the *nix filesystem API. In the past, writing a developer toolchain that uses direct I/O instead of normal filesystem operations or building a custom OS or a funny layer that fakes out syscalls would’ve been an absurd endeavor, but that’s totally doable now.

在“能用就行”的项目层面,这些都是可以显著改进的地方。我目前没有太多空闲时间,但即便如此,我还是构建了这个正则表达式引擎,它可以针对我关心的任何特定工作负载进行调整,使其比其他通用正则表达式库更快;我还构建了这个 ripgrep 分支,它使用了来自该正则表达式引擎的本地代码编译器,对于我的 codex ripgrep 工作负载来说速度更快(当然,文本索引是更好的解决方案,但我已经研究过文本索引,这只是一个“纯属娱乐”的项目,我并没有试图追求最优解);我还构建了一个加速我项目构建的 Rust 版本(对冷启动构建有巨大提升,对热启动构建有中等提升,受限于我不想分叉 Rust 编译器前端)。对于系统调用和文件系统开销,仅仅将开发环境从 Mac 切换到 Linux 就有了很大改善,当然这也是另一个可以大幅加速的地方,特别是当智能体频繁进行大量小文件系统操作时(我的机器经常在等待文件系统操作,因为标准操作系统的文件系统接口在设计时并未考虑现代磁盘的性能,这并不罕见)。有了现代磁盘,没有理由再使用 *nix 文件系统 API。在过去,编写一套使用直接 I/O 而非普通文件系统操作的开发工具链,或者构建一个自定义操作系统或一个伪造系统调用的有趣层,将是一项荒谬的尝试,但现在这完全可行。

For someone like me who doesn’t know anything about regexes, string matching algorithms, compilers, interpreters, etc., this set of projects would’ve taken a year or more to get to “works for me” quality. Instead, this was a low single-digit number of hours of my time. If I wanted to make any of these things meet a “useful product or open source project” quality bar, that would be a lot more work, but it’s still pretty incredible how much this process is sped up.

对于像我这样对正则表达式、字符串匹配算法、编译器、解释器等一无所知的人来说,这一系列项目在过去可能需要一年甚至更久才能达到“能用就行”的质量。而现在,我只花了几个小时。如果我想让其中任何一个项目达到“有用的产品或开源项目”的质量标准,那将需要更多的工作,但这个过程被加速的程度仍然令人难以置信。

My read of Malis’s meaning when he says “we should be more ambitious with the software we build”, is that it doesn’t even occur to people to do these things that are now easy. For weeks, every time I logged into Twitter, I saw someone complain about how Rust compilation is slow and is limiting development velocity (I think this wasn’t actually true when I saw the complaints, in that this was before 5.6 Sol and 6 Astra were available on Cerebras, and if you measured where the time actually went, Rust compilation time wasn’t actually that much of a bottleneck at the time). Sure, Rust compilation is slow.

我对 Malis 所说的“我们应该在构建软件时更有野心”的理解是,人们甚至没有想到去做这些现在已经变得很容易的事情。几周以来,我每次登录 Twitter,都会看到有人抱怨 Rust 编译速度慢,限制了开发速度(我认为在我看到这些抱怨时,事实并非如此,因为那时 Cerebras 尚未推出 5.6 Sol 和 6 Astra,如果你测量时间到底花在了哪里,Rust 编译时间在当时其实并不是那么大的瓶颈)。当然,Rust 编译确实很慢。