GitHub 上的新仓库 EL4CTEO/fast-anything,创建 1 天,已有 1259 星(平均每天 1193 星)。
不要把它用 Rust 重写。重写那 5% 的慢速部分:对 Python、Node 或 Ruby 应用进行性能分析,使用你的编码代理将热点函数移植到 Rust,证明它们的行为一致。
主题:agent-skills, ai-agents, claude-code, claude-code-plugin, codex, developer-tools, ffi, mcp, mcp-server, napi-rs, nodejs, optimization, performance, profiler, pyo3, python, rewrite-it-in-rust, ruby, rust, typescript
语言:Rust
README:
不要把它用 Rust 重写。重写那 5% 的慢速部分。
将整个应用用 Rust 重写需要数月时间、分钟级的编译时间和千兆字节的 target/ 目录。实际上,大部分运行时间都集中在少数几个函数中。
fast-anything 会找到这些函数,让你的编码代理仅将它们移植到 Rust,证明移植后的代码在真实记录调用下产生相同的结果,并进行替换。一条命令完成,完全可逆。
安装
npm i -g @el4cteo/fast-anything # 或者:cargo install fast-anything
端口通过你的 Rust 工具链(rustup)进行编译。
使用
fast-anything go --agent claude -- python app.py # 或者:-- node app.ts / ruby app.rb / java App.java / mvn exec:java / gradle run / go run . / php app.php / clang -O2 main.c
或者逐步执行:
| 命令 |
作用 |
scan -- |
对应用进行性能分析,按时间 × 可移植性对函数进行排名 |
port [id] |
记录最多 500 次真实调用,创建一个单函数 Rust crate + TASK.md |
verify |
发布构建端口并重放所有记录的调用 |
enable / disable |
切换 Rust 的启用或禁用状态(一个标记块,逐字节移除) |
bench |
对整个应用进行计时,原始版本与 Rust 版本交替运行 |
report |
为你的 PR 生成 markdown + SVG 卡片 |
doctor |
检查 Rust、你的运行时和代理 |
--agent 接受 claude、codex,或任何从 stdin 读取提示的命令。如果不提供它,手动将 TASK.md 交给你所使用的工具即可。
证明,而非感觉
那个端口看起来正确,但比较的是字节而不是字符。500 次真实调用中有 148 次发现了这个问题。除了记录的调用外,fast-anything 还会推导额外的案例并让原始代码回答它们:边界情况(NaN、±无穷大、-0.0、零和 ±1、非 ASCII 文本、空输入以及最大 16 倍大的输入)和缩小输入(微小和随机切片)。在所有情况下匹配之前不会启用任何内容:相同的值(浮点数误差在 1e-9 以内),错误时原始代码报错。如果每次调用的速度比原始代码慢(调用 Rust 的成本高于节省的工作量),也不会启用该端口。FAST_ANYTHING_DISABLE=1 始终运行原始代码。
结果
在 i5-10500、Windows 11(C 和 C++:4 核 GitHub Actions Linux 运行器)上的真实运行。从 examples/ 复现它们。
| 应用 |
之前 |
之后 |
| Python 模糊去重(700 个名称) |
4.91s |
42ms, 116× |
| TypeScript 模糊去重(2,000 个名称) |
3.11s |
155ms, 20× |
| PHP 模糊去重(600 个名称) |
2.94s |
53ms, 55× |
| Go 模糊去重(3,000 个名称) |
3.02s |
144ms, 21× |
| Ruby 模糊去重(400 个名称) |
3.13s |
228ms, 14× |
| C# 模糊去重(4,000 个名称) |
4.03s |
312ms, 13× |
| Java 模糊去重(4,000 个名称) |
3.50s |
1.18s, 3×(函数内提升 11 倍;其余为 JVM 启动时间) |
| C mandelbrot(8 个缩放级别) |
431ms |
127ms, 3.4× |
| C++ 模糊去重(6,000 个名称) |
3.02s |
1.09s, 2.7× |
fast-anything 移植它能找到的最外层循环,而不是内部调用的微小函数,因此应用只进入 Rust 一次而不是数百万次。仅移植内部的 levenshtein 函数得到了 35 倍和 1.9 倍的提升。
为什么不全部重写?
- 编译时间:每个端口都是一个单函数 crate。秒级,而非分钟级。
- 缓存:每个端口共享一个
.fast/target。随时可以删除它。
- 风险:你的代码保持不变。Rust 是按函数选择的,并根据实际行为进行检查。
代理
- Claude Code 插件:
/plugin marketplace add EL4CTEO/fast-anything,然后 /plugin install fast-anything@fast-anything 和 /fast-anything:fast python app.py
- MCP 服务器(Claude Code、Codex、Cursor…),内置于二进制文件中:
claude mcp add fast-anything -- fast-anything mcp。8 个工具:fast_scan、fast_port、fast_verify、fast_enable、fast_disable、fast_bench、fast_report、fast_status。
- 技能:
skills/fast-anything 教给任何代理这个循环。
语言
| 语言 |
绑定 |
状态 |
| Python 3.10+ |
PyO3 |
✅ |
| JavaScript / TypeScript (Node 22+) |
napi-rs |
✅ |
| Ruby 3.3+ |
C ABI + JSON,通过 Ruby 内置的 Fiddle |
✅ |
Java 22+ (java App.java, Maven, Gradle) |
相同的 C 桥接,通过 FF |
|
查看原文
GitHub 上的新仓库 EL4CTEO/fast-anything,创建 1 天,已有 1259 星(平均每天 1193 星)。
Don't rewrite it in Rust. Rewrite the 5% that's slow: profile Python, Node or Ruby apps, port the hot functions with your coding agent, prove they behave the same.
主题:agent-skills, ai-agents, claude-code, claude-code-plugin, codex, developer-tools, ffi, mcp, mcp-server, napi-rs, nodejs, optimization, performance, profiler, pyo3, python, rewrite-it-in-rust, ruby, rust, typescript
语言:Rust
README:
Don't rewrite it in Rust. Rewrite the 5% that's slow.
Rewriting a whole app in Rust costs months, minute-long compiles and gigabytes of target/. Most of the runtime sits in a few functions anyway.
fast-anything finds those functions, has your coding agent port only them to Rust, proves the port gives the same results on real recorded calls, and swaps it in. One command, fully reversible.
Install
npm i -g @el4cteo/fast-anything # or: cargo install fast-anything
Ports are compiled with your Rust toolchain (rustup).
Use
fast-anything go --agent claude -- python app.py # or: -- node app.ts / ruby app.rb / java App.java / mvn exec:java / gradle run / go run . / php app.php / clang -O2 main.c
Or step by step:
| command |
what it does |
scan -- |
profiles the app, ranks functions by time × how portable they are |
port [id] |
records up to 500 real calls, creates a one-function Rust crate + TASK.md |
verify |
release-builds the port and replays every recorded call |
enable / disable |
swaps the Rust in or out (one marked block, removed byte for byte) |
bench |
times the whole app, original vs Rust, interleaved runs |
report |
markdown + SVG card for your PR |
doctor |
checks Rust, your runtimes and your agents |
--agent takes claude, codex, or any command that reads a prompt on stdin. Without it, hand TASK.md to whatever you use.
Proof, not vibes
That port looked right but compared bytes instead of characters. 148 of 500 real calls caught it. On top of the recorded calls, fast-anything derives extra cases and lets the original answer them: edge cases (NaN, ±infinity, -0.0, zero and ±1, non-ASCII text, empty and up to 16× bigger inputs) and shrunk inputs (tiny and random slices). Nothing is enabled until every case matches: same values (floats within 1e-9), errors where the original errors. A port that is right but slower per call than the original (calling into Rust costs more than the work saved) isn't enabled either. FAST_ANYTHING_DISABLE=1 runs the original any time.
Results
Real runs on an i5-10500, Windows 11 (C and C++: a 4-core GitHub Actions Linux runner). Reproduce them from examples/.
| app |
before |
after |
| Python fuzzy dedupe (700 names) |
4.91s |
42ms, 116× |
| TypeScript fuzzy dedupe (2,000 names) |
3.11s |
155ms, 20× |
| PHP fuzzy dedupe (600 names) |
2.94s |
53ms, 55× |
| Go fuzzy dedupe (3,000 names) |
3.02s |
144ms, 21× |
| Ruby fuzzy dedupe (400 names) |
3.13s |
228ms, 14× |
| C# fuzzy dedupe (4,000 names) |
4.03s |
312ms, 13× |
| Java fuzzy dedupe (4,000 names) |
3.50s |
1.18s, 3× (11× on the function; the rest is JVM startup) |
| C mandelbrot (8 zoom levels) |
431ms |
127ms, 3.4× |
| C++ fuzzy dedupe (6,000 names) |
3.02s |
1.09s, 2.7× |
fast-anything ports the outermost loop it can, not the tiny function called inside it, so the app crosses into Rust once instead of millions of times. Porting only the inner levenshtein gave 35× and 1.9×.
Why not rewrite it all?
- Compile time: each port is a one-function crate. Seconds, not minutes.
- Cache: every port shares one
.fast/target. Delete it whenever you like.
- Risk: your code stays as it is. Rust is opt-in per function, checked against real behavior.
Agents
- Claude Code plugin:
/plugin marketplace add EL4CTEO/fast-anything, then /plugin install fast-anything@fast-anything and /fast-anything:fast python app.py
- MCP server (Claude Code, Codex, Cursor…), built into the binary:
claude mcp add fast-anything -- fast-anything mcp. 8 tools: fast_scan, fast_port, fast_verify, fast_enable, fast_disable, fast_bench, fast_report, fast_status.
- Skill:
skills/fast-anything teaches any agent the loop.
Languages
| language |
binding |
status |
| Python 3.10+ |
PyO3 |
✅ |
| JavaScript / TypeScript (Node 22+) |
napi-rs |
✅ |
| Ruby 3.3+ |
C ABI + JSON, through Ruby's built-in Fiddle |
✅ |
Java 22+ (java App.java, Maven, Gradle) |
the same C bridge, through the FF |
|
原文版权归 GitHub 爆发仓库 及原作者所有,本站转载仅供阅读。如需删除,请联系 support@aisa.one。