This document describes the automated performance benchmarking pipeline for Stellar-Save, which tracks:
- Contract Gas Costs: Monitor Soroban contract function gas usage to detect regressions
- Frontend Performance: Track web vital metrics and Lighthouse scores
- Performance Trends: Analyze trends over time to identify performance degradation
| Function | Threshold | Priority |
|---|---|---|
create_group |
2M gas | Normal |
contribution |
1.5M gas | Normal |
auto_advance_cycle |
3M gas | Critical |
distribute_winnings |
4M gas | Critical |
apply_penalty |
800K gas | Normal |
query_group_status |
500K gas | Normal |
- Development: Unlimited budgets for exploration
- Testing: Focused budgets on specific operations
- Production: Strict limits with regression alerts at +10% threshold
# Run all benchmarks
cargo test --manifest-path contracts/stellar-save/Cargo.toml benchmark -- --nocapture
# Run specific benchmark
cargo test --manifest-path contracts/stellar-save/Cargo.toml benchmark_create_group_gas -- --nocapture
# With detailed output
RUST_BACKTRACE=1 cargo test --manifest-path contracts/stellar-save/Cargo.toml benchmark -- --nocapture --test-threads=1| Category | Target Score | Min Score |
|---|---|---|
| Performance | 90 | 85 |
| Accessibility | 95 | 90 |
| Best Practices | 90 | 85 |
| SEO | 95 | 90 |
| Metric | Target | Warning |
|---|---|---|
| First Contentful Paint (FCP) | 1.8s | 2.5s |
| Largest Contentful Paint (LCP) | 2.5s | 4.0s |
| Cumulative Layout Shift (CLS) | 0.1 | 0.25 |
| First Input Delay (FID) | 100ms | 300ms |
| Interaction to Next Paint (INP) | 200ms | 500ms |
# Build for production
cd frontend
npm run build
# Start preview server
npm run preview -- --host 127.0.0.1 --port 4173
# In another terminal, run Lighthouse
npx lhci autorun --config .lighthouserc-perf.jsonThe pipeline automatically detects:
- Gas Regressions: When gas usage increases >10% above baseline
- Lighthouse Regressions: When scores decrease >5 points
- Web Vital Regressions: When metrics exceed warning thresholds
- PR Comments: Performance results posted to pull requests
- Build Artifacts: Detailed reports available in GitHub Actions
- Failure Status: Build marked as failed if critical regressions detected
- Run comprehensive benchmarks
- Compare against base branch
- Flag regressions (if any)
- Post summary to PR
- Run benchmarks with extended runs (3x Lighthouse audits)
- Archive results for historical tracking
- Update performance dashboard
- Full regression analysis
- Generate trend reports
- Identify performance drift
The performance dashboard (performance-results/dashboard.html) displays:
- Current Metrics: Latest benchmark results
- Trends: Historical performance data
- Alerts: Active regressions or issues
- Comparisons: Branch-to-branch analysis
Access via GitHub Actions artifacts after workflow completion.
If gas costs exceed thresholds:
- Profile the operation with
cargo llvm-cov - Identify hotspots in contract logic
- Optimize by:
- Reducing state reads/writes
- Batching operations
- Using more efficient algorithms
- Verify with benchmarks
If Lighthouse scores are low:
- Check which audits are failing
- Optimize by:
- Reducing bundle size
- Code splitting routes
- Image optimization
- Lazy loading non-critical components
- Verify with local Lighthouse audits
Performance thresholds and settings are defined in:
docs/performance-config.json: Threshold configurations.github/workflows/performance-benchmarks.yml: Workflow definitionfrontend/lighthouse-config.js: Lighthouse audit settings
If benchmarks show inconsistent results:
- Reduce background processes during runs
- Increase number of runs (Lighthouse defaults to 3)
- Check for environment differences
- Review CI machine specifications
Gas estimates can vary due to:
- Network state variations
- Test environment differences
- Soroban version updates
Monitor trends rather than absolute values.
Common causes:
- Network throttling variations
- JavaScript execution timing
- Resource loading order
- System load during CI runs
Review multiple runs for trends.
- Comparative reporting across teams/branches
- Automated optimization recommendations
- Contract storage analysis
- Memory usage tracking
- Custom metrics integration
- Historical data persistence