deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

fast-anything finds slow code and lets coding agents port just that 5% to Rust

A new MIT-licensed tool profiles an app, records real calls to its hottest functions, and has a coding agent port only those to Rust — activating a port only after it matches the original's behavior.

fast-anything finds slow code and lets coding agents port just that 5% to Rust

A new open-source command-line tool called fast-anything reached the Hacker News front page on 22 November with a pointed pitch: instead of rewriting an entire application in Rust, rewrite only the small fraction of code where the runtime actually goes. According to the project's GitHub repository, the tool profiles an existing app, hands the hottest functions to an AI coding agent to port, checks that the ports behave identically to the originals, and swaps them in — reversibly.

How the workflow runs

After installing through npm or cargo, a single command such as fast-anything go --agent claude -- python app.py runs the whole loop. According to the README, the pipeline breaks into steps: scan profiles the app and ranks functions by a mix of time spent and how portable they are; port records up to 500 real calls to a chosen function and generates a one-function Rust crate plus a TASK.md brief; verify builds the port in release mode and replays every recorded call; enable and disable swap the Rust version in and out through a single marked block that restores the original code exactly when removed; bench interleaves timing runs of the original and the port; and report produces a markdown summary and an SVG card for a pull request.

The --agent flag accepts claude, codex, or any command that reads a prompt from stdin. The project also ships a Claude Code plugin, a built-in MCP server exposing eight tools such as fast_scan and fast_verify, and a skill file that teaches the loop to any agent. Without an agent, the generated TASK.md can simply be handed to whatever system you prefer.

Equivalence is enforced, not assumed

The README's central argument is that a port should be proven against behavior, not judged by reading the diff. On top of the recorded calls, the tool derives extra cases and lets the original implementation answer them: edge values such as NaN, positive and negative infinity, negative zero, non-ASCII text, and empty or much larger inputs. A port is enabled only when every case matches — floats agreeing within 1e-9 and errors appearing exactly where the original errors. A port that is correct but slower per call than the original is rejected too, since crossing into Rust can cost more than the work saved. The README cites one port that looked fine but compared bytes instead of characters, a bug caught by 148 of the 500 recorded calls. An environment variable forces the original code at any time.

A second design decision is granularity. The tool ports the outermost loop it can rather than the tiny helper inside it, so the application crosses into Rust once instead of millions of times. The README reports a case where that choice separated a 35x speedup from a 1.9x one.

The numbers, with caveats

The project publishes before-and-after figures from its own examples directory, measured on an i5-10500 running Windows 11, with the C and C++ runs on a four-core GitHub Actions Linux runner. Reported gains include a Python fuzzy-dedupe script dropping from 4.91 seconds to 42 milliseconds, a 116x improvement; TypeScript at 20x, PHP at 55x, Go at 21x and Ruby at 14x on similar dedupe workloads; a Java example at 3x end to end, or 11x on the function itself, with JVM startup accounting for the rest; and C and C++ examples at 3.4x and 2.7x. These are the author's own benchmarks on small, CPU-bound demo programs rather than independent tests of real applications.

Scope and limits

Support covers Python 3.10+ through PyO3 and Node 22+ through napi-rs, while Ruby, Java, Go, PHP, C and C++ all use a single C bridge that passes JSON back and forth with no headers or extra bindings — which, the README notes, means any language able to call C could adopt it. The eligible surface is narrow by design: top-level, deterministic functions taking plain data such as numbers, strings, lists and dicts. Stateful or I/O-heavy code does not qualify, and scan explains why a given function cannot move. Each port is a one-function crate compiled with the user's own rustup toolchain and shares one cache directory, which the project says keeps builds down to seconds. The tool is MIT-licensed.

Why it matters

The notable idea here is less about Rust than about verification-gated AI refactoring. Agent-written ports are trusted not because the code looks right but because a harness records real behavior and refuses to activate anything that deviates from it — differential testing applied to LLM output, with a kill switch built in. It also turns the familiar observation that a few functions hold most of the runtime into a concrete, reversible, per-function workflow. The caveats are real: self-reported benchmarks, synthetic workloads and a pure-function-only scope mean many I/O-bound applications will see little benefit. But as a template for letting coding agents touch production code inside hard behavioral guardrails, fast-anything is worth attention.

  • #rust
  • #performance
  • #ai-agents
  • #open-source
  • #developer-tools

Related posts