Skip to content

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

  1. Eliminated Pre-scan Phase
  2. Removed duplicate _to_config() calls
  3. Cross-stack refs now detected during config build
  4. Impact: ~2x reduction in config generation calls

  5. Optimized Type Checking

  6. Replaced expensive isinstance() with direct class comparisons
  7. Impact: 49% faster serialization, 73% fewer function calls

  8. Implemented Lazy Hashing

  9. Added dirty flags to avoid redundant hash computations
  10. Impact: 10.9x speedup for unchanged resource checks

  11. Optimized Resource Config Caching

  12. Version-based caching instead of hash-based
  13. 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:

  1. JSON Serialization Optimization
  2. Use faster JSON library (orjson/ujson)
  3. Stream JSON directly to file
  4. Pre-compute static parts of JSON

  5. Parallel Processing

  6. Process independent resources in parallel
  7. Use thread pool for config generation

  8. Native Acceleration

  9. Implement critical paths in Rust
  10. 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