Skip to content

Add VF64-specialized LinearCache for shorter stack traces#896

Open
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:mainfrom
ChrisRackauckas-Claude:vf64-linear-cache-specialization
Open

Add VF64-specialized LinearCache for shorter stack traces#896
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:mainfrom
ChrisRackauckas-Claude:vf64-linear-cache-specialization

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

Implements the VF64 pattern for LinearCache and DefaultLinearSolverInit to reduce type string lengths in stack traces from ~1500 chars to ~500 chars per instance. This addresses the LinearSolve.jl component of SciML/DifferentialEquations.jl#1128.

Before: LinearCache had 12 type parameters and DefaultLinearSolverInit had 25 type parameters, producing ~1500 character type strings in stack traces.

After: LinearCacheVF64 has 4 type parameters and DefaultLinearSolverInitVF64 has 1 type parameter, producing ~500 character type strings. This is a 67% reduction.

New types

  • LinearCacheVF64{Tp, Tc, Tlv, S} — hardcodes A::Matrix{Float64}, b/u::Vector{Float64}, Pl/Pr::IdentityOperator, abstol/reltol::Float64, assumptions::OperatorAssumptions{Bool}
  • DefaultLinearSolverInitVF64{TA} — hardcodes all 24 factorization cache slot types for Matrix{Float64} at module load time via let/@eval
  • LinearCacheType = Union{LinearCache, LinearCacheVF64} — for backward-compatible dispatch
  • DefaultLinearSolverInitType = Union{DefaultLinearSolverInit, DefaultLinearSolverInitVF64}

How it works

  • When init() detects Matrix{Float64} + Vector{Float64} + DefaultLinearSolver, it automatically constructs a LinearCacheVF64 instead of LinearCache
  • All method signatures updated from cache::LinearCache to cache::LinearCacheType (Union-based dispatch)
  • Field names are identical between the two structs, so all field access works unchanged
  • Non-VF64 types (sparse matrices, non-Float64, custom solvers) still use the generic LinearCache

Files changed

  • src/vf64_types.jl (new) — VF64 type definitions, conversion, and constructor
  • src/common.jlLinearCacheVF64 struct, Union type, VF64 branch in __init
  • src/LinearSolve.jl — include, exports, moved defaultalg_symbol generic method earlier (fixes world age issue with @generated functions)
  • src/factorization.jl — dispatch updates, moved specialized defaultalg_symbol overloads
  • src/default.jl — dispatch updates
  • All other src/*.jl solver files — dispatch updates
  • All 16 extension files — dispatch updates

Test plan

  • All existing Pkg.test() tests pass (no regressions)
  • Basic solve correctness verified (A\b comparison)
  • VF64 type construction verified (cache isa LinearCacheVF64)
  • Cache mutation works (updating A and b)
  • Type string length verified (492 chars vs ~1500 chars before)

🤖 Generated with Claude Code

Implement the VF64 pattern for LinearCache and DefaultLinearSolverInit
to reduce type string lengths in stack traces from ~1500 chars to ~500 chars
per instance. This addresses the LinearSolve.jl component of
DifferentialEquations.jl#1128.

New types:
- LinearCacheVF64{Tp, Tc, Tlv, S}: 4 type params vs 12 in LinearCache,
  hardcodes A::Matrix{Float64}, b/u::Vector{Float64}, Pl/Pr::IdentityOperator,
  abstol/reltol::Float64, assumptions::OperatorAssumptions{Bool}
- DefaultLinearSolverInitVF64{TA}: 1 type param vs 25 in DefaultLinearSolverInit,
  hardcodes all 24 factorization cache slot types for Matrix{Float64}
- LinearCacheType = Union{LinearCache, LinearCacheVF64} for dispatch

The VF64 cache is automatically constructed when init() detects
Matrix{Float64} + Vector{Float64} + DefaultLinearSolver. All existing
dispatch is preserved through the Union type.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants