Fast-Anything: Don't rewrite it in Rust. Rewrite the 5% that's slow github.com ·...

@best30

Fast-Anything: Don't rewrite it in Rust. Rewrite the 5% that's slow github.com · 171 points · 136 comments · HN thread

TL;DR fast-anything is a tool that profiles an app (Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C, C++, C#), has a coding agent port only the hot outer function to Rust, verifies the port against recorded and derived real calls, and swaps it in reversibly. The README reports 2.7x to 116x speedups on fuzzy-dedupe and similar benchmarks, with the port enabled only when results match and the port is not slower per call.

  • Instead of rewriting a whole app, it ports only the few functions that dominate runtime, one function per one-function Rust crate, so compile times are seconds.
  • It records up to 500 real calls and derives edge cases (NaN, infinities, -0.0, non-ASCII, empty and 16x larger inputs) that the original answers, requiring matching values within 1e-9 before enabling.
  • A port is also rejected if calling into Rust costs more than the work it saves per call.
  • Reported benchmarks: Python fuzzy dedupe 4.91s to 42ms (116x), C# 13x, Go 21x, Java 3x overall (11x on the function), C++ 2.7x; porting only the inner levenshtein gave much less (35x and 1.9x).
  • Interfaces include a CLI (fast-anything go -- python app.py), a Claude Code plugin, and an MCP server with eight tools; ports are plain Rust libraries with a single C entry point except for Python (PyO3) and JS (napi-rs).
  • Ports only top-level deterministic functions taking plain data; SYCL kernels are not ported and scan explains why other functions cannot move.

Discussion The thread is a broad, somewhat skeptical debate that mostly drifts from the tool itself into whether rewriting slow code in Rust is worthwhile at all. Commenters trade stories about Python, Node and Java performance, Amdahl's law, scattered overhead versus true hotspots, and the costs of Rust compile times and FFI boundaries. Several question the benchmark framing, such as counting JVM startup and comparing against C# or Java alternatives, and a few call the README AI-generated or the Rust-rewrite trend fashionable. The mood is critical but technical, with many people sharing concrete experience rather than dismissing the idea outright.

  • Hotspot-only porting works for CPU-bound code, but it's narrow (many): Several commenters agree that moving a small hot part to a compiled language can yield big gains, especially in numeric or CPU-heavy Python. They add that most real programs are spread out, so the approach helps only a limited set of cases.
  • Most slowness is architecture, data structures and I/O, not language (many): A large group argues that algorithm choice, caching, query design, and data layout matter more than language choice. Examples include database bottlenecks and unnecessary distributed architecture.
  • Rewriting from scratch with performance in mind beats patching (some): One view holds that a rewrite with hindsight can make most codebases much faster even in the same language. Others note that uv's speed came mainly from removing dynamic behavior and improving I/O, not from Rust alone.
  • Rust's main value is safety and correctness, not speed (some): Commenters argue Rust's type system and borrow checker prevent whole classes of bugs, and that this matters more for AI-written code. Others counter that performance is a real reason as well.
  • Extra dependencies and FFI overhead add risk and complexity (some): Skeptics question why a maintainer would accept an opaque Rust dependency in a hot path when mature libraries like RapidFuzz exist, and note that FFI crossings can eat the gains.
  • Benchmarks and framing look weak or AI-generated (a few): Some comments question including JVM startup in Java timings, the choice of C and C++ rewritten into Rust, and the README's style. One person simply says the write-up looks AI-generated.
  • Personal experience: a port delivered large real-world gains (a few): A few commenters report big wins from porting Python pipelines or a Node app to Rust, with cost savings and lower memory use. Others report Rust compile times slowing their work.

Links from the comments

#Rust #Performance #Python #FFI #AIcoding #Profiling