1. Why fast-anything?
The repository went public on November 21, 2026, and collected 4,829 stars and 355 forks in eight days (as of writing). Its default branch has 255 commits, the version is 0.9.1, and the license is MIT. The README opens like this:
Most of an app's runtime sits in a few functions. fast-anything finds them, has your coding agent port only those to Rust, proves the port returns the same results on real recorded calls, and swaps it in.
It has the same shape as Craft Anything, the subject of the previous post: an agent builds something and a tool grades it against the original. Craft Anything compares screenshot pixels; fast-anything compares a function's inputs and outputs.
The README's results table says the Ruby example got 14× faster. Does that carry over to a Rails app? In this blog's Rails request-layer measurement, 70% of a list API request's CPU went to Active Record. This post reads fast-anything's Ruby backend and measures it on the core logic of a public game built with Rails to answer that question.
2. The one-sentence version
fast-anything is a CLI that lets an agent port one profiler-picked function to Rust, grades the port against calls recorded from real runs, and swaps it in only when it passes.
| Question | fast-anything's answer |
|---|---|
| What gets ported? | One top-level function, or one self. method on a module or class. It has to be deterministic and take and return only plain data: numbers, strings, arrays, maps. |
| Who writes the Rust? | A coding agent. --agent takes claude, codex, or any command that reads a prompt on stdin. |
| What does the tool do? | Measuring, recording, building, checking and swapping. In the skill's words: "The CLI measures, records, builds, checks and swaps. You write the Rust." |
| How does it know they match? | It replays calls recorded from a real run (up to 500 by default), plus edge cases derived from them, against the Rust port and compares the results. |
| What happens to the original? | Nothing. Swap code goes in at a fixed spot (for Ruby, the end of the file, or before the main guard in an entry script), and disable removes just that code. |
| Which languages? | Python, JavaScript/TypeScript, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R. Android apps are ranked but not ported. |
| How is it used? | As a CLI, an MCP server (fast-anything mcp), Claude Code and Codex plugins, and an agent skill. |
3. Repository layout and size
The tool itself is written in Rust: 22,759 lines under src/ with 193 #[test]s. Each language backend gets its own file.
| File | Lines | Role |
|---|---|---|
node.rs | 3,120 | JavaScript/TypeScript backend, napi-rs bindings |
cfamily.rs | 2,554 | C/C++ backend |
python.rs | 2,320 | Python backend, PyO3 bindings |
kotlin.rs | 1,139 | Kotlin/JVM backend |
pipeline.rs | 1,008 | The go flow and the enable gate |
java.rs | 867 | Java backend |
android.rs | 842 | Android backend that only ranks, via simpleperf |
golang.rs | 841 | Go backend |
native.rs | 818 | Glue generator shared by languages that call one C entry point |
backend.rs | 801 | Replay, hold-out, shared crate settings |
ruby.rs | 544 | Ruby backend, plus src/ruby/runner.rb (477) and recorder.rb (177) |
Python and JS/TS use native bindings; the other languages call a single C function in the Rust library. examples/ holds the same fuzzy-dedupe program in each language, which is where the README's results come from. Each example has a reference port (reference/lib.rs for Python and TS, reference/port.rs for the rest), a port of the kind a good agent would write, which CI uses to test the pipeline without an agent.
4. One function's journey
fast-anything go --agent claude -- ruby app.rb runs these steps in order and, once the port is on, writes a report too. Each step can also be run on its own.
| Step | What it does | When it fails |
|---|---|---|
scan | Runs the app under a profiler and judges each function's time and portability | Marks it ✗ with the reason |
port | Runs the app again, records real calls to the target, creates a Rust crate | Stops when no call with plain data was recorded |
| agent | Reads TASK.md and writes src/port.rs | |
verify | Builds in release mode and replays every recorded call and edge case | Shows the failing calls and the agent fixes them |
enable | Appends the swap block to the end of the original module | Stays off if the port is slower |
bench | Times the whole app against the original in alternating runs, with A/A noise |
The skill tells the agent to skip anything under 2% of the run, since porting it can't make a visible difference. port runs the app once more to record real calls to the target and creates a Rust crate and a TASK.md under .fast/ports/<id>/. TASK.md contains the original source, a few recorded calls and the rules to follow.
5. The checks
Hold-out. One in five recorded calls is never shown to the agent. The comment at src/backend.rs line 312 reads "Every 5th recorded call is held out.", and the condition is k % 5 == 4. When a held-out call fails, verify reports only that it failed, without its inputs or expected value (redact_held_out). This keeps the agent from looking at the answers and special-casing them.
Edge cases. edges in src/ruby/runner.rb builds inputs of the same type as each recorded value, picked where ports and originals tend to disagree.
| Recorded type | Inputs it tries |
|---|---|
| Integer | 0, 1, -1 |
| Float | NaN, Infinity, -Infinity, -0.0, 0.0, 1e308, 5e-324 |
| String | é in the middle, 日本 at the end, 👍🏽 at the start, a combining mark (e + U+0301), the empty string |
| Array | The empty array, the array with its first element swapped for an edge value |
Separately, derive_edges grows shortened arrays and strings 4×, 16× and so on, up to 4,096 items or characters, as long as the time budget allows. Of the newly made inputs, those the original raises on are dropped. The comment calls them "outside the function's domain: not a fair test". So whatever the original answers is the specification. Exceptions recorded from real calls are replayed, and they pass as long as the Rust side also returns an error; the exception's class and message aren't compared. Floats count as equal within 1e-9 of their size (or of the largest value in the same array), and -0.0 is kept distinct from 0.0.
The enable gate. By default enable checks four things: the original function's source saved at recording is still in the file, the port passed verify, its Rust hasn't changed since then (a crate hash), and it isn't slower per call than the original. A port that is right but slower stays off. There is also a rule against functions so cheap that a call takes about as long as reading the clock, but it only applies on backends that measure the clock cost, and the Ruby verifier doesn't record it. --force skips every gate.
// src/pipeline.rs
pub fn slower_hint() -> &'static str {
"calling into Rust costs more than this function's work, so it won't be switched on. \
Port its caller instead (fewer, bigger calls), or enable --force"
}
Despite the README's section title "Proof, not vibes", none of this is a mathematical proof. It is differential testing on recorded calls. Nothing guarantees that inputs outside the recorded calls and the edge and derived cases made from them give the same result.
6. How it plugs into Ruby
Profiling. scan runs the app under TracePoint.new(:call, :return), counting only method calls in files inside the project folder. It takes the top 40 by cumulative time and parses them with Prism to decide whether each can be ported. Because of Prism it needs Ruby 3.3 or newer. The Ruby 2.6 that ships with macOS is rejected at the resolve step, so these experiments used Homebrew's Ruby 4.0.6.
The criteria (describe) are below. Any one of them earns a ✗ with the reason.
- It's an instance method: "module functions and top-level methods only for now"
- It's a nested method, or it takes a block,
**options,..., an unnamed*or a destructured argument. - It calls
yieldorsuper, or writes instance, class or global variables. - It does I/O such as
puts,system, backticks,FileorNet::HTTP, or usesrand,TimeorRandom. - It lives in an entry script with no
if __FILE__ == $0guard.
The bridge. On the Ruby side there are no headers and no libclang: the built-in Fiddle calls fa_call, a C function in the Rust library. The argument array goes over as a JSON string, and {"ok": result} or {"error": message} comes back as JSON. Since JSON has no NaN or infinity, those travel tagged, as {"$float": "NaN"}.
The swap block. enable appends a block like this to the end of the file that defines the function (trimmed):
# Uses the verified Rust port. FAST_ANYTHING_DISABLE=1 runs the Ruby above instead.
unless ENV["FAST_ANYTHING_DISABLE"]
begin
require "fiddle"
require "json"
-> {
lib = Fiddle.dlopen(File.expand_path(".fast/lib/libfa_sweep_flood_reveal.dylib", __dir__))
call = Fiddle::Function.new(lib["fa_call"], ...)
Sweep.singleton_class.send(:define_method, :flood_reveal) do |*args, **kw|
values = instance_exec(*args, **kw, &bind) # bind arguments the way the original signature does
input = JSON.generate(values)
out = call.call(input, input.bytesize, size)
reply = JSON.parse(out[0, len].force_encoding(Encoding::UTF_8))
raise reply["error"] if reply.key?("error")
reply["ok"]
end
}.call
rescue LoadError, Fiddle::DLError
end
end
The original def stays where it is and define_method overrides it afterwards. If the library file is missing, the rescue passes silently and the original Ruby runs.
7. Running it on a Rails game
The subject is pdobb/minesweeper_alliance, a minesweeper where many people sweep one board together in real time, under the MIT license. It runs on Rails 8.1.4.1, Ruby 4.0.10, PostgreSQL and Solid Cable, Cache and Queue. app/ and lib/ hold 310 Ruby files, 12,852 lines.
The app asks for Ruby 4.0.10, but the experiments ran on the local 4.0.6. There was no local PostgreSQL, so the app itself wasn't booted. Instead, three things were done. fast-anything's classifier was run over every method in the app. The core game logic, the cascade reveal, was rebuilt without a database in the app's own structure and put through scan and port. Finally the same logic was rewritten as a function over plain data and taken all the way through a Rust port. The Rust was written by the Claude Code session writing this post, in place of --agent claude, which would bill the author's Claude account.
7.1 89% of 2,045 methods are instance methods
With only the dispatch lines cut from runner.rb, its describe function was applied unchanged to every def in app/ and lib/, counting the first ✗ reason.
| Verdict | Count | Share |
|---|---|---|
| ✗ instance method | 1,823 | 89.1% |
| ✓ portable | 146 | 7.1% |
✗ takes a block, **options or ... | 63 | 3.1% |
| ✗ writes instance, class or global variables | 6 | 0.3% |
| ✗ not deterministic | 4 | 0.2% |
✗ unnamed * argument, yield | 3 | 0.1% |
Most of the 146 ✓ aren't worth porting either. They include DOM id builders such as turbo_target, constants such as Emoji.mine, and database writes such as CellTransaction.create_between. The static check recognizes I/O only from a fixed list such as File, Net::HTTP and puts, not Active Record calls. Calls that pass Active Record objects are skipped at the next step, recording (7.2). A function that takes plain arguments and writes to the database still gets through, though.
The game's core algorithm is Game::Board::RecursiveReveal, which opens the surrounding cells one after another when you click a blank cell.
module Game::Board::RecursiveReveal
def self.call(cell)
unrevealed_neighboring_cells(cell).inject(Set.new) { |acc, neighboring_cell|
next acc unless (revealed_cell = Cell::SoftReveal.(neighboring_cell))
acc << revealed_cell.upsertable_attributes
acc |= call(revealed_cell) if Cell::State.blank?(revealed_cell)
acc
}
end
It's a module function, so it gets a ✓. But its argument cell is an Active Record object. And Cell::Neighbors, which finds the neighbors, calls the board's cells_at, which scans every cell on the board each time it looks for eight neighbors.
# app/models/board.rb
def cells_at(coordinates_set)
coordinates_set = Conversions.CoordinatesSet(coordinates_set)
cells.select { |cell| coordinates_set.include?(cell.coordinates) }
end
The whole-board neighbor lookup runs once for every newly opened cell (to count neighboring mines) and once more for each of those that is blank (to find unopened neighbors), so the cascade costs roughly the board's cell count times the number of cells opened.
7.2 Functions that take objects stop at recording
That structure was rebuilt without a database: coordinates as Data, cells as Struct, a cells_at that scans everything like the app's, and recursion that merges Sets. Struct is lighter than Active Record attribute access, so this reconstruction most likely costs less than the real app. Here is scan on it (30 boards, trimmed):
# function total self calls verdict
1 appstyle.click ████████▋ 95.9% 0.1% 30 ✓ port it
! calls soft_reveal, recursive_reveal, they get ported together with it
3 appstyle.recursive_reveal ████████▌ 94.2% 5.8% 457 ↳ ported inside click
6 appstyle.cells_at █████▍ 59.6% 59.6% 1,681 ✗ instance method (module functions and top-level methods only for now)
The profiler pinned cells_at at 59.6% of the time, but marked it unportable as an instance method. It recommended click instead, a module function that takes the board object and a cell index. Running port on it stops at recording:
✗ recorded no usable calls to appstyle.click out of 30. Arguments and results must be plain data:
numbers, strings, bytes, lists, tuples, dicts, sets (got: AppStyle::Board)
Most Rails code hits one of these two walls. Instance methods are excluded by the classifier, and module functions that pass Active Record objects around can't be recorded. The skill's advice for this case is "Suggest moving pure logic into its own module when that's the blocker."
7.3 Rewriting over arrays and indexes alone gives 70×
Following that advice, the pure logic was pulled out into a function. It takes the mines and the opened cells as row-major arrays of 0/1 and returns each newly opened cell's index with its neighboring mine count.
module Sweep
# mines, revealed: arrays of 0/1, length width * height.
# Returns [[index, neighboring_mines], ...] for each newly revealed cell, in BFS order.
def self.flood_reveal(width, height, mines, revealed, start)
Neighbors are found directly by index arithmetic (ny * width + nx), and a queue does a breadth-first walk instead of recursion. The app only keeps a mine off the clicked cell itself; the experiment also left the eight cells around it empty so that every click cascades and can be measured. Both versions ran in pure Ruby on the same boards: best of three runs, with a check that both opened the same cells with the same values.
| Board | App-style rebuild | Plain data | Ratio |
|---|---|---|---|
| 30×16, 99 mines (the app's Expert) | 3.1 ms/board | 0.044 ms/board | 70× |
| 120×80, 1,200 mines | 493 ms/board | 0.36 ms/board | 1,352× |
The time to build the board objects (10.7 ms for 100 boards) is subtracted from the app-style numbers. Both versions are Ruby, so the gap comes from the algorithm. Flat arrays, index arithmetic and the queue walk changed together, and their shares weren't separated. On this experiment's large board the gap grew much wider. The real app also reads the cells from the database and writes them back with Cell.upsert_all; that part wasn't measured.
7.4 The Rust port was 2.6× per call
Now fast-anything ran on Sweep.flood_reveal. ruby app.rb expert 2000 makes one first click on each of 2,000 Expert boards.
# function total self calls verdict
1 sweep.flood_reveal ███████ 78.1% 78.1% 2,000 ✓ port it
2 boards.make █▎ 13.3% 13.3% 2,000 ✓ port it
port recorded 500 of the 2,000 calls, keeping 400 in the crate's recordings file (with 8 of them as examples in TASK.md) and holding 100 back separately. The Rust port follows the Ruby code as written, on one thread, down to Ruby's Array rules: negative indexes count from the end, reading past the end gives nil, writing past the end grows the array with nils, and a width of 0 raises. It passed on the first verify.
▸ building fa_sweep_flood_reveal (release)
▸ replaying 500 recorded calls against the Rust port
✓ 790/790 calls give the same result (400 recorded + 100 held out + 90 edge cases + 200 derived)
✓ sweep.flood_reveal per call: 46.7µs in Ruby, 18.2µs in Rust: 2.6× faster
For the whole app:
Ruby ████████████████████████ 157ms
Rust ███████████████████▌ 127ms
✓ ruby app.rb expert 2000 is 1.3× faster end to end (median of 5 rounds, 1.1–1.4×; CPU time 1.3×; A/A ±9.7%)
! that's within run-to-run noise: the original alone varies by up to ±9.7% between runs.
bench repeats rounds that run the original twice and Rust once. The tool checks whether the middle 50% of the change with Rust on overlaps the original's run-to-run spread (A/A, −1.5% to +9.7%) and calls it noise if it does. It overlapped here, so the tool itself warned. Measured separately, ruby app.rb expert 1, a single board, also takes about 30 ms, and board generation, 13% in the scan, stays in Ruby. Here is the share card report produced:
After disable, sweep.rb went from 107 lines back to its original 55. The output checksum (397315946) was the same with Rust on and with FAST_ANYTHING_DISABLE=1.
7.5 Where do the 18.9 µs go?
The 2.6× that verify measured (46.7 µs vs 18.2 µs) is small for the computation itself. To see where the time goes, it was timed again in parts. The Ruby original, Rust through the swap block and the Ruby-side JSON round trip are the best of five runs over the same 2,000 boards, so they differ slightly from verify's numbers. fa_call was timed with prebuilt JSON strings, including the Fiddle call and fa_free. The computation alone is the best of 20 runs of the 400 recorded calls directly in Rust, input Vec copies included.
| Part | Per call |
|---|---|
| Ruby original | 43.5 µs |
| Rust, everything through the swap block | 18.9 µs |
├ fa_call alone (Fiddle call, parse JSON, compute, write JSON) | 13.4 µs |
│ └ the computation alone (port::flood_reveal) | 1.13 µs |
| └ Ruby-side JSON round trip alone (args out, result in) | 5.6 µs |
The computation alone is about 38× faster (43.5 ÷ 1.13). But every call turns two 480-element arrays into JSON, the Rust glue parses that JSON into a serde_json::Value tree and then converts it into Vec<i64>, and the result goes back through Value into JSON. That bridge costs about 17.8 µs per call (estimated as 18.9 − 1.13) and eats most of the gain. On the 9,600-cell board the arrays grow with it: Ruby 457 µs, Rust 274 µs, so the ratio actually drops to 1.7×.
The README points this out too: "It ports the outermost loop it can, so the app crosses into Rust once instead of millions of times." This app crossed over once per board, 2,000 times. Wrapping the loop over all 2,000 boards into the function would have cut that to a single crossing; that case wasn't measured.
8. Where does the speed come from? Splitting the README's Ruby example
Under the README's results table is this note: "generated ports are multithreaded (they use available_parallelism), so whole-app speedups scale with the machine's thread count." So how much of the 14× is the language and how much is parallelism?
examples/fuzzy-dedupe-rb finds pairs within edit distance 2 among 400 names. find_duplicates is called once, and calls levenshtein 79,800 times inside. Only the outer function needs porting, so unlike section 7 the bridge is crossed once. Three ports were verified against the same recording and their per-call times compared. All three passed 37/37 (1 recorded, 10 edge cases, 26 derived). With fewer than five recorded calls, this example has no hold-out.
| Port | Time | vs Ruby |
|---|---|---|
| Ruby original | 1.31–1.44 s | 1× |
| Rust with the Ruby loops as they are, 1 thread | 73–82 ms | about 18× |
reference/port.rs algorithm, 1 thread | 6.1–6.2 ms | about 220× |
reference/port.rs as is, 15 threads | 0.63–0.73 ms | about 2,000× |
reference/port.rs adds two things. One is algorithmic: it strips the shared prefix and suffix of the two strings first, skips the edit distance entirely when the length difference already exceeds the limit, and reuses a single row buffer. The other is parallelism: std::thread::scope deals the outer loop's rows out to threads. The generated crate has no parallel library such as rayon; the port's author implements the thread split.
Split up, the straight single-threaded port gives about 18×, the algorithm adds about 12× on the same single thread, and 15-thread parallelism adds about 9×, which multiply to about 2,000×. The whole app went from 1.37 s to 32 ms, 43×. That beats the README's 14× (a 12-thread i5-10500 on Windows), but with a different machine and OS, how much of that gap is thread count wasn't measured.
TASK.md asks the agent to "Make it fast", so algorithmic improvements are part of what the tool intends, and since verify checks the results match, they aren't cheating. Still, the README's ratios shouldn't be read as how much faster Rust is than Ruby. The straight port came to around 18×, and when calls are frequent and inputs are large, as in section 7, the bridge cuts into even that.
9. Suggested reading order
skills/fast-anything/SKILL.md: 33 lines. The loop the agent follows and its don'ts sum up the whole design.src/pipeline.rs: thegoflow and theenablegate (slower_hint,too_cheap_hint).src/backend.rs: hold-out (line 312), replay, and the build settings of generated crates.src/ruby.rs:record, which appends a recording line to the file and restores it, andshim, which builds the swap block.src/ruby/runner.rb:cmd_profile(TracePoint),describe(the Prism classifier),edgesandderive(edge cases), andcmd_verify, all in one file.src/native.rs: the C entry-point glue and the NaN tags (FLOATS).examples/fuzzy-dedupe-rb/reference/port.rs: what the tool expects a good port to look like.
10. Design points worth noting
1. Some calls are hidden from the agent. One recorded call in five is held back, and a failure on it comes without values. The design keeps the agent from fitting its output to the test values.
2. Right but slower stays off. Matching results are necessary but not enough: a port slower per call than the original stays off, and the tool suggests the next move, porting the caller.
3. The original is never removed. The def stays, and only the swap block comes and goes. One environment variable runs the original, so a suspicious result can be compared right away.
4. Nobody writes a spec. As section 5 showed, newly made inputs are tested only where the original answers, so the original's behavior is the specification.
5. It says why something can't be ported. Every ✗ comes with a reason, and the skill has the agent suggest moving pure logic into its own module. The biggest gain on section 7's Rails game (70× on the Expert board) came from exactly that refactoring.
11. Things to watch
1. It tests recorded calls; it doesn't prove anything. Checking is limited to the recorded calls and the edge and derived cases made from them. The command handed to scan has to represent real use, and the skill says to use a representative workload rather than the test suite.
2. Ruby and Rails offer a narrow target. Instance methods aren't supported yet, and Active Record objects can't be recorded. In this Rails app 89% of methods dropped out at the first check. If most of a request's CPU is Active Record, as in the list API of the Rails request-layer measurement, that part can't be moved with this tool.
3. The bridge cost grows with larger inputs. Ruby serializes every argument to JSON on every call. A function that is handed large arrays often gains less, however fast its Rust is. In section 7, 1.13 µs of computation came with about 17.8 µs of bridge.
4. It has to be built where it runs. The generated crate's config says "Built for the machine that runs it: .fast/lib is rebuilt per machine, never shipped." and builds with target-cpu=native. A Rails app shipped as a Docker image needs the library built for the deployment server's OS, architecture and CPU. If the library is missing, the swap block silently swallows the Fiddle::DLError and falls back to Ruby, which makes the miss easy to overlook.
5. The results table mixes several contributions. As section 8 shows, the ratios multiply the language, the algorithm and parallelism. A machine with a different thread count gets different numbers.
6. It changes very fast. 255 commits landed in the eight days since release. The criteria, such as no instance methods, are marked "for now" and may change.
12. Conclusion
The answer to the opening question: running fast-anything on this Rails app as it is turned up almost nothing to port. Most methods are instance methods, and module functions pass Active Record objects around. Rails code built the same way will likely see the same result. To port anything, the logic first has to be pulled out into a function over plain data, and in this minesweeper game that refactoring alone, over arrays and index arithmetic, made it 70× faster in pure Ruby. On top of that, the Rust port was 2.6× faster per call, and for the whole app the gain was indistinguishable from noise.
So in Rails the tool is useful in two ways. scan is a profiler that points at the hotspot accurately. verify is a differential test that checks with real calls that the Rust port gives the same results as the original Ruby. It doesn't check the refactoring from Active Record code to a plain-data function, though; that needs its own comparison, as in 7.3. On the other hand, a pure function called once that burns CPU for a long time, like fuzzy dedupe, multiplies the language, the algorithm and parallelism into a large ratio. Which case you're in can be estimated in advance from scan's verdicts and how many times the bridge is crossed.
13. How this relates to earlier posts
| Post | In common | Difference from fast-anything |
|---|---|---|
| Craft Anything | An agent builds and a tool grades against the original | Craft Anything compares screens through screenshots. fast-anything compares one function's inputs and outputs through recorded calls. |
| The cost of Rails abstractions | Both measure whether Ruby is slow and what is slow | That post compared the same API with and without a framework. This one compares one piece of pure logic from a Rails app as Ruby, refactored Ruby and Rust. |
| Rails request layers | Both look at where a Rails request's time goes | Its finding that 70% of a list API request's CPU is Active Record ties into this post's conclusion: fast-anything can't move that part. |
| Inside Active Record | Both measure the cost of building objects | That post cut costs inside Active Record. This one measures the difference when the function stops using objects at all. |
Analysis date: 2026-11-30 Commit analysed:
c3e3dc5(fast-anything 0.9.1, 2026-11-29) Repository: https://github.com/EL4CTEO/fast-anything (MIT) Test environment: Apple M5 Pro (15 cores), macOS 27.2, Ruby 4.0.6 (Homebrew), Rust 1.96. fast-anything release build from source. The Rust ports were written by the Claude Code session writing this post instead of--agent; the section 7 port is single-threaded. Hands-on subject: pdobb/minesweeper_alliance19ed13e(MIT, Rails 8.1.4.1). The app wasn't booted: the classifier ran on the app's code as is, and the cascade reveal was rebuilt without a database. The fuzzy dedupe run usedexamples/fuzzy-dedupe-rbas is.
Written with Claude Code