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

resample() performance #498

Open
chrhck opened this issue Mar 20, 2023 · 3 comments
Open

resample() performance #498

chrhck opened this issue Mar 20, 2023 · 3 comments

Comments

@chrhck
Copy link

chrhck commented Mar 20, 2023

Hi all,
I have a workflow which requires a lot of resampling. The default filter used in resample is currently a bottleneck in my workflow, where a lot of time is spent in evaluating the Kaiser window (more preceisely: https://specialfunctions.juliamath.org/stable/functions_list/#SpecialFunctions.besseli )
Any tips on how I can improve performance?

@dd0
Copy link

dd0 commented Jun 1, 2023

This might be a few months late, but I had the same problem: I want to resample many short signals with a real-valued resampling rate, for which the filter is quite long (~37k samples) and takes a while to compute. If the rate is constant, you can compute the filter once, and provide it as an argument to resample:

julia> s = rand(ComplexF32, 42000);

julia> ratio = 1/32.2;

julia> @time resample(s, ratio);
  0.025392 seconds (37.42 k allocations: 2.936 MiB)

julia> @time f = resample_filter(ratio);
  0.023044 seconds (37.38 k allocations: 1.426 MiB)

julia> @time resample(s, ratio, f);
  0.002592 seconds (34 allocations: 1.510 MiB)

Note that this only helps because the output length is significantly shorter than the filter length -- if s was much longer, or if ratio wasn't as small, the difference wouldn't be as significant.

Should this be mentioned in the documentation? resample_filter is currently undocumented, but it's exported, so it doesn't look like an internal function that the user should avoid.

@anowacki
Copy link
Contributor

I also have found resampling to be a bottleneck in some processing and this helps. It would be great if resample_filter was documented and made part of the API.

@anowacki
Copy link
Contributor

See also #506.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants