Level 2: JIT Compilation
Level 2 provides JIT compilation for CPU-bound loops and numerical code.
Overview
| Aspect | Value |
|---|---|
| First Call Overhead | ~100-500ms (compilation) |
| Subsequent Calls | ~5μs |
| Memory | ~50MB |
| Best For | CPU-bound loops |
JIT Backends
| Python Version | Primary Backend | Fallback |
|---|---|---|
| 3.9-3.10 | Numba | Pyston-Lite |
| 3.11-3.12 | Numba | None |
| 3.13+ | Native JIT | Numba |
Enabling Level 2
import epochly@epochly.optimize(level=2)def compute(data):result = 0for x in data:result += x ** 2return result
Supported Code Patterns
- Numerical Loops: Simple arithmetic in loops
- Array Operations: Element-wise array processing
- Nested Loops: Multi-dimensional iteration
Speedup Factors
| Operation Type | Typical Speedup |
|---|---|
| GPU elementwise (10M+) | 66–70x |
| GPU convolution (batched) | 14–19x |
| Parallel CPU (heavy tasks) | 8–12x |
Best Practices
- Use for Large Data: GPU shines on arrays with 10M+ elements
- Use for Heavy Tasks: Parallel execution works best with tasks >100ms each
- Don't Force It: Epochly yields to normal behavior when it can't help