Benchmarks
Lazy normalization preserves sparse storage. Eager normalization constructs a dense normalized matrix. Compare a complete regression fit, including peak memory, and then individual operations with setup excluded.
8,192 × 512 rows × columns · f64 · mean centering + SD scaling
The normalized dense matrix alone occupies 32 MiB.
A complete fit
Fit ridge regression with gradient descent across seven nonzero densities, from 0.1% to 100%. Both paths use the same data, algorithm, and accuracy target, starting with the raw sparse input.
Total wall-clock time
Peak memory during the fit
Memory counts requested Rust bytes, excluding allocator overhead and native-library allocations. It does not measure total process RAM.
Fit measurements and convergence
Both paths satisfy the same gradient tolerance and produce matching coefficients and objectives. Iterations count coefficient updates; the CSV also records the objective and final gradient norm.
| Nonzeros (%) | Strategy | Total (ms) | Peak (MiB) | Iterations |
|---|---|---|---|---|
| 0.101 | Lazy sparse | 2.803 | 0.217 | 37 |
| 0.101 | Eager dense | 3,586.535 | 32.213 | 37 |
| 0.302 | Lazy sparse | 3.256 | 0.346 | 27 |
| 0.302 | Eager dense | 2,592.192 | 32.342 | 27 |
| 1.001 | Lazy sparse | 6.978 | 0.793 | 26 |
| 1.001 | Eager dense | 2,624.951 | 32.789 | 26 |
| 2.997 | Lazy sparse | 14.746 | 2.07 | 26 |
| 2.997 | Eager dense | 2,470.889 | 34.067 | 26 |
| 9.981 | Lazy sparse | 43.894 | 6.54 | 26 |
| 9.981 | Eager dense | 2,436.39 | 38.537 | 26 |
| 29.972 | Lazy sparse | 136.454 | 19.334 | 26 |
| 29.972 | Eager dense | 2,543.672 | 51.33 | 26 |
| 100 | Lazy sparse | 586.178 | 64.152 | 27 |
| 100 | Eager dense | 3,299.305 | 96.148 | 27 |
Individual operations
These timings measure one product with normalization already fitted and eager storage already materialized. Outputs are reused; any scratch allocation inside the operation is included.
Forward product: X̃v
Transpose product: X̃ᵀu
Operation measurements and memory breakdown
The memory column includes normalization, eager construction, and ten forward/transpose pairs, with the sparse source retained. This is a separate workload from the complete fit above. The CSV includes normalized storage, workspace, setup timings, and raw sparse timings.
| Nonzeros (%) | Strategy | Forward (µs) | Transpose (µs) | Peak (MiB) |
|---|---|---|---|---|
| 0.101 | Lazy sparse | 21.421 | 20.655 | 0.213 |
| 0.101 | Eager dense | 2,014.339 | 56,119.126 | 32.209 |
| 0.302 | Lazy sparse | 28.971 | 28.997 | 0.342 |
| 0.302 | Eager dense | 2,914.567 | 69,790.233 | 32.338 |
| 1.001 | Lazy sparse | 93.636 | 71.163 | 0.789 |
| 1.001 | Eager dense | 1,793.026 | 63,598.909 | 32.785 |
| 2.997 | Lazy sparse | 234.338 | 213.036 | 2.067 |
| 2.997 | Eager dense | 2,881.038 | 46,105.336 | 34.063 |
| 9.981 | Lazy sparse | 341.296 | 266.851 | 6.537 |
| 9.981 | Eager dense | 1,435.458 | 44,911.219 | 38.533 |
| 29.972 | Lazy sparse | 1,044.502 | 919.946 | 19.33 |
| 29.972 | Eager dense | 1,459.732 | 45,563.346 | 51.326 |
| 100 | Lazy sparse | 3,037.598 | 3,109.39 | 64.148 |
| 100 | Eager dense | 1,398.147 | 45,997.752 | 96.145 |
October 27, 2026 · Intel(R) Core(TM) Ultra 7 155U · 1 thread · 30 timing samples per case. Both axes use logarithmic scales. Points show measured nonzero densities; lines connect the samples.
Fit measurements (CSV) · Operation measurements (CSV) · Run metadata
Methodology
These are synthetic, single-threaded comparisons of sparse lazy normalization and dense eager normalization. Each backend uses its own dense destination. They illustrate the trade-off for this workload; the faster choice depends on the data, operations, and hardware.
Complete regression fit
Both paths solve the same ridge problem in normalized coordinates:
The shared gradient descent example uses reusable output buffers and starts from zero coefficients. Each fit includes 30 power iterations to estimate an initial step size, followed by gradient descent with backtracking. Both representations stop when the gradient's L2 norm is at most , where is the initial gradient. The harness rejects unconverged fits and checks that coefficients and objectives agree before timing. The downloadable results include iteration counts, objectives, and final gradient norms.
Timing starts with the raw matrix and response already allocated. It includes fitting centers and scales, dense materialization for the eager path, all solver setup, solving to convergence, and dropping the fitted result. Each timed fit starts afresh. Fixture generation and backend conversion are excluded.
Peak memory
A separate executable measures the largest increase in live requested Rust bytes across normalization, materialization, and the complete solve. It adds the original sparse input and response, which both paths retain throughout the fit. This includes the eager dense matrix and solver workspace while they are live. It measures the complete workflow directly; it does not add phase peaks.
The figures exclude allocator overhead, native-library allocations, and unrelated process state. They measure allocation bytes rather than process RAM. Reallocation is recorded at its resulting size. An application that releases its source after eager construction may retain less memory during solving, though construction still requires the source and destination to coexist.
Fixtures and individual operations
The size selector offers 2,048 × 128, 8,192 × 512, and 16,384 × 1,024 matrices and updates all four charts and their tables. Dimensions are rows × columns. Matrices use canonical CSC storage, f64 values, and usize indices. Fixtures use ChaCha8Rng with seed 205 and target nonzero fractions 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, and 1. Each cell is selected independently. Stored values are positive, with varying column scales, so centering generally turns structural zeros into nonzero logical values. The response is the deterministic sequence , starting at . Mean centering and SD scaling are fitted separately for each complete fit; exact zero scales are replaced with one.
Individual products reuse the matrix, fitted parameters, input vectors, and output buffers. They include any scratch allocation inside the public *_into methods. Forward and transpose inputs are deterministic, nonconstant vectors with nonzero sums. The harness checks products against the eagerly normalized matrix before timing.
Timings use Criterion means and 95% bootstrap confidence intervals. The 8,192 × 512 collection uses 30 samples, 0.3 seconds of warmup, at least one second of measurement, and 10,000 bootstrap resamples. The other sizes use ten samples, 0.05 seconds of warmup, at least 0.1 seconds of measurement, and 1,000 resamples. Long fits extend measurement to collect the requested samples. Compilation and allocation profiling finish before timing begins. Intervals describe variation on the collection machine; they do not describe variability across hardware or sparse patterns. The run metadata records the CPU, compiler, collection date, thread settings, and solver settings.
Reproduce
# Collect complete fits, operation timings, and allocation profiles.
bash scripts/bench-least-squares.sh
# Use shorter timing settings for a quick comparison.
LAZYMATRIX_BENCH_QUICK=1 bash scripts/bench-least-squares.sh
# Publish a checked collection and regenerate the website plots.
mkdir -p benches/least_squares
cp target/least-squares/{results.csv,products.csv,metadata.json} benches/least_squares/
task website:check
# Check small fixtures and convergence without collecting timing samples.
LAZYMATRIX_BENCH_SMOKE=1 cargo bench --locked --bench least_squares \
--features ndarray,sprs,faer -- --testThe website builds its charts from checked-in measurements. It never runs benchmarks. The measurement notes describe the collector and its outputs.
Additional measurements
The operation CSV also contains SD scaling without centering, unnormalized sparse products, setup timings, and memory breakdowns. Scaling alone preserves structural zeros; its dense eager path compares with the crate's dense materialization API rather than an optimized sparse scaling strategy.
The earlier full operation sweep covers tall, square, and wide matrices at 2, 32, and 128 MiB of dense storage. It was collected on a different machine; its metadata and measurement notes remain available. Earlier consumer fitting profiles are also retained separately.

