rusty_mp3 Speed-Up: Pure Rust MP3 Encode and Decode, Byte-Identical
Two remade_ffmpeg_rs pull requests cut rusty_mp3 encoder instructions by 41 to 44% and decoder instructions by 15 to 19%, with output byte-identical to before.

How much faster did rusty_mp3 get at pure Rust MP3 encoding and decoding?
By callgrind instruction count, PR 283 cut the encoder 40.6% to 43.5% on three streams and PR 286 cut the decoder 14.8% and 19.4% on two, with byte-identical output. Those are counts, not wall time. The PR 286 README adds timed runs on one i7-14650HX core: encode 1.43x faster than 1.2.2, decode 1.12x faster than 1.2.3.
Pure Rust MP3 now does less work. rusty_mp3 is the MP3 codec in remade_ffmpeg_rs, with no C and no FFI, and two pull requests on 4 December 2026 took work out of both halves of it. The encoder runs 41 to 44% fewer instructions. The decoder runs 15 to 19% fewer. Every output is byte-identical to what the old code wrote.
Both are merged and released: the encoder in rusty_mp3 1.2.3 and the decoder in 1.2.4. Below we say which, quote only what the pull requests and the repo state, and mark every place the numbers stop.
Pure Rust MP3 Performance: The Two Pull Requests
Pull request 283 is the encoder. It merged at 6:36 AM MST on 4 December, and rusty_mp3 1.2.3 reached crates.io within the hour. The changelog lists it as the only performance change in that release. Pull request 286 is the decoder. It was opened at 8:24 AM MST and merged at 10:11 AM MST the same day, and rusty_mp3 1.2.4 carried it to crates.io at about 11:00 AM MST.

Both PRs measure with callgrind, which counts the instructions a run executes. The encoder PR says the counts cover codec work only, use rusty_alloc as the allocator, and repeat exactly when the same binary runs again. Neither PR names the machine for those runs. That is reasonable for a count, since the number should not move with the CPU, but it means we can't say what hardware produced it.
The counts are not seconds. The encoder PR says the cuts remove real work, so a time win is expected, but it had not been clocked. The decoder PR repeats the caveat. Valgrind counts a rep stosb per byte, so the decoder's zero-fill savings overstate what a clock would show. A third commit in PR 286 does add timed runs, and we quote them below with their conditions.
What The Encoder Lost: 41 To 44% Of Its Instructions
Three encode instruments went through six changes. The table is the PR's own.
| Instrument | Before | After | Change | |---|--:|--:|--:| | Vocal, 6 s stereo, CBR 128k | 632,985,139 | 365,419,235 | −42.3% | | Guitar, 6 s stereo, VBR q2 | 710,826,486 | 401,709,994 | −43.5% | | Speech, 10 s mono, 64k | 469,127,407 | 278,781,182 | −40.6% |
Where The Work Went
Two steps did most of it, each measured against the step before on the CBR instrument. best_pair_table computed codeword lengths per table and magnitude cell once, instead of looking up code_len for every cell under every candidate table: −21.7%. The FFT lost its per-access bounds checks (−9.9%) and then had its first three stages fused per eight-sample block in registers (another −9.9%). A single reverse walk to find both region ends, plus a popcount to choose the count1 table, took −7.8%.
The Small Steps And One Wrong Guess
The other two steps were small. A 64-bit accumulator in BitWriter::write, which emits whole bytes instead of one bit per loop, saved 0.7%. Letting the 18 MDCT outputs accumulate together along contiguous rows saved 0.6%. The PR also records a refuted estimate: the MDCT change was expected to save about 15 million instructions and saved 2.85 million, because the original scalar loop was cheaper than its line count suggested.
What Byte-Identical Means Here
It means the same stream comes out before and after. The PR reports 28 hashes identical after every step: 19 encodes (CBR 32 to 320k, VBR q0 to q9, mono, 48 kHz, MPEG-2 and MPEG-2.5 rates, applause) and 9 decodes of LAME streams. Three new oracle tests keep the replaced code as the reference, and 161 tests pass. It does not mean the output matches LAME. The crate README says LAME still scores higher on PEAQ, by up to 0.1 ODG at 160 kbps and above.
The Decoder, And What A Clock Shows
The decoder PR is smaller in scale and more modest in claim. It removes redundant zero-fills and replaces a slow fallback for long Huffman codewords.
| Stream | Before | After | Change | |---|--:|--:|--:| | Piano, LAME 128k | 47,540,054 | 40,524,924 | −14.8% | | Percussion, LAME 192k | 98,441,638 | 79,378,902 | −19.4% |
Four Decoder Steps
Dequantisation now clears only the tail above rzero. The spectrum buffer is held in Mp3Decode across granules instead of being zeroed per granule. The IMDCT writes into per-channel scratch, so hybrid_into replaces a fresh zeroed array. And codewords past the 12-bit first-level table get a second-level table: they had used a bit-at-a-time scan costing about 17,000 instructions each, 9.7% of the percussion stream from 493 calls. That last step saved 7.93 million of the 19 million on percussion and 0.56 million on piano.
Wall Time, On One Machine
The README commit in the PR says the timed runs were on Linux (WSL2), one pinned core of an Intel Core i7-14650HX, against FFmpeg 8.0.1, 20 rotating rounds, medians. Decoding a 60-minute LAME 192 kbps stream took 3.17 s for the PR's build, which the README calls 1.2.4 and which shipped under that number, against 3.62 s for 1.2.3 and 7.21 s for FFmpeg's mp3float. That is 1.12 times faster than 1.2.3 (17 of 20 rounds), and 2.0 times faster than FFmpeg by best run, or 1.7 times once the 0.6 s FFmpeg spends demuxing is subtracted. Encoding a 10-minute 192 kbps track took 3.95 s against 5.66 s for 1.2.2 and 7.69 s for LAME through FFmpeg, which the README gives as 1.43 times faster than 1.2.2 and about 2 times faster than LAME.
What Isn't Claimed
Other CPUs are unmeasured. The decoder numbers are the pull request's own, and we read them rather than rerunning them on the released 1.2.4. The PR leaves two items undone: the PCM resize memset, and the synthesis FIFO rotate_left, which costs 3.1 million instructions on percussion. For the wider story of the pure Rust MP3 encoder and decoder, see the pure Rust alternative to minimp3, the rusty_mp3 crate page, and the same counted-change method in the Diana 0.10 campaign and the rusty_h265 0.7 decoder kernels. A newer crate with a similar evidence trail is rusty_nvenc. On the audio side, the Opus multistream surround guide covers another pure Rust codec. For how callgrind counts, read the Valgrind manual, and for the reference encoder, LAME.
FAQ
Quick answers for builders evaluating this technology.
Is the rusty_mp3 decoder change released yet?
Yes. The encoder change (PR 283) shipped in rusty_mp3 1.2.3 on crates.io on the morning of 4 December 2026. The decoder change (PR 286) merged at 10:11 AM MST and shipped in rusty_mp3 1.2.4, which reached crates.io at about 11:00 AM MST the same day. The 1.2.4 changelog lists the decoder work under Performance.
Does byte-identical output mean the encoder matches LAME?
No. It means the new rusty_mp3 writes the same bytes as the old rusty_mp3 on the 19 test encodes. LAME is a different encoder. The crate README says LAME still scores higher on PEAQ, by up to 0.1 ODG at 160 kbps and above and by more at lower bitrates.
Why do the PRs report instruction counts instead of seconds?
Callgrind counts exactly and repeats exactly, so a change of a few thousand instructions is visible and a re-run gives the same number. Wall time wobbles with the machine. The PRs say instruction counts do not price cache or branch behaviour, so a README commit in PR 286 adds timed runs as well.
How fast is rusty_mp3 against FFmpeg and LAME, on the timed runs?
On one pinned i7-14650HX core under WSL2, the PR 286 README gives decode 3.17 s against 7.21 s for FFmpeg's mp3float on a 60-minute stream, and encode 3.95 s against 7.69 s for libmp3lame on a 10-minute track. One machine, 20 rounds, medians. Other CPUs are unmeasured.
Which numbers are the project's own, and which did you rerun?
All of them are the project's own, taken from the two pull requests, the rusty_mp3 changelog and the README commit in PR 286. We read them and did not rerun them. Where a figure is not in those sources, such as the hardware behind the callgrind runs, this page says it is not stated.