Daily Perf Improver - Add comprehensive linear algebra benchmarks #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive benchmarking infrastructure for linear algebra operations as part of Phase 1 (Quick Wins) of the performance improvement plan. This establishes baseline performance metrics for critical linear algebra operations that were previously not benchmarked.
Performance Goal
Goal Selected: Add benchmarks for linear algebra operations (Phase 1, Priority: HIGH)
Rationale: The performance research plan identified that while vector and matrix operations had benchmarks, linear algebra operations (QR, LU, Cholesky, EVD, linear system solving) had no benchmarking coverage. These operations are fundamental to scientific computing, statistics, and machine learning applications, making their performance critical for the library's value proposition.
Changes Made
New Benchmarks Added (21 total)
All benchmarks test three matrix sizes (10×10, 30×30, 50×50) and use
MemoryDiagnoser
to track allocations.QR Decomposition (3 benchmarks):
LU Decomposition (3 benchmarks):
Cholesky Decomposition (3 benchmarks):
Eigenvalue Decomposition (3 benchmarks):
Linear System Solving (3 benchmarks):
Matrix Inverse (3 benchmarks):
Least Squares (3 benchmarks):
Files Modified
benchmarks/FsMath.Benchmarks/LinearAlgebra.fs
(new file, 174 lines)benchmarks/FsMath.Benchmarks/FsMath.Benchmarks.fsproj
- Added LinearAlgebra.fsbenchmarks/FsMath.Benchmarks/Program.fs
- Registered LinearAlgebraBenchmarksApproach
--job short
Performance Measurements
Test Environment
Results Summary by Operation Type
QR Decomposition
Shows expected O(mn²) scaling for m×n matrices.
LU Decomposition
Significantly faster than QR, expected O(n³) scaling.
Cholesky Decomposition
Fastest decomposition (2× faster than LU) for symmetric positive-definite matrices.
Eigenvalue Decomposition (EVD)
Most expensive operation, involves iterative algorithms.
Linear System Solving
Dominated by LU decomposition cost.
Matrix Inverse
More expensive than single system solve (solves n systems).
Least Squares
Dominated by QR decomposition cost.
Key Observations
Performance Scaling Analysis
All operations scale as expected. EVD shows higher variance due to iterative nature.
Replicating the Performance Measurements
To replicate these benchmarks:
Results are saved to
BenchmarkDotNet.Artifacts/results/
in multiple formats (GitHub MD, HTML, CSV).Testing
✅ All 132 tests pass
✅ All 21 new benchmarks compile successfully
✅ All benchmarks are discoverable via
--list flat
✅ All benchmarks execute without errors
✅ Memory diagnostics enabled and working
Next Steps
This PR establishes comprehensive baseline measurements for linear algebra operations. Based on these measurements and the performance plan, future work includes:
Phase 1 (remaining):
Phase 2 (algorithmic improvements):
Phase 3 (advanced optimizations):
Related Issues/Discussions
🤖 Generated with Claude Code