8000 perf: predicate push-down for Expr clauses + mixed rule optimization (#207, #206) by adityamukho · Pull Request #249 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions benches/minigraf_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,40 @@ fn bench_btree_lookup(c: &mut Criterion) {
}
}

// ── query/predicate_pushdown ──────────────────────────────────────────────────

fn bench_predicate_pushdown(c: &mut Criterion) {
// Fixture: n entities each with :val (integer) and :name (string).
// Uses helpers::populate_with_names(n).
//
// Query: multi-pattern with a selective Expr predicate.
// (query [:find ?e ?n :where [?e :val ?v] [?e :name ?n] [(> ?v <threshold>)]])
//
// Threshold = 90th percentile → ~10% of entities pass the filter.
const SCALES: &[(&str, usize)] = &[("1k", 1_000), ("10k", 10_000), ("100k", 100_000)];

let mut group = c.benchmark_group("query/predicate_pushdown");
group.sample_size(10);

for &(label, n) in SCALES {
let db = helpers::populate_with_names(n);
let threshold = (n as i64) * 9 / 10;
let query = format!(
"(query [:find ?e ?n :where [?e :val ?v] [?e :name ?n] [(> ?v {})]])",
threshold
);
group.bench_with_input(
BenchmarkId::from_parameter(label),
&(db, query),
|b, (db, q)| {
b.iter(|| db.execute(q).unwrap());
},
);
}

group.finish();
}

criterion_group!(
benches,
bench_insert,
Expand All @@ -1527,5 +1561,6 @@ criterion_group!(
bench_prepared,
bench_retract,
bench_btree_lookup,
bench_predicate_pushdown,
);
criterion_main!(benches);
Loading
Loading
0