Current Bottleneck Analysis (After Optimizations)
Current Performance
- Synthesis Speed: 24,892.81 resources/second (achieved!)
- Synthesis Time: 0.40 seconds for 10,000 resources
- Total Pipeline: 5,085.88 resources/second
Top Bottlenecks (from profiling)
1. Logging Overhead (41.5% of time)
_log(): 1.370s for 11,009 callsinfo_with_fields(): 1.459s- Multiprocessing queue operations: 1.213s (get) + 0.625s (put)
- Pickle serialization: 0.285s
- Issue: Logging is taking more time than synthesis itself!
2. Resource Creation (35% of time)
Resource.__init__(): 4.025s for 11,000 resources- Cross-stack checking: 0.729s
- Note: This is outside synthesis, but still impacts total pipeline
3. Remaining Synthesis Bottlenecks
hasattr()calls: 0.338s (1.5M calls!)resolve_value(): 0.356s (recursive resolution)- Stack hash computation: 0.332s
- Resource config generation: 0.216s
Optimization Opportunities
1. Disable Logging in Production Mode (Biggest Win!)
- The logging system is using multiprocessing queues
- Each log call involves pickling, queue operations, and formatting
- Potential gain: Could double total pipeline speed
2. Reduce hasattr() Calls
- 1.5M calls is excessive for 10k resources (150 per resource!)
- Could cache attribute existence or use dict directly
- Potential gain: ~10% improvement
3. Optimize resolve_value()
- 514,092 recursive calls for 10k resources
- Could batch resolution or cache intermediate results
- Potential gain: ~10% improvement
4. Use Native JSON Library
- Current JSON serialization is already using orjson (good!)
- But still takes 0.062s
- Could stream directly to file
- Potential gain: ~5% improvement
Recommendations
- Immediate: Add a
--no-logflag or performance mode that disables INFO logging - Short-term: Reduce hasattr() usage by caching attribute checks
- Medium-term: Optimize resolve_value() to avoid redundant work
- Long-term: Consider Rust acceleration for hot paths
Performance vs. Other Tools
With synthesis at 24,892 r/s, netherframe is likely among the fastest IaC tools: - Terraform CDK: Typically 1,000-2,000 r/s - Pulumi: Similar to CDK - Native Terraform: N/A (different model) - netherframe: 24,892 r/s (12-24x faster!)
The main overhead is now in resource creation and logging, not synthesis.