Runtime dispatch for plan_fft

,

Hi,

I am learning about JET.jl while optimizing a function that involves FFT. I happened to find that JET.jl detected a runtime dispatch for plan_fft or plan_fft!:

using JET
using FFTW
julia> @report_opt plan_fft!(zeros(ComplexF64, 8))
═════ 1 possible error found ═════
┌ plan_fft!(X::Vector{ComplexF64}) @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\fft.jl:805
│┌ plan_fft!(X::Vector{ComplexF64}; kws::@Kwargs{}) @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\fft.jl:805
││┌ plan_fft!(X::Vector{ComplexF64}, region::Tuple{Int64}) @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\fft.jl:791
│││┌ plan_fft!(X::Vector{ComplexF64}, region::Tuple{Int64}; flags::UInt32, timelimit::Float64, num_threads::Nothing) @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\fft.jl:801
││││┌ (FFTW.cFFTWPlan{…})(X::Vector{…}, Y::Vector{…}, region::Tuple{…}, flags::UInt32, timelimit::Float64) @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\FFTW.jl:52
│││││┌ destroy_deferred() @ FFTW C:\Users\hyzho\.julia\packages\FFTW\mFpUb\src\fft.jl:339
││││││┌ foreach(f::typeof(FFTW.unsafe_destroy_plan), itr::Vector{FFTW.FFTWPlan}) @ Base ./abstractarray.jl:3187
│││││││ runtime dispatch detected: f::typeof(FFTW.unsafe_destroy_plan)(%36::FFTW.FFTWPlan)::Any

Is this a performance issue that I should care about?

No, because it only affects garbage collection of plans (and only in relatively rare cases where there was thread contention when the initial deallocation was attempted).

Also, the plan_fft call itself shouldn’t be in a performance-critical path — the intended usage of FFTW is that, if performance matters, you should create plans once and then re-use them many times.

1 Like