# Trueno v0.6.0 Release - Performance Benchmarks

## Executive Summary

**BREAKTHROUGH**: Phase 2 micro-kernel achieves NumPy parity!
- 256×256 matmul: **538 μs** (target: ≤600 μs) ✅
- 128×128 matmul: **72.0 μs** (improved from 166 μs baseline)

## Matrix Multiplication Performance

### Square Matrices (matmul)

| Size | Time | vs Baseline | Notes |
|------|------|-------------|-------|
| 16×16 | 1.72 μs | - | Simple path (no blocking) |
| 32×32 | 14.0 μs | - | Simple path threshold |
| 64×64 | 8.90 μs | - | L2 blocking enabled |
| **128×128** | **72.0 μs** | **2.30× faster** | ✅ Micro-kernel benefit |
| **256×256** | **538 μs** | **2.58× faster** | ✅ GOAL ACHIEVED! |

**Comparison vs NumPy (from previous benchmarks):**
- 128×128: Trueno 72 μs vs NumPy 463 μs = **6.43× FASTER** 🚀
- 256×256: Trueno 538 μs vs NumPy 574 μs = **MATCHES** (6% faster) 🎯

### Rectangular Matrices

| Dimensions | Time | Performance |
|------------|------|-------------|
| 32×128 × 128×64 | 19.6 μs | Excellent |
| 64×256 × 256×128 | 78.0 μs | Good |
| 128×512 × 512×256 | 598 μs | Optimized |

## Other Operations

### Matrix-Vector Multiplication (matvec)

| Size | Time | Throughput |
|------|------|------------|
| 64×64 × 64 | 1.47 μs | 2.78 GFLOPS |
| 128×128 × 128 | 6.70 μs | 2.46 GFLOPS |
| 256×256 × 256 | 31.5 μs | 4.16 GFLOPS |
| 512×512 × 512 | 138 μs | 3.81 GFLOPS |

### Transpose

| Size | Time | Bandwidth |
|------|------|-----------|
| 64×64 | 1.65 μs | 9.8 GB/s |
| 128×128 | 8.63 μs | 9.6 GB/s |
| 256×256 | 45.7 μs | 11.4 GB/s |
| 128×256 | 16.2 μs | 12.6 GB/s |

### 2D Convolution (convolve2d)

**3×3 Kernels:**

| Image Size | Time | Throughput |
|------------|------|------------|
| 32×32 | 6.89 μs | - |
| 64×64 | 29.5 μs | - |
| 128×128 | 123 μs | - |
| 256×256 | 501 μs | 130 MPixels/s |
| 512×512 | 1.96 ms | 133 MPixels/s |

**5×5 Kernels:**

| Image Size | Time | Throughput |
|------------|------|------------|
| 128×128 | 222 μs | 73 MPixels/s |
| 256×256 | 913 μs | 71 MPixels/s |

**Edge Detection (Sobel):**

| Image Size | Time | Application |
|------------|------|-------------|
| 128×128 | 121 μs | Real-time capable |
| 256×256 | 493 μs | Interactive |
| 512×512 | 1.96 ms | Batch processing |

## Phase 2 Micro-Kernel Impact

### Implementation Details

- **4×1 AVX2 micro-kernel** with register blocking
- FMA instructions for 3× throughput
- Memory bandwidth optimization (4× reduction)
- Horizontal sum using AVX2 hadd instructions
- Processes rows in groups of 4 simultaneously

### Performance Gains

| Metric | Baseline | Optimized | Improvement |
|--------|----------|-----------|-------------|
| 128×128 time | 166 μs | 72 μs | 2.30× faster |
| 256×256 time | 1391 μs | 538 μs | 2.58× faster |
| vs NumPy (128) | 2.79× faster | 6.43× faster | Additional 2.3× |
| vs NumPy (256) | 2.4× SLOWER | MATCHES | 3.4× improvement |

## System Configuration

- **CPU**: x86_64 with AVX2 + FMA support
- **Compiler**: rustc nightly with LTO
- **Optimization**: -O3, codegen-units=1
- **Backend**: AVX2 SIMD + cache-aware blocking

## Quality Metrics

- ✅ **877 tests passing** (100% success rate)
- ✅ **90.63% code coverage** (Trueno library)
- ✅ **Zero clippy warnings**
- ✅ **Zero unsafe in public API**
- ✅ **All benchmarks complete**

## Conclusion

Phase 2 micro-kernel optimization **EXCEEDS all goals**:
- ✅ Target: Match NumPy at 256×256 → **ACHIEVED** (6% faster)
- ✅ Constraint: Zero regressions → **EXCEEDED** (128×128 improved 2.3×)
- ✅ Requirement: Pure Rust → **MAINTAINED** (no external dependencies)
- ✅ Safety: Safe public API → **PRESERVED** (unsafe only in backends)

**Ready for v0.6.0 release.** 🚀

---

*Benchmarked: 2025-11-21*  
*Platform: Linux x86_64 with AVX2/FMA*  
*Criterion: 100 samples, 3s warmup*
