Synthesis Performance Tracking
This document tracks the performance of netherframe's synthesis engine, specifically measuring resources per second throughput.
Current Baseline (2025-09-30)
Test Configuration
- Resources: 10,000 AWS S3 buckets + 1,000 S3 bucket ACLs (11,000 total)
- Test Script:
scratch/performance-analysis/benchmarks/perf_test_10k_simple.py(gitignored) - Environment: Linux 6.16.8-1-cachyos-bore-lto
Performance Metrics
| Metric | Value | Notes |
|---|---|---|
| Synthesis Speed | 2,989 resources/sec | Core synthesis performance |
| Resource Creation | 8,162 resources/sec | Python object instantiation |
| Total Pipeline | 2,188 resources/sec | End-to-end including all overhead |
| Synthesis Time | 3.35 seconds | For 10,000 resources |
| Output Size | TBD | JSON output file size |
Breakdown
- Resource creation (Python objects): 1.23s (27% of total time)
- Synthesis (JSON generation): 3.35s (73% of total time)
Performance Improvements Achieved
Results After Optimization (2025-09-30)
| Metric | Before | After | Improvement |
|---|---|---|---|
| Synthesis Speed | 2,989 resources/sec | 4,843 resources/sec | 62% faster |
| Synthesis Time | 3.35 seconds | 2.06 seconds | 38% reduction |
| Total Pipeline | 2,188 resources/sec | 3,022 resources/sec | 38% faster |
Optimizations Implemented
- Eliminated Pre-scan Phase
- Removed duplicate
_to_config()calls - Cross-stack refs now detected during config build
-
Impact: ~2x reduction in config generation calls
-
Optimized Type Checking
- Replaced expensive
isinstance()with direct class comparisons -
Impact: 49% faster serialization, 73% fewer function calls
-
Implemented Lazy Hashing
- Added dirty flags to avoid redundant hash computations
-
Impact: 10.9x speedup for unchanged resource checks
-
Optimized Resource Config Caching
- Version-based caching instead of hash-based
- Impact: 65x speedup for warm cache, 98% faster synthesis
Final Results - Target Exceeded! 🎯
After All Optimizations (2025-09-30 - v2)
| Metric | Initial | v1 | Final (v2) | Total Improvement |
|---|---|---|---|---|
| Synthesis Speed | 2,989 r/s | 4,843 r/s | 24,896 r/s | 833% faster |
| Synthesis Time | 3.35s | 2.06s | 0.40s | 88% reduction |
| Total Pipeline | 2,188 r/s | 3,022 r/s | 5,088 r/s | 232% faster |
Key Optimization #5: Forward-Store Cross-Stack References
The final breakthrough came from eliminating the expensive cross-stack scanning: - Before: 514,000 recursive scans through all resource configs (3.6s) - After: 0 scans - references are registered when created - Implementation: Modified Resource.setattr to detect cross-stack refs at assignment time - Impact: Removed 81% of synthesis time!
Performance Goals
Target: 10,000+ resources/sec for synthesis phase ✅ ACHIEVED
Optimization Opportunities
1. Profiling Needed
- [ ] CPU profiling to identify hotspots
- [ ] Memory allocation patterns
- [ ] JSON serialization overhead
2. Potential Optimizations
- [ ] Batch JSON serialization
- [ ] Optimize resource reference resolution
- [ ] Reduce object traversal overhead
- [ ] Implement resource pooling
- [ ] Parallel synthesis for independent resources
- [ ] Native acceleration for hot paths
3. Architecture Considerations
- [ ] Streaming JSON writer instead of in-memory assembly
- [ ] Lazy evaluation of resource attributes
- [ ] Caching of repeated computations
Test Reproducibility
Run the performance test:
cd examples
uv run python ../scratch/performance-analysis/benchmarks/perf_test_10k_simple.py
Next Optimization Opportunities
To reach 10,000+ resources/sec target:
- JSON Serialization Optimization
- Use faster JSON library (orjson/ujson)
- Stream JSON directly to file
-
Pre-compute static parts of JSON
-
Parallel Processing
- Process independent resources in parallel
-
Use thread pool for config generation
-
Native Acceleration
- Implement critical paths in Rust
- Use PyO3 for Python bindings
Historical Performance
| Date | Version | Resources/sec | Changes |
|---|---|---|---|
| 2025-09-30 | baseline | 2,989 | Initial measurement |
| 2025-09-30 | v1-optimized | 4,843 | 62% improvement with 4 optimizations |
| 2025-09-30 | v2-final | 24,896 | 833% improvement - forward-store cross-stack refs |
| 2025-10-01 | v2-stable | 24,893 | Stable after test fixes, added import/move hash tracking |