EL4CTEO/fast-anything找出程序里最慢的几段代码,用 AI 改写成 Rust,跑得更快
很多人想给程序提速,第一反应是整个用 Rust 重写一遍,结果要花好几个月,编译一次要等好几分钟,硬盘还被占满。其实大部分时间只耗在少数几个函数上。fast-anything 就是帮你找出这几个拖后腿的函数,只把它们改写成 Rust,其余代码原封不动。
用法很直接:先扫描你的程序,按耗时和改写难度给函数排个队;再挑一个函数,录下它真实运行时的调用数据,交给你的 AI 编程助手写成 Rust;然后自动回放这些调用,逐条比对结果是否一致。全部对得上才启用,随时可以一键关掉,代码改动只有一个标记块,删得干干净净。
在 Windows 11 的 i5-10500 上,对 700 个名字做模糊去重,从 4.91 秒降到 42 毫秒,约 116 倍。
同样环境下对 2000 个名字做模糊去重,从 3.11 秒降到 155 毫秒,约 20 倍。
对 400 个名字做模糊去重,从 3.13 秒降到 228 毫秒,约 14 倍。
C 语言画曼德博集合 8 个缩放级别,从 431 毫秒降到 127 毫秒,约 3.4 倍。
案例来自项目官方说明里举的例子和演示,不是本站编的。
用之前要准备:需要本机装好 Rust 工具链;想用 AI 自动改写的话,还要有 Claude、Codex 或类似的编程助手
下载链接直接指向 GitHub 官方发布页的文件,不经过本站。国内下载 GitHub 文件可能偏慢。
也可以用命令装:
npm i -g @el4cteo/fast-anything # or: cargo install fast-anything 命令原样摘自项目官方说明,本站没有改动。
随便用、随便改,也能用在公司产品里,只要保留原作者的版权声明。
以上是对许可证的通俗解释,不是法律意见;正式商用以官方仓库的 LICENSE 文件为准。
项目本身是 MIT 许可证开源的,可以免费使用。但它要配合 AI 编程助手来改写代码,那部分是否收费取决于你用的助手。
说明里没有提到界面语言,只列出了支持的编程语言和用法,没有说支持中文界面。
可以。安装包覆盖 Windows、Mac 和 Linux,示例结果也是在 Windows 11 上跑出来的。
说明里没有讲数据上传的事。改写由你选择的 AI 编程助手完成,是否联网取决于那个助手。
可以随时停用,原代码一直没动,改动能逐字节还原;也可以用环境变量强制跑原版。
下面是海外开发者在 Hacker News(国外程序员常去的技术论坛)上讨论这个项目的真实评论,按讨论热度挑选,中文由 AI 翻译,点「看原文」可以对照英文。
Better yet, stop writing large codebases in lenguajes that will have performance troubles.
What does %LANGUAGE% have anything to do with the goal? Totally same principles apply for any other lower level language: Zig, C. While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling. Update: like I said, Rust is awesome and has so many advantages over C it's not worth a discussion really. But again I see that many projects are choosing Rust not because of merits but simply because it's a fashion.
neat, but in my experience bottlenecks that you could solve this way are low hanging fruits and optimized away quickly. the true performance hog is like sand, spread across the system, a little bit in every place.
I dont get the point of this. Developers rewrite code in rust for memory safety, not speed.
Hah, pretty neat! I recently discovered that one can apparently distribute Rust projects on npm by compiling to wasm. action-validator used to do this. Had been thinking about something like this.
We took this route in a Python web framework I maintain: route matching, JSON encoding, request body parsing, compression and some other specific parts moved to Rust with PyO3, everything else stayed in Python.
数据来自 GitHub,本站每周核对一次,最近核对于 2026-11-22。