fast-anything Selective Rust Acceleration and Behavior Equivalence

Document type
Field manual
Updated
Reading time
9 min

Reference manual for EL4CTEO/fast-anything v0.8.5 covering profiling, 500-call recording, synthetic edge-case replay verification, 12-language bridges, CLI subcommands, and the built-in MCP server.

Source
Document details
EL4CTEO/fast-anything
License
MIT

A profiler and selective Rust porting tool that identifies slow pure functions, hands them to an AI coding agent, verifies behavior against recorded and edge cases, and swaps them in reversibly.

Supported languages
12Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R
Default recorded calls
500Real calls plus derived edge and shrunk cases
Built-in MCP tools
8stdio JSON-RPC 2.0 (protocol 2025-06-18)
Peak benchmark speedup
116xPython fuzzy dedupe 4.91s down to 42ms

01Scope and Deliverables

System Overview

EL4CTEO/fast-anything (current version v0.8.5, MIT License) is a Rust CLI tool, Claude Code plugin, and built-in MCP server. It profiles application bottlenecks, records real inputs and outputs, delegates porting of individual hot functions to standalone Rust crates via a coding agent, and swaps verified ports into place using a single reversible marked block.

Each ported function lives in a one-function crate sharing a single .fast/target build cache, keeping compile times to seconds. You can delete the cache at any time or set FAST_ANYTHING_DISABLE=1 to run the original implementation. The tool targets the outermost portable loop to minimize cross-language boundary crossings.

Per README.md and src/doctor.rs, v0.8.5 supports 12 languages and their corresponding bridges:

Language and minimum versionRun command examplesBridge and profiler
Python 3.10+python app.py, uv run, poetry runPyO3; supports @staticmethod, dataclasses, NamedTuples, numeric NumPy arrays, and multiprocessing.Pool
JavaScript / TypeScript (Node 22+, Bun 1+, Deno 2+)node app.ts, bun app.ts, deno run -A app.tsnapi-rs; supports worker_threads, static methods, Buffer, typed arrays, and Set<string>
Ruby 3.3+ruby app.rbC ABI + JSON via built-in Fiddle; no headers required
Java 22+java App.java, mvn exec:java, gradle runC bridge via the Java FFM API
Kotlin / JVM (JDK 22+, Gradle)gradle run (src/main/kotlin)Shared Java bridge; top-level functions, object, companion, and extension functions
Go 1.22+go run .C bridge via the Windows loader or dlopen (cgo)
PHP 8.1+php app.phpC bridge via PHP's FFI extension (extension=ffi required)
C / C++ (gcc, clang, Intel oneAPI icx/icpx)clang -O2 main.c lib.cC bridge via LoadLibrary or dlopen; -fsycl profiles and ports host functions only
C# / .NET 8+dotnet run -c ReleaseC bridge via NativeLibrary; profiled with EventPipe
R 4.0+Rscript app.RC bridge via base R's .C(); profiled with Rprof, no packages or R headers required

02Environment and Setup

Installation and Prerequisites

Running fast-anything requires a local Rust toolchain and the target language runtime. Cargo.toml specifies Rust 1.88 (edition 2024) for building the binary, while doctor checks for cargo 1.85 or newer for compiling ported crates.

  • Not completed:

    Rust toolchain (required): Install cargo via rustup (1.85+ for ports; 1.88+ to build from source).

  • Not completed:

    Target language runtime (project-dependent): Meet the minimum version in the table above; enable extension=ffi in php.ini for PHP; run from a setvars.bat shell on Windows for Intel oneAPI.

  • Not completed:

    AI coding agent (optional): Supports claude, codex, or any CLI command reading a prompt on stdin; without --agent, pass .fast/ports/<id>/TASK.md manually to any tool.

Install globally via npm or Cargo, then run doctor to inspect your environment:

bash
# Install via npm or Cargo
npm i -g @el4cteo/fast-anything
cargo install fast-anything

# Check Rust, language runtimes, and available agents
fast-anything doctor

For editor and agent integration, the repository ships both a Claude Code plugin and a built-in MCP server:

bash
# 1. Claude Code plugin (run inside Claude Code)
/plugin marketplace add EL4CTEO/fast-anything
/plugin install fast-anything@fast-anything

# 2. Built-in MCP server (Claude Code, Codex, Cursor, and others)
claude mcp add fast-anything -- fast-anything mcp

03CLI Subcommands and Agent Interface

Core Commands and MCP Tools

fast-anything provides a unified CLI (with a global -C / --dir flag for target project folders) and exposes 8 matching tools with progress notifications over stdio JSON-RPC 2.0 via fast-anything mcp.

End-to-end

fast-anything go --agent <name> -- <cmd>

Profile, port, verify, enable, and benchmark in one command

Runs the full pipeline with --top (default 1), --attempts (default 3), --runs (default 5), and --samples (default 500), retaining the best verified attempt across retries.

Profiling

fast-anything scan -- <cmd> / fast_scan

Profile runtime and rank functions by portability

Runs a representative workload, scores functions by time share and portability, reports I/O or nondeterminism blockers, and skips functions below 2% share.

Recording

fast-anything port [id] / fast_port

Record real calls and scaffold a one-function Rust crate

Re-runs the app to capture up to 500 calls into .fast/ports/<id>/recordings.jsonl and generates the crate stub plus TASK.md; pass --agent to delegate immediately.

Verification

fast-anything verify [id] [--all] / fast_verify

Release-build and replay real plus derived cases

Replays every recorded call, synthetic edge case, and shrunk input; floats must match within 1e-9, errors must match type, and per-call runtime must beat the original.

Toggle

fast-anything enable / disable [id] [--all]

Swap the verified Rust port in or out

enable requires Rust sources matching the last passing verify (or --force); disable removes the marked block byte for byte and fails if a marker is missing.

Benchmarking

fast-anything bench [--runs 5] / fast_bench

Interleaved end-to-end timing: original vs Rust

Runs 5 interleaved iterations by default to measure whole-app speedup and warns if program output differs with Rust ports enabled.

Reporting

fast-anything report / status / build

Generate PR cards, inspect state, and rebuild ports

report writes .fast/report.md and .fast/report.svg; status prints the last scan and every port; build recompiles all ports after cloning or toolchain upgrades.

Diagnostics

fast-anything doctor / mcp

Verify local runtimes and start the MCP server

doctor checks cargo, minimum runtime versions, PHP FFI, and agents; mcp serves fast_scan through fast_status (8 tools) over stdio.

04Equivalence Proof and Performance Principles

Verification Guarantees and Authoring Rules

fast-anything enforces behavioral equivalence and measured per-call speedup before enabling any port. Key rules from README.md, skills/fast-anything/SKILL.md, and src/agent.rs:

Combine recorded calls with synthetic edge and shrunk cases

verify replays up to 500 recorded calls plus derived cases covering NaN, ±infinity, -0.0, 0, ±1, non-ASCII text, empty inputs, inputs up to 16 times larger, and shrunk slices, using the original function as the oracle. Every case must match (floats within 1e-9, identical error types) and per-call speed must beat the original before enable succeeds.

README.md

Port the outermost portable loop to amortize FFI overhead

Crossing PyO3 or FFI boundaries carries per-call cost. Targeting the outermost portable function crosses into Rust once instead of millions of times; official benchmarks showed inner levenshtein ports yielding 35x and 1.9x versus 116x and 20x for the outer loop.

README.md

Preserve original functions and recordings; match language semantics

Leave the original function body untouched (the appended marked block performs the swap) and never edit recordings.jsonl. Match Unicode semantics (.chars() for Python, UTF-16 units for JavaScript), integer ranges, float operation order, and error paths; edit src/port.rs for Ruby, Java, Go, PHP, C/C++, C#, and R, or src/lib.rs for Python and JS/TS.

skills/fast-anything/SKILL.md

Profile representative workloads and skip functions under 2%

Run scan with a realistic application workload (avoid substituting the test suite). Functions under 2% of total runtime cannot produce visible gains; if pure compute is mixed with I/O or top-level script code, extract it into a standalone function or guard main execution before scanning.

skills/fast-anything/SKILL.md

Scoped agent presets and automatic speed retries

With --agent claude, fast-anything launches Claude Code with --permission-mode acceptEdits restricted to Read, Edit, Write, Glob, Grep, and cargo check/build/test/fmt; --agent codex runs codex exec --full-auto -. If a port passes correctness checks but runs slower per call than the original, go --agent sends it back for optimization and keeps the best correct attempt.

src/agent.rs / CHANGELOG.md

05Commands and Official Results

Workflow and Benchmark Example

Run either the single-command pipeline or individual subcommands to execute the same verification loop:

End-to-end acceleration and step-by-step verification
# One-command pipeline: scan, port with Claude, verify, enable, and benchmark
$ fast-anything go --agent claude -- python app.py
# Step-by-step execution
$ fast-anything scan -- python app.py
$ fast-anything port
$ fast-anything verify
ok: all recorded and derived cases matched
$ fast-anything enable
$ fast-anything bench
$ fast-anything report
# Bypass Rust ports for a single run, or disable all ports permanently
$ FAST_ANYTHING_DISABLE=1 python app.py
$ fast-anything disable --all

Published examples/ benchmarks from README.md (Intel i5-10500 on Windows 11; C and C++ on a 4-core GitHub Actions Linux runner):

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

06Portability Boundaries and Safety Checks

Limitations and Guardrails

07Further Reading

Next Steps and References

  1. Validate your local setup: Run fast-anything doctor after installation to confirm cargo, target language runtimes, and agent CLIs are ready.

  2. Test on a built-in example: Copy examples/fuzzy-dedupe/ or another language example from the repository and run fast-anything scan, port, verify, and bench to inspect .fast/report.md and .fast/report.svg.

  3. Wire into your agent workflow: Install the Claude Code plugin for /fast-anything:fast, or register claude mcp add fast-anything -- fast-anything mcp to expose all 8 MCP tools directly to your coding agent.

References