DEV Community

Cover image for 116x Faster Is True. It Is Also the Wrong Number.
AheadKit
AheadKit

Posted on

116x Faster Is True. It Is Also the Wrong Number.

The 116x number is not a lie. It is a measurement of the wrong thing. I ran the whole loop on my own fuzzy dedupe, a thousand names with typos, and the function really did get 110 times faster. The app got 48 times faster. Both numbers are from the same run, and the difference between them is the only thing worth writing about.

Fast-Anything does one thing: it profiles your app, finds the slowest function, has a coding agent rewrite just that function in Rust, proves the rewrite behaves the same on real recorded calls, and swaps it in. The headline number, 116x, comes from their fuzzy dedupe example: a Python dedupe of 700 names falling from 4.91 seconds to 42 milliseconds. I built my own version of the same job, 1,005 names with typos, 163 unique after dedupe, and ran the whole loop on it. My baseline was 2.61 seconds, then 2.57 on the repeat.

The scan took about seven seconds under the profiler and named the obvious suspect. dedupe was 99.9 percent of the run in a single call. Inside it, levenshtein ran 67,427 times and took 99.6 percent. The third function on the list was the typo generator, which the tool refused to port, correctly, because it calls random and no deterministic rewrite of a random function means anything. That refusal is the first thing the tool got right. A profiler that proposes porting your randomness is a profiler that has not understood your program.

The port step recorded one real call to dedupe and wrote a crate with a brief for the coding agent. I wrote the Rust myself, following that brief: the Levenshtein distance over characters, not bytes, because Python strings index by code point and a byte-based port would have failed on the first non-ASCII name. Then the tool replayed every recorded call plus the edge cases it derives, empty input, non-ASCII text, long inputs, against the Rust build. Thirty-five out of thirty-five came back identical. Per call, the function went from 2,536.8 milliseconds in Python to 23.1 in Rust. That is 110 times faster, measured, and close enough to the advertised 116 that the headline survives contact with my machine.

Then I ran the benchmark, which times the whole app, not the function. Five runs each, interleaved. Python: 2.60 seconds. Rust: 55 milliseconds. Forty-eight times faster end to end.

Forty-eight is the honest number and 110 is the true one, and they are different because the function is not the app. The app also generates a thousand names, prints a line, and starts a Python interpreter, and none of that got faster. The port moved the only part that was slow, and the slow part was 99.9 percent of the run, so the app still got dramatically faster. But the gap between 110 and 48 is the fixed cost of everything around the function, and no port touches that. A bigger app with more fixed cost would show a smaller end-to-end number from the same 110-times function. A smaller one would show a bigger number. The per-call figure belongs to the function. The end-to-end figure belongs to the app. Quoting the first as if it were the second is how a real speedup turns into a misleading one.

None of this makes the tool a gimmick. The loop worked exactly as described: scan found the hot function, the port was verified against real calls before anything was swapped in, and the swap is reversible. What it makes is a tool whose headline number needs a second number next to it, the one for the whole program. I would still port the hot function. I just would not tell anyone it made my app 116 times faster, because it made one function 110 times faster and my app 48 times faster, and the second number is the one a user feels.

What is the biggest gap you have seen between a function's speedup and the app's? I keep finding the fixed costs are larger than anyone admits before they measure them.


P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam

Buy me a coffee

AheadKit on Gumroad — Beginner-Friendly Books & Packs

Top comments (0)