6. Performance Optimization¶
This chapter covers techniques for maximizing NLSQ performance.
6.1. Chapter Overview¶
- JIT Caching (10 min)
Understanding and optimizing JIT compilation caching.
- Memory Management (10 min)
Memory pools, budgets, and efficient data handling.
- Sparse Jacobians (10 min)
Leveraging sparsity for large problems.
- Profiling (10 min)
Using TRFProfiler and identifying bottlenecks.
6.2. Performance Quick Tips¶
Use GPU: 10-20x speedup for large datasets
Reuse CurveFit: JIT cached between calls
Use streaming: Memory-efficient for very large data
Loosen tolerances: Trade precision for speed
Profile first: Identify actual bottlenecks
# Fast pattern
fitter = CurveFit() # Create once
for x, y in datasets:
popt, pcov = fitter.curve_fit(model, x, y) # JIT reused