Full Byte Developer.

Port the hot 5% with fast-anything

Use fast-anything to profile, port one hot function to Rust, verify on recorded calls, then enable only if it matches.

Published here · 2 sources

A full Rust rewrite buys months of compile time for code that was never on the hot path. fast-anything profiles the app, ports only ranked functions to Rust, verifies on recorded calls, and enables the port only when results match. License: MIT. [1]

Related reading: Craft Anything clean-room rebuild, Constrain AI coding agent scope, How Anthropic verified its Rust rewrite of the Messages API and rederive: defend AI-built code by redesigning it. Browse the Dev tools topic.

Install the CLI and a Rust toolchain

bash
npm i -g @el4cteo/fast-anything

The README also lists cargo install fast-anything. Ports compile with your Rust toolchain via rustup. [1][2]

You should see a fast-anything binary on your PATH before you profile anything. [1]

Profile, port, verify, then enable

One-shot form from the README:

bash
fast-anything go --agent claude -- python app.py

The stepped flow: scan ranks functions by time and portability; port records up to 500 real calls and creates a one-function Rust crate plus TASK.md; verify release-builds and replays every recorded call; enable / disable swaps the Rust block in or out; bench times original vs Rust with an A/A control; report writes a PR card; doctor checks Rust, runtimes and agents. [1]

--agent accepts claude, codex, or any command that reads a prompt on stdin. Without it, give TASK.md to your usual agent. [1]

Read the proof rules before you trust a speedup

Verify replays recorded calls and derived edge cases (NaN, infinities, -0.0, empty and larger inputs, non-ASCII text). Nothing enables until values match (floats within 1e-9 of their size or of the largest value in the same list, with -0.0 kept distinct from 0.0) and errors match. A correct but slower-per-call port is refused. Every 5th recorded call (from 5 calls up) is held out of the agent's crate folder so a port that special-cases only the shown calls still fails. FAST_ANYTHING_DISABLE=1 forces the original path. [1]

The README's verify demo caught a port that compared bytes instead of characters: 148 of 500 real calls failed. That is the point of recorded calls over vibes. If verify fails, fix the Rust or pick a different function; do not force enable. [1]

Author-reported example benches on the README (i5-10500, Windows 11; C and C++ on a 4-core GitHub Actions Linux runner):

appbeforeafter
Python fuzzy dedupe (700 names)4.91s42ms (116x)
TypeScript fuzzy dedupe (2,000 names)3.11s155ms (20x)
PHP fuzzy dedupe (600 names)2.94s53ms (55x)
Go fuzzy dedupe (3,000 names)3.02s144ms (21x)
Ruby fuzzy dedupe (400 names)3.13s228ms (14x)
C# fuzzy dedupe (4,000 names)4.03s312ms (13x)
Java fuzzy dedupe (4,000 names)3.50s1.18s (3x; 11x on the function, rest JVM startup)
C mandelbrot (8 zoom levels)431ms127ms (3.4x)
C++ fuzzy dedupe (6,000 names)3.02s1.09s (2.7x)

Those are the author's measured examples from examples/, not a promise for your app. Reproduce from that folder when you need your own numbers. The README also notes that porting only an inner levenshtein gave 35x and 1.9x, while porting the outermost loop the tool can move avoids millions of crossings into Rust. [1]

When not to port

Skip fast-anything (or stop after scan) when any of these hold:

  1. The hot work is not a top-level deterministic function on plain data. scan explains why something cannot move yet. [1]
  2. The cost is JVM or process startup, not the function body (see the Java row above). [1]
  3. The candidate is a tiny inner helper called millions of times; prefer the outermost portable loop. [1]
  4. A verify pass matches values but loses on per-call time. Enable refuses that port. [1]
  5. You need a whole-app rewrite for packaging or ABI reasons. This tool keeps the original code and swaps one marked block. [1]

Supported language bindings and server-scan duration flags are listed in the README language table (Python 3.10+, Node 22+ / Bun / Deno 2+, Ruby 3.3+, Java 22+, Go 1.22+, PHP 8.1+, C/C++, C# / .NET 8+, R 4.0+, and more). Read that table before you assume your runtime is covered. [1]

For long-running servers and GUIs, the README documents scan --duration 30 (stops them like Ctrl+C, or process.exit on Node). Run doctor before the first port so Rust, the runtime and the agent binary are present. Each port is a one-function crate sharing one .fast/target cache; fast-anything clean deletes that cache when you want a fresh compile. [1]

Plugin and MCP wiring (optional): install the CLI first, then add the marketplace for Codex or Claude Code, or claude mcp add fast-anything -- fast-anything mcp for eight tools (fast_scan through fast_status). Without an agent flag, hand TASK.md to whatever you already use. [1]

Your next run should stop at verify until every case matches, then enable only once.

Send this to the teammate who opened a rewrite-it-all-in-Rust ticket before measuring which function burned the time.

Keep this guide

By Full Byte Developer

Filed under Dev tools, AI agents

Questions about this guide

What is fast-anything?

An MIT tool (npm @el4cteo/fast-anything, crates.io fast-anything) that profiles an app, ports only the slow functions to Rust with a coding agent, verifies on recorded calls, and swaps the port in. Fully reversible.

Does it rewrite the whole app in Rust?

No. The README pitch is to rewrite the slow slice, not the whole app. Ports are one-function Rust crates with a TASK.md for the agent.

When does enable refuse a port?

Per the README: nothing is enabled until every recorded and derived case matches the original (values and errors). A port that is right but slower per call than the original is also not enabled.

Which agents can drive the port step?

The README says --agent takes claude, codex, or any command that reads a prompt on stdin. Without --agent, hand TASK.md to whatever you use.

Sources

Next in this stack