# 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.

Source: https://fullbytedeveloper.com/blog/fast-anything-port-hot-paths
Published here: 2026-11-26

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](/blog/craft-anything-clean-room-rebuild), [Constrain AI coding agent scope](/blog/constrain-ai-coding-agent-scope), [How Anthropic verified its Rust rewrite of the Messages API](/blog/anthropic-rust-rewrite-messages-api) and [rederive: defend AI-built code by redesigning it](/blog/rederive-ai-code-design-skill). Browse the [Dev tools topic](https://fullbytedeveloper.com/blog/topic/dev-tools).

## 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):

| app | before | after |
|---|---|---|
| Python fuzzy dedupe (700 names) | 4.91s | 42ms (116x) |
| TypeScript fuzzy dedupe (2,000 names) | 3.11s | 155ms (20x) |
| PHP fuzzy dedupe (600 names) | 2.94s | 53ms (55x) |
| Go fuzzy dedupe (3,000 names) | 3.02s | 144ms (21x) |
| Ruby fuzzy dedupe (400 names) | 3.13s | 228ms (14x) |
| C# fuzzy dedupe (4,000 names) | 4.03s | 312ms (13x) |
| Java fuzzy dedupe (4,000 names) | 3.50s | 1.18s (3x; 11x on the function, rest JVM startup) |
| C mandelbrot (8 zoom levels) | 431ms | 127ms (3.4x) |
| C++ fuzzy dedupe (6,000 names) | 3.02s | 1.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.

## Sources

1. [EL4CTEO/fast-anything README](https://github.com/EL4CTEO/fast-anything)
2. [npm package @el4cteo/fast-anything](https://www.npmjs.com/package/@el4cteo/fast-anything)
