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

FFT Window Threadsafety #7145

Merged
merged 3 commits into from
Jun 2, 2024

Conversation

marcusmueller
Copy link
Member

@marcusmueller marcusmueller commented Feb 21, 2024

Description

I add locks around window setting/usage.

As a drive-by improvement, let's not use floor, ceil to implement (inherent) integer division semantics.

Related Issue

Fixes #7144

Which blocks/areas does this affect?

FFT

Testing Done

Checklist

@willcode willcode added fft Bug Fix Backport-3.10 Should be backported to 3.10 labels Feb 22, 2024
@marcusmueller marcusmueller marked this pull request as ready for review February 22, 2024 18:43
Copy link
Member

@daniestevez daniestevez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me, but performance-wise I'm wondering if it wouldn't be better to get the window lock at the beginning of the work() function and hold it for the whole duration of work(). I'm slightly worried that if the FFT size is small, locking and unlocking the mutex for each individual FFT might introduce too much overhead.

@willcode

This comment was marked as resolved.

Copy link
Member

@mbr0wn mbr0wn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with @daniestevez, although I don't know about the performance overhead. But what if we flip it around: If we unlock sooner, we get better concurrency. To which I say "so what", what's the value of being able to call set_window() more often from a different thread. So if we lock for the duration of work(), we get maybe some, maybe very little performance gains, but we lose nothing of value.

gr-fft/python/fft/qa_fft.py Outdated Show resolved Hide resolved
@daniestevez
Copy link
Member

@mbr0wn that's exactly what I had in mind. set_window() will typically be called infrequently, and it can wait until work() finishes to update the window.

@marcusmueller
Copy link
Member Author

I'm fine either way, but I remember I had to be finer in locking granularity in one place, because otherwise I could deadlock our CI, then made it consistent in every place. Will have to check what the precise reason was, and whether it affects work, probably not. Anyways, currently no time, so this becomes a draft for now.

@marcusmueller marcusmueller marked this pull request as draft March 7, 2024 14:52
@mbr0wn mbr0wn added the medium label Mar 11, 2024
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
…antics

Also, remove unused config.h

Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
@marcusmueller marcusmueller marked this pull request as ready for review June 2, 2024 20:41
@willcode willcode merged commit f622650 into gnuradio:main Jun 2, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport-3.10 Should be backported to 3.10 Bug Fix fft medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FFT block: thread-unsafe window setting
5 participants