文章摘要
该项目用Rust重写了Postgres数据库,已通过100%的Postgres回归测试,兼容Postgres 18.3版本,包含超过4.6万条回归查询测试。
文章总结
好的,这是根据您的要求,对原文进行的中文重述:
标题: GitHub - malisper/pgrust: 用Rust重写的PostgreSQL,现已100%通过PostgreSQL回归测试
核心内容:
pgrust是一个用Rust语言重写PostgreSQL的项目。它旨在与PostgreSQL 18.3版本保持兼容,并已成功匹配PostgreSQL在超过46,000个回归查询中的预期输出结果。该项目在磁盘层面与PostgreSQL兼容,可以直接从现有的PostgreSQL 18.3数据目录启动。
项目目标:
pgrust的核心目标是让从内部修改PostgreSQL变得更加容易。具体来说,它保持PostgreSQL的行为模式,以真实的PostgreSQL测试作为验证标准,并利用Rust语言和AI辅助编程来探索更深层次的服务器端改动。
当前状态:
pgrust目前尚未达到生产就绪状态,也未进行性能优化。现有的PostgreSQL扩展以及PL/Python、PL/Perl、PL/Tcl等过程语言扩展通常还不兼容。部分内置的contrib模块已经移植,未来可能会支持更多兼容性。
未来路线图:
- 实现PostgreSQL内部的多线程
- 内置连接池功能
- 更好地支持JSON密集型工作负载
- 支持快速分支和工作流
- 存储实验,包括无VACUUM的设计
- 为不良查询和AI生成的SQL提供运行时防护
- 减少查询计划突然变差的情况
如何尝试:
- WebAssembly演示: 访问 https://pgrust.com 在线体验。
- Docker: 使用提供的Docker命令可以快速启动一个pgrust容器,并通过内部的
psql客户端连接。 - 从源码构建: 项目提供了在macOS和Debian/Ubuntu系统上的构建指南,包括安装依赖、编译、初始化数据目录和启动服务的步骤。
回归测试:
项目提供了一个脚本 (scripts/run-regression) 来运行PostgreSQL的回归测试套件。该脚本会使用pgrust自身的--initdb命令和仓库中附带的PostgreSQL 18.3测试文件。已验证的结果是,pgrust在超过46,000个回归查询中与PostgreSQL的预期输出完全一致。
项目背景:
该仓库包含了达到回归测试里程碑的新版pgrust实现。旧版实现已归档。项目背景和相关文章链接提供了更多关于pgrust启动、67%兼容性更新以及“四骑士”路线图的详细信息。
反馈与联系:
如果遇到问题、设置过程有困惑,或者有希望优先看到的PostgreSQL改进,欢迎在GitHub上提交Issue。联系方式包括邮件、Discord和邮件列表。
许可证:
pgrust采用AGPL-3.0许可证。
评论总结
以下是针对评论内容的总结,涵盖主要观点、论据及不同立场,并保留关键引用:
1. 对AI重写Postgres的质疑与批评
- 核心质疑:重写缺乏实际生产验证,仅依赖测试通过不可靠。
- “The things that make software like Postgres and SQLite reliable are not mostly the test, but the real world production scars.” (gingersnap)
- “Which one is safer? A new Postgres written in Rust, or the original real world tested Postgres?” (empiricus)
- 对动机的批评:认为项目仅为展示LLM能力,而非解决实际问题。
- “I really don’t understand why this is needed outside of an opportunity to show how impressive LLMs can be.” (cyberjar)
- “Rewritten in Rust is becoming a meme now.” (grugdev42)
- 对代码质量的担忧:指出Rust重写中存在大量
unsafe块,可能引入新漏洞。- “Why does a single 2000-line file have over 100 unsafe blocks? Why is the parser unsafe at all?” (evil-olive)
2. 对重写项目的支持与乐观
- 技术潜力:认为Rust重写可提升内存安全性和性能。
- “Personally I do want to see libraries be in as much memory safe languages as possible.” (satvikpendem)
- “I think we will actually see some successful projects coming out of this.” (theplumber)
- 学习与探索价值:视其为实验性项目,有助于推动技术发展。
- “I find these projects interesting for learning purposes and exploring new ways.” (josefrichter)
- 作者回应:声称新版本已通过100%回归测试,且性能显著提升。
- “Passes 100% of Postgres regression suite… Is 50% faster on transaction workloads, ~300x faster on analytical workloads.” (malisper)
3. 对Rust生态与重写趋势的反思
- 批评Rust社区:认为“重写为Rust”已成为一种教条主义。
- “All these ‘rewritten in rust’ projects only reinforce the idea that a significant part of the rust community consists of software talibans.” (ottavio)
- 呼吁原创性:建议Rust应解决新问题,而非重复造轮子。
- “Rust and its ecosystem needs to become more original… Existing solutions that already work don’t have to be rewritten in Rust.” (melodyogonna)
4. 对项目可持续性与实用性的疑问
- 长期维护:质疑项目能否获得社区支持并持续发展。
- “Code is not the same as a viable open-source project with a community, contributors, advocates, users and funding.” (flanked-evergl)
- 商业价值:缺乏明确的使用场景或业务需求。
- “Why do I use this instead of the official build? What is the business case?” (pknerd)
5. 对LLM重写方法的讨论
- 测试与过拟合风险:LLM可能过度依赖测试用例,忽略整体行为。
- “LLM’s ability to handle a big wall of if-conditions can backfire if it starts taking shortcuts and taking the tests-as-a-spec too literally.” (gnull)
- 代码审查困难:AI生成的代码难以通过传统方式(如提交历史)审查。
- “How would one go about reviewing a piece of code like this? … With LLMs generating 7101 commits in less than a month that isn’t feasible.” (dirkc)
总结
评论呈现两极分化:一方质疑AI重写缺乏生产验证、动机不纯,且代码质量存疑;另一方则认可其技术潜力、学习价值,并期待性能提升。核心争议点包括:测试通过是否等同于可靠性、Rust重写的实际必要性,以及LLM生成代码的可维护性。作者(malisper)的回应试图以性能数据回应质疑,但未完全消除对长期可持续性的担忧。