This document defines the methodology for benchmarking performance and solver latency in Sanctifier to ensure predictable outputs, reliable CI, and safe-by-default behavior as the project scales.
Sanctifier uses two primary benchmarking vectors:
- AST Analysis Latency: Measures the speed of parsing Rust source and executing static analysis rules (tracked via
criterion). - SMT Solver Latency: Measures the time taken by the Z3 solver to prove or disprove invariants under various constraint strategies.
Solver performance is critical for CI/CD integration. We categorize SMT queries into three domain-driven strategies:
| Strategy | Domain Size | Focus | Typical Latency |
|---|---|---|---|
UnconstrainedOverflow |
Worst-case exhaustive proof | High | |
BoundedDomainOverflow |
Real-world integer ranges | Medium | |
SmallDomainOverflow |
Unit-test style sanity checks | Low |
- Benchmarks are run using
cargo test --test smt_latency_benchmark. - Reports are generated in
target/smt-latency-report.json. -
Target Stability: Average latency for
SmallDomainOverflowshould remain$< 5ms$ to ensure developer productivity.
We benchmark core rule execution using criterion to prevent linear performance degradation on large contracts.
We use COMPLEX_CONTRACT_PAYLOAD (a multi-function contract with complex storage and auth patterns) as our standard baseline.
-
Analyzer Initialization: Must be near-instant (
$< 100\mu s$ ). -
Rule Execution: Total execution time for a standard contract should not exceed
$50ms$ per$1,000$ lines of code.
To maintain high velocity while ensuring performance:
- Pre-commit: Developers should run
scripts/check-benchmarks.shlocally before pushing. - CI Pipeline: SMT latency benchmarks run on every PR if
RUN_BENCHMARKS=1is set. - Scheduled Runs: Full Criterion benchmarks run weekly to track long-term performance trends.
-
Timeout: All SMT calls default to a
$10s$ timeout (SmtConfig::default()). -
Precision: By default, Sanctifier uses the
UnconstrainedOverflowstrategy for highest safety, falling back to bounded domains only when explicitly configured for performance-critical environments.