Performance baselines define acceptable limits for key contract operations, API response times, and database queries. Thresholds are enforced in CI via the performance workflow. Baseline values are stored in performance/baselines.json.
| Operation | Baseline | Threshold | Unit |
|---|---|---|---|
| Participant registration | 500,000 | 750,000 | instructions |
| Waste registration | 800,000 | 1,200,000 | instructions |
| Waste transfer | 1,000,000 | 1,500,000 | instructions |
| Incentive creation | 600,000 | 900,000 | instructions |
| Reward distribution | 1,200,000 | 1,800,000 | instructions |
| Metric | Baseline | Threshold | Unit |
|---|---|---|---|
| p95 latency | 300 | 500 | ms |
| p99 latency | 700 | 1,000 | ms |
| Error rate | 1 | 5 | % |
| Metric | Baseline | Threshold | Unit |
|---|---|---|---|
| Query p95 | 400 | 600 | ms |
| Query p99 | 800 | 1,200 | ms |
Baseline = expected normal performance. Threshold = maximum acceptable value before the check fails.
The performance.yml workflow runs on:
- Every push to
mainordevelop - Pull requests targeting
main - Weekly on Sundays at 03:00 UTC
- Manual dispatch via GitHub Actions UI
Jobs:
- contract-benchmarks — runs
cargo test --test performance_testinstellar-contract/, uploads results as artifact - api-performance — runs a 30s k6 smoke test against
k6-api-response-times.js, compares results againstbaselines.jsonthresholds (skipped gracefully if k6 unavailable) - performance-report — downloads artifacts and writes a pass/fail table to the GitHub Actions step summary
| Severity | Condition | Action |
|---|---|---|
| Warning | Metric exceeds baseline | Note in PR review |
| Failure | Metric exceeds threshold | CI check fails, block merge |
The api-performance job uses continue-on-error: true so a missing test environment does not block unrelated work, but threshold violations in a live environment will still fail the step.
Artifacts from each run are retained by GitHub Actions (default 90 days). To track trends over time:
- Download artifacts from the Actions UI or via
gh run download - Compare
performance-results.txtacross runs for contract instruction counts - Compare
k6-results.jsonacross runs for API metrics
When deliberate optimizations or contract changes alter expected performance:
- Run the full benchmark suite locally and collect new measurements
- Edit
performance/baselines.json— updatebaselineto the new measured value and setthresholdto 150% of baseline (or as appropriate) - Update the
updatedfield to today's date - Open a PR with the changes and include benchmark output as evidence
# Run contract benchmarks locally
cd stellar-contract
cargo test --test performance_test -- --nocapture
# Run k6 smoke test locally (requires k6)
k6 run --vus 1 --duration 30s performance/k6-api-response-times.jsWhen a threshold breach is detected:
- Identify the regressing commit via
git bisect - Profile the operation: for contract code, check instruction count growth in test output; for API, use k6 detailed output
- Fix or revert the regression, or update the baseline if the change is intentional and justified
- Re-run CI to confirm the breach is resolved before merging