Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore_throw support #4

Merged
merged 5 commits into from
Oct 4, 2023
Merged

Add ignore_throw support #4

merged 5 commits into from
Oct 4, 2023

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Oct 2, 2023

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 topolarity requested a review from gbaraldi October 2, 2023 17:06
@topolarity topolarity force-pushed the ct/ignore-throw branch 3 times, most recently from 0f5d166 to 1f8df2a Compare October 2, 2023 17:13
@topolarity
Copy link
Member Author

CI failures are due to #3

@topolarity
Copy link
Member Author

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

@topolarity topolarity force-pushed the ct/ignore-throw branch 2 times, most recently from ea32105 to 49e5069 Compare October 3, 2023 17:26
@topolarity topolarity changed the title Add preliminary ignore_throw support Add ignore_throw support Oct 3, 2023
This allows us to filter allocations that occur only when throwing
errors in called functions.

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

After:
```julia
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
```
This allows us to ignore calls to functions that occur only within
throw/catch blocks.
Since we assume forward-progress, being post-dominated by an
`unreachable` means that path must encounter a throw().

This assumption is being re-considered for upcoming versions of Julia,
but for the moment it still stands.
@topolarity topolarity merged commit 0d48076 into main Oct 4, 2023
1 of 2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the ct/ignore-throw branch October 4, 2023 18:42
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