One Rust Patch, Two Workloads: Catching Regressions with CodSpeed
You’re reviewing a Rust pull request that changes how a batch job counts unique event IDs. The tests pass, and on the first benchmark the patch uses about 24% fewer instructions than the original code. Would you merge it? Now try a second batch. Both batches contain 2,048 IDs. In the first, the same eight values repeat. In the second, every ID is different. The patch still gets the right answer,…
This tutorial demonstrates how to catch regressions in batch jobs that count unique event IDs using Rust. A patch replaces a BTreeSet with a small Vec, resulting in 24% fewer instructions on a benchmark with repeated IDs. However, when the benchmark contains unique IDs, the patch incurs 3.28 times more instruction references. The lab runs the patch on two batches with 2,048 IDs each, one with repeated IDs and the other with unique IDs.
The goal is to identify the cause of the increased work in the second benchmark and fix the patch while preserving the performance gain on repeated IDs.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.