Drop the redundant axes(::SparsityPatternCSC, ::Integer) method (invalidates 2k+ ModelingToolkit instances on load) - #338
Merged
gdalle merged 1 commit intoSep 4, 2026
Conversation
`SparsityPatternCSC <: AbstractMatrix{Bool}` and defines `size`, so Base's
`axes(A::AbstractArray, d)` already returns `OneTo(size(S, d))`. The extra
method changes nothing for callers, but inserting it when the package loads
invalidates every `axes(A, d)` call site compiled earlier with an abstract
`A`; on the ModelingToolkit stack that is 2,049 instances, which throws away
those packages' precompile caches as soon as OrdinaryDiffEq is loaded.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Agent-Harness: Claude Code 2.1.259
Agent-Model: claude-fable-5-1
Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
ChrisRackauckas
marked this pull request as ready for review
September 4, 2026 18:05
Member
|
Seems like an easy win. |
Member
|
Agreed, docs failure is unrelated |
ChrisRackauckas
added a commit
to SciML/CommonWorldInvalidations.jl
that referenced
this pull request
Sep 4, 2026
This reverts commit e84633a and bumps to 1.2.2. The invalidation the canaries guarded against came from a single redundant method, `Base.axes(::SparsityPatternCSC, ::Integer)` in SparseMatrixColorings, which has now been removed at the source (JuliaDiff/SparseMatrixColorings.jl#338). With that gone, the canaries only cost every abstractly typed `axes(A, d)` call site its world-split, so they are no longer worth carrying. Agent-Harness: Claude Code 2.1.259 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #338 +/- ##
==========================================
- Coverage 99.20% 99.20% -0.01%
==========================================
Files 21 21
Lines 2151 2150 -1
==========================================
- Hits 2134 2133 -1
Misses 17 17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Removes
Base.axes(S::SparsityPatternCSC, d::Integer) = Base.OneTo(size(S, d))fromsrc/graph.jl.SparsityPatternCSC <: AbstractMatrix{Bool}and definessize, so Base's fallbackaxes(A::AbstractArray, d)already returns exactlyOneTo(size(S, d))(andOneTo(1)ford > 2, same as before). Addsaxes(A) == axes(S)and thed = 3case to the existingsizetestset so the behaviour stays pinned.Why
Adding that method at load time invalidates every
axes(A, d)call site that was compiled earlier with an abstractA(axes(::AbstractArray, ::Int64),axes(::AbstractMatrix, ::Int64),axes(::AbstractArray, ::Any)all take a backedge to the method table). SparseMatrixColorings is loaded by OrdinaryDiffEqDifferentiation, i.e. after ModelingToolkit, and on that stack the insertion kills 3,055 cached instances, 2,049 of them in ModelingToolkit / ModelingToolkitBase / ModelingToolkitTearing / Symbolics:__mtkcompile,_mtkcompile,maybe_build_initialization_problem,process_SciMLProblem,alias_elimination!,find_eq_solvables!,ODEProblem,NonlinearProblem. In practiceusing ModelingToolkit, OrdinaryDiffEqdiscards the model-building code that ModelingToolkit's precompile workload just cached.Measured with
SnoopCompileCore.@snoop_invalidations using OrdinaryDiffEqafterusing ModelingToolkit(Julia 1.12.7, ModelingToolkit 11.40, OrdinaryDiffEq 7.8.1, SparseMatrixColorings 0.4.27 vs this branchPkg.developed):axesinsertionusing OrdinaryDiffEq(The last column is
mtkcompile+ODEProblemfor a small ODE and a small DAE that ModelingToolkit's own workload compiles; with the invalidation those take 12.3 s and 3.4 s on first use even though they are in the pkgimage.)Tests
Pkg.test()on Julia 1.12.7:SparseMatrixColorings | 50464 pass, 31 broken (pre-existing) | 11m44s, tests passed.JuliaFormatter(BlueStyle) reports both touched files formatted.Context (analysis and scripts): https://github.com/ChrisRackauckas/InternalJunk/issues/88#issuecomment-5537967759. SciML also carries a defensive canary for this pattern in SciML/CommonWorldInvalidations.jl#45; this PR is the fix at the source.
🤖 Generated with Claude Code (model: claude-fable-5-1) on behalf of Chris Rackauckas
https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn