# Runtime dispatch for plan\_fft

**URL:** <https://discourse.julialang.org/t/runtime-dispatch-for-plan-fft/126958>\
**Category:** Performance\
**Tags:** jet, fft\
**Created:** [March 14, 2025, 3:47pm UTC](https://discourse.julialang.org/t/runtime-dispatch-for-plan-fft/126958 "2025-03-14T15:47:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Post date:** [March 14, 2025, 3:47pm UTC](https://discourse.julialang.org/t/runtime-dispatch-for-plan-fft/126958/1 "2025-03-14T15:47:37Z")

</div>

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!`:

```julia
using JET
using FFTW

```

```julia
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?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 14, 2025, 5:24pm UTC](https://discourse.julialang.org/t/runtime-dispatch-for-plan-fft/126958/2 "2025-03-14T17:24:10Z")

</div>

> [@henry2004y](#):
>
> 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.
