test: add Criterion bench suite for PPE hot-path costs - #35
test: add Criterion bench suite for PPE hot-path costs#35abdallahsamabd wants to merge 1 commit into
Conversation
praxis-bot
left a comment
There was a problem hiding this comment.
Criterion Bench Suite for PPE Hot Path
PR adds an ppe-benches crate covering plugin dispatch, full-decision latency, throughput, per-PDP cost, and memory/session-taint growth. Suite design is solid: setup runs outside timed loops, fixtures mirror production wiring, CI compiles the suite via clippy --all-targets without wall-clock gating, and docs/benchmarks.md records the decision rationale and baseline numbers.
Findings
| # | Severity | File | Issue |
|---|---|---|---|
| 1 | Large | benches/memory.rs:77 |
session_append_one accumulates state across Criterion iterations |
| 2 | Medium | benches/pdp_cost.rs:98 |
PDP evaluate results not checked for expected decision outcome |
a1307c7 to
53499e9
Compare
araujof
left a comment
There was a problem hiding this comment.
Thanks for this PR!
The suite builds and its smoke tests pass. A few notes to address missing measurements and some other nits:
- Criterion does not report p95 or p99 by default. The docs only record means, so the requested p50/p95/p99 results are not covered.
- No CPU profile was captured; the document gives an expected flamegraph instead.
session_append_onekeeps adding labels to the same store, so the 8/64/512 starting sizes are quickly swamped. It also reportsn_labelselements per iteration even though only one label is appended.- The memory results do not show per-decision allocation or footprint growth with policy size.
Please address these before merging.
|
Hi @abdallahsamabd, Thank you for the contribution. Here is my review on this PR: Finding 1:
|
terylt
left a comment
There was a problem hiding this comment.
Overall, nice work! See my comments in the previous message for suggested changes.
cbe45d7 to
16389c5
Compare
|
@abdallahsamabd please tag us when this one is ready for re-review. Thanks! |
|
@araujof |
praxis-bot
left a comment
There was a problem hiding this comment.
PR Review
Re-review of the bench suite. Both prior findings (session_append_one state accumulation and missing PDP decision assertions) have been addressed — nice work. One new convention finding below.
| @@ -133,6 +137,10 @@ praxis-policy-pdp-cel = { path = "builtins/pdps/cel", | |||
| praxis-policy-pdp-opa = { path = "builtins/pdps/opa", version = "0.1.0" } | |||
| praxis-policy-session-valkey = { path = "builtins/session/valkey", version = "0.1.0" } | |||
|
|
|||
There was a problem hiding this comment.
[Medium] "0.7" is missing the patch version. All other workspace dependencies specify full semver with patch (e.g. "1.6.0", "0.5.3"). Same issue in crates/ppe-benches/Cargo.toml where dhat uses "0.3".
Change to criterion = { version = "0.7.0", ... } here and dhat = { version = "0.3.3", ... } in the crate Cargo.toml to match the workspace convention.
16389c5 to
d59bb0d
Compare
Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
d59bb0d to
7150cd0
Compare
Summary
Adds a Criterion benchmark suite for the Praxis Policy Engine hot path (#19).
ppe-benchesunderbenches/covering:plugin_only/cedar_only/plugin_then_cedarmode: concurrentevaluateonlydhat-heapprofilemake benchruns the suite on demand (not part ofmake ci)docs/benchmarks.mdSetup (YAML load, Cedar compile) stays outside Criterion iters so timings reflect
PolicyEngine::invoke_named/PdpResolver::evaluate/SessionStore, not load cost.CI policy: do not gate PRs on wall-clock benches. Clippy/
make cistill compile all[[bench]]targets so the suite cannot bitrot.Test plan
cargo bench -p ppe-benches --no-runcargo bench -p ppe-benches -- --testcargo clippy -p ppe-benches --all-targets -- -D warningsmake bench(or targeted:--bench full_decision,--bench pdp_cost)cargo bench -p ppe-benches --features dhat-heap --bench memorydocs/benchmarks.mdmatches local hardware / re-run if publishing release numbers