julia icon indicating copy to clipboard operation
julia copied to clipboard

effects: taint `:nothrow` effect on unknown `:static_parameter` (conservatively)

Open aviatesk opened this issue 2 years ago • 2 comments

With this commit, we taint :nothrow effect property correctly on access to unknown :static_parameter, e.g.:

unknown_sparam_throw(::Union{Nothing, Type{T}}) where T = (T; nothing)
@test Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Type{Int},))))
@test !Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_throw, ((Nothing,))))

This commit implements a very conservative analysis, and thus there is a room for improvement still, e.g.:

unknown_sparam_nothrow(x::Ref{T}) where {T} = (T; nothing)
@test_broken Core.Compiler.is_nothrow(Base.infer_effects(unknown_sparam_nothrow, (Ref,)))

fix #46771

aviatesk avatar Sep 16 '22 06:09 aviatesk

@Keno is it okay for now to merge this as is, and try to improve the accuracy of this nothrow analysis in a follow up PR (it seems a bit tricky than I expected though)?

aviatesk avatar Sep 18 '22 05:09 aviatesk

I would prefer to try to get at least some precision in at the same time, because I suspect we're relying on this bug for performance in a number of applications

Keno avatar Sep 18 '22 07:09 Keno

@aviatesk I rebased this branch, so that we can push forward Keno's PR more easily.

staticfloat avatar Feb 07 '23 00:02 staticfloat

Will this need to be backported to 1.9 since it's a bugfix to the effect system?

vchuravy avatar Feb 07 '23 12:02 vchuravy

Will this need to be backported to 1.9 since it's a bugfix to the effect system?

Yes, I think we should do it.

aviatesk avatar Feb 07 '23 14:02 aviatesk

@nanosoldier runbenchmarks("inference", vs=":master")

aviatesk avatar Feb 07 '23 14:02 aviatesk

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

nanosoldier avatar Feb 07 '23 15:02 nanosoldier

given that there aren't any regressions here, good to merge?

oscardssmith avatar Feb 07 '23 16:02 oscardssmith

There is one test failure on this PR, so don't merge now.

aviatesk avatar Feb 07 '23 17:02 aviatesk

@nanosoldier runbenchmarks("inference", vs=":master")

aviatesk avatar Feb 08 '23 05:02 aviatesk

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

nanosoldier avatar Feb 08 '23 06:02 nanosoldier