Skip to content

Latent data race in WelchConfig #629

@palday

Description

@palday

The WelchConfig docstring has an interesting nugget:

DSP.jl/src/periodograms.jl

Lines 545 to 549 in d08699a

!!! note
WelchConfig precomputes an fft plan, and preallocates the necessary intermediate buffers.
Thus, repeated calls to `welch_pgram` that use the same `WelchConfig` object
will be more efficient than otherwise possible.

The latter part encourages re-use, but the former part hints that concurrent re-use may have a race condition. It might be useful to call this out explicitly so that a naive

config = WelchConfig(...)
psds = Vector{Periodogram}(undef, length(signals))
Threads.@threads for (idx, sig) in enumerate(signals)
    psds[idx] = welch_pgram(sig, config)
end

doesn't become a user footgun

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions