Skip to content

perf: improve exact arithmetic benchmark coverage with diverse inputs #80

@acgetchell

Description

@acgetchell

Dependencies

Summary

The current benches/exact.rs benchmarks use a single fixed well-conditioned matrix per dimension. This measures typical-case performance but misses important input classes where exact arithmetic performance varies significantly.

Current State

Each dimension (D=2–5) benchmarks one diagonally dominant matrix with small entries (matrix_entry produces values near D+1 on the diagonal, small off-diagonal). The only exception is near_singular_3x3, which benchmarks det_sign_exact and det_exact but not solve_exact.

This is methodologically sound for reproducibility but leaves gaps:

  • No near-singular solve benchmarks (the primary use case for exact solve)
  • No inputs that stress BigInt intermediate value growth
  • No variance measurement across different input structures

Proposed Changes

1. Near-singular solve benchmarks

Add solve_exact and solve_exact_f64 benchmarks for near-singular matrices (at least D=3). These are the inputs where exact solve matters most and where intermediate values grow largest.

2. Adversarial BigInt growth inputs

Add a matrix with large entries (e.g. entries near f64::MAX / 2) that maximizes intermediate BigInt bit-lengths during Bareiss/Gauss elimination. This stress-tests the allocator and big-integer multiply.

3. Random-input percentile benchmarks (optional)

Consider adding a benchmark group that runs N random matrices per dimension and reports median/p95/p99. This captures variance from branch misprediction, allocation patterns, and intermediate value sizes that a single fixed input misses.

4. Ill-conditioned matrix benchmarks

Add a Hilbert-like or Vandermonde matrix where entries span many orders of magnitude. This exercises different exponent-scaling behavior in the f64_decomposeBigInt path.

Benefits

  • More representative performance characterization for the exact arithmetic use case (geometric predicates on near-degenerate configurations)
  • Better detection of performance regressions on adversarial inputs
  • Stronger empirical evidence for docs/PERFORMANCE.md

Implementation Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformancePerformance related issues

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions