Force inference of a type argument#1074
Merged
amontoison merged 1 commit intoJuliaSmoothOptimizers:mainfrom Feb 23, 2026
Merged
Force inference of a type argument#1074amontoison merged 1 commit intoJuliaSmoothOptimizers:mainfrom
amontoison merged 1 commit intoJuliaSmoothOptimizers:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the allocate_if helper in krylov_utils.jl to force inference of the storage type argument, avoiding type-instability during workspace allocation.
Changes:
- Update
allocate_if’s vector-allocation overload to take the storage type as::Type{S} where S.
Comments suppressed due to low confidence (1)
src/krylov_utils.jl:285
- Now that this overload forces the storage type via
::Type{S}, the matrix overload below (allocate_if(bool, workspace, v, S, m::Int, n::Int)) still acceptsSas an untyped value, which prevents the compiler from inferringSand can reintroduce the same type-instability for matrix allocations. Consider updating that overload to also take::Type{S} where Sfor consistency and performance.
function allocate_if(bool, workspace, v, ::Type{S}, u) where S
start_allocation_time = time_ns()
if bool && isempty(workspace.:($v)::S)
workspace.:($v)::S = similar(u)
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1074 +/- ##
==========================================
+ Coverage 94.68% 97.69% +3.01%
==========================================
Files 45 50 +5
Lines 8027 10011 +1984
==========================================
+ Hits 7600 9780 +2180
+ Misses 427 231 -196 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
amontoison
approved these changes
Feb 23, 2026
a985192
into
JuliaSmoothOptimizers:main
42 of 44 checks passed
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.
This prevents a type-instability