JuliaLang / AllocCheck.jl

AllocCheck
Other
215 stars 8 forks source link

Add `ignore_throw` support #4

Closed topolarity closed 11 months ago

topolarity commented 11 months ago

This allows us to filter allocations that occur only when throwing errors in called functions.

Before this change:

julia> check_allocs(*, (Matrix{Float64},Matrix{Float64}))
20-element Vector{AllocCheck.AllocInstance}:
...

After:

julia> check_allocs(*, (Matrix{Float64},Matrix{Float64}); ignore_throw=true)
1-element Vector{AllocCheck.AllocInstance}:
 Allocation of Matrix{Float64} in ./boot.jl:477
  | Array{T,2}(::UndefInitializer, m::Int, n::Int) where {T} =

Stacktrace:
 [1] Array
   @ ./boot.jl:477 [inlined]
 [2] Array
   @ ./boot.jl:485 [inlined]
 [3] similar
   @ ./array.jl:418 [inlined]
 [4] *(A::Matrix{Float64}, B::Matrix{Float64})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:113

The two outstanding limitations are:

  1. This does not yet filter catch blocks, but it should Done
  2. This does not yet filter functions that are called only from throw/catch blocks, but it should Done
topolarity commented 11 months ago

CI failures are due to https://github.com/JuliaComputing/AllocCheck.jl/pull/3

topolarity commented 11 months ago

Caveats above have been resolved, so ignore_throw=true is now feature-complete with this PR 🎉