Skip to content

bench(pingora-lru): migrate benchmarks to Criterion#847

Open
C-Harshul wants to merge 5 commits intocloudflare:mainfrom
C-Harshul:criterion-benchmarks-pingora-lru
Open

bench(pingora-lru): migrate benchmarks to Criterion#847
C-Harshul wants to merge 5 commits intocloudflare:mainfrom
C-Harshul:criterion-benchmarks-pingora-lru

Conversation

@C-Harshul
Copy link
Copy Markdown

Closes #602

The existing benchmarks in pingora-lru use manual Instant::now() timing inside a fn main(). This produces a single number with no warmup, no outlier handling, and no way to detect regressions automatically. This PR migrates both benchmarks to Criterion.rs.

Changes

pingora-lru/Cargo.toml
Adds criterion = { version = "0.5", features = ["html_reports"] } to [dev-dependencies].

benches/bench_linked_list.rs
Migrates all five operations — push, iter, search, promote, and pop — into named Criterion benchmark groups. iter_batched(LargeInput) is used for the pop benchmark so the cost of building the list is excluded from the measured time.

benches/bench_lru.rs
Migrates single-thread and 8-thread concurrent benchmarks. iter_custom is used for the concurrent case since Criterion does not manage threads natively — it times the wall-clock duration of all threads completing iters operations each, which mirrors the intent of the original benchmark.

Before / after

Before After
Output 8ns avg per operation [8.1 ns 8.3 ns 8.6 ns]
Warmup
Confidence interval ✓ 95%
Regression detection ✓ automatic
Outlier handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt Criterion.rs for Benchmarks

1 participant