Skip to content

Force inference of a type argument#1074

Merged
amontoison merged 1 commit intoJuliaSmoothOptimizers:mainfrom
timholy:teh/specialize
Feb 23, 2026
Merged

Force inference of a type argument#1074
amontoison merged 1 commit intoJuliaSmoothOptimizers:mainfrom
timholy:teh/specialize

Conversation

@timholy
Copy link
Copy Markdown
Contributor

@timholy timholy commented Feb 22, 2026

This prevents a type-instability

Copilot AI review requested due to automatic review settings February 22, 2026 23:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 accepts S as an untyped value, which prevents the compiler from inferring S and can reintroduce the same type-instability for matrix allocations. Consider updating that overload to also take ::Type{S} where S for 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
Copy link
Copy Markdown

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.69%. Comparing base (9536ef7) to head (dffa351).
⚠️ Report is 121 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amontoison amontoison merged commit a985192 into JuliaSmoothOptimizers:main Feb 23, 2026
42 of 44 checks passed
@timholy timholy deleted the teh/specialize branch February 23, 2026 09:02
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.

3 participants