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

Use Bessels.jl for Bessel function calculations #538

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

anowacki
Copy link
Contributor

Replace calls to SpecialFunctions.besseli(0, ...) with calls to
Bessels.besseli0(...), adding Bessels.jl
(https://github.com/JuliaMath/Bessels.jl) as a dependency.

When resampling signals with a very low or high arbitrary rate, the call
to Windows.kaiser is what dominates. Profiling this, most of the time
is taken up by the call to SpecialFunctions.besseli. This allocates,
but also the computation is just fundamentally slow for these arguments.

Replacing these calls with those to Bessels.besseli0 gives a factor
of 17 speedup when resampling a 1000-point random trace to a rate of
0.02.

Closes #506.

Copy link

codecov bot commented Feb 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9791404) 97.56% compared to head (2a7de1b) 97.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #538   +/-   ##
=======================================
  Coverage   97.56%   97.56%           
=======================================
  Files          18       18           
  Lines        3125     3125           
=======================================
  Hits         3049     3049           
  Misses         76       76           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anowacki
Copy link
Contributor Author

Issue with macOS x64 CI seems to be a problem with the Codecov coverage upload rather than the code itself, so unless you have strong opinions on not supporting Bessels.jl v0.1, this seems ready.

@wheeheee
Copy link
Member

Sorry for the slow response, was searching JuliaHub and the general registry on mobile. While I'm in principle fine with including 0.1, of Bessels' dependents, only SparseIR.jl v0.94 (which has only 2 dependents) had a Compat for 0.1, and it changed compat to 0.2 in the next release.
All other dependent packages have compats for 0.2, so my opinion is that we should go with the majority here.

Replace calls to `SpecialFunctions.besseli(0, ...)` with calls to
`Bessels.besseli0(...)`, adding Bessels.jl
(https://github.com/JuliaMath/Bessels.jl) as a dependency.

When resampling signals with a very low or high arbitrary rate, the call
to `Windows.kaiser` is what dominates.  Profiling this, most of the time
is taken up by the call to `SpecialFunctions.besseli`. This allocates,
but also the computation is just fundamentally slow for these arguments.

Replacing these calls with those to `Bessels.besseli0` gives a factor
of 17 speedup when resampling a 1000-point random trace to a rate of
0.02.

Closes JuliaDSP#506.
@anowacki
Copy link
Contributor Author

Okay, no problem—I've changed that in the updated commit. And your response is by no description slow! Thank you for taking on some of the DSP.jl maintenance!

@wheeheee wheeheee merged commit 4213e9a into JuliaDSP:master Feb 19, 2024
11 checks passed
@anowacki anowacki deleted the an/bessels-jl branch February 20, 2024 11:54
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

Successfully merging this pull request may close these issues.

kaiser performance: use Bessels.jl?
3 participants