Skip to content

Conversation

@DanielVandH
Copy link
Member

@DanielVandH DanielVandH commented Oct 31, 2025

Relies on JuliaArrays/LazyArrays.jl#386. Don't think the performance in the simple benchmark below is affected by JuliaArrays/LazyArrays.jl#383

Puts the MulAddAccumulate's cache_filldata! method behind a function barrier, cutting the number of allocations roughly in half for a very simple example. On current release:

using LazyArrays, SemiclassicalOrthogonalPolynomials, BenchmarkTools, InfiniteArrays
using SemiclassicalOrthogonalPolynomials: MulAddAccumulate
@benchmark copyto!(dest, src) setup=begin
    A = Vcat(1, cache(2:3), cache(4:∞))
    B = Vcat(cache(1:5), [1, 2], cache(3:∞))
    src = view(MulAddAccumulate(A, B), 1:100_000)
    dest = similar(src)
end

BenchmarkTools.Trial: 123 samples with 1 evaluation per sample.
 Range (min  max):  36.005 ms  72.708 ms  ┊ GC (min  max): 0.00%  3.77%
 Time  (median):     38.956 ms              ┊ GC (median):    4.51%
 Time  (mean ± σ):   40.786 ms ±  5.312 ms  ┊ GC (mean ± σ):  4.01% ± 2.82%

      ▂█▁
  ▃▄▃▃███▅▄▃▃▆▂▃▂▁▂▃▂▁▂▂▁▂▃▂▁▁▂▁▁▁▁▂▁▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▂▁▁▁▂ ▂
  36 ms           Histogram: frequency by time          65 ms <

 Memory estimate: 19.16 MiB, allocs estimate: 797057.

On this PR:

BenchmarkTools.Trial: 142 samples with 1 evaluation per sample.
 Range (min  max):  31.669 ms  48.247 ms  ┊ GC (min  max): 0.00%  5.63%
 Time  (median):     35.093 ms              ┊ GC (median):    6.51%
 Time  (mean ± σ):   35.255 ms ±  2.779 ms  ┊ GC (mean ± σ):  4.34% ± 3.45%

     ▄▁▂      ▇██▅
  ▄▃▆████▅▃▅▅▆█████▅▄▃▃▃▃▁▅▁▄▁▁▃▄▃▃▁▁▁▁▃▁▁▁▁▁▁▁▁▁▃▁▁▁▃▁▁▁▁▁▁▄ ▃
  31.7 ms         Histogram: frequency by time          47 ms <

 Memory estimate: 17.68 MiB, allocs estimate: 399625.

Doesn't really end up making as much of a difference inside divdiff for a HalfWeighted{:a} polynomial though, e.g.

@benchmark D[1:n, 1:n] setup = begin
    P = SemiclassicalJacobi(2.0, 1 / 2, 0, 1 / 2);
    Q = SemiclassicalOrthogonalPolynomials.HalfWeighted{:a}(P);
    D = diff(Q).args[2];
    n = 1000;
end

gives roughly the same results. Still need to make some performance improvements there as discussed.

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.97%. Comparing base (6388cba) to head (757fb9a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #147      +/-   ##
==========================================
+ Coverage   94.93%   94.97%   +0.03%     
==========================================
  Files           4        4              
  Lines         671      676       +5     
==========================================
+ Hits          637      642       +5     
  Misses         34       34              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielVandH
Copy link
Member Author

This should be good to go as well now @dlfivefifty, assuming the design seems fine to you

@dlfivefifty dlfivefifty merged commit fdab140 into master Nov 9, 2025
11 of 20 checks passed
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.

3 participants