Skip to content

Conversation

@devmotion
Copy link
Member

There are a lot of avoidable allocations currently when generating Sobol samples (BTW a bit related: JuliaMath/Sobol.jl#35 - after this change probably the use of skip!/skip should be removed from QuasiMonteCarlo).

On the master branch

julia> using QuasiMonteCarlo, BenchmarkTools

julia> @benchmark QuasiMonteCarlo.sample(100, 10, SobolSample())
BenchmarkTools.Trial: 10000 samples with 3 evaluations.
 Range (min  max):  8.014 μs  227.764 μs  ┊ GC (min  max): 0.00%  93.73%
 Time  (median):     8.722 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   9.241 μs ±   6.835 μs  ┊ GC (mean ± σ):  2.77% ±  3.59%

   ▂▄▅▅▅▆▇█▇▇▇▆▄▃▂▂▁▁▁▁▂▂▂▃▃▃▂▁▂▁▁▁▁                          ▃
  ▆██████████████████████████████████████▇▇▇▇▇▇▇███▇██▇▇▇▆▆▆▅ █
  8.01 μs      Histogram: log(frequency) by time      12.3 μs <

 Memory estimate: 26.02 KiB, allocs estimate: 124.

This PR

julia> using QuasiMonteCarlo, BenchmarkTools

julia> @benchmark QuasiMonteCarlo.sample(100, 10, SobolSample())
BenchmarkTools.Trial: 10000 samples with 7 evaluations.
 Range (min  max):  4.542 μs  313.673 μs  ┊ GC (min  max): 0.00%  97.50%
 Time  (median):     4.935 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.396 μs ±   9.654 μs  ┊ GC (mean ± σ):  6.38% ±  3.51%

           ▁█▅▇                                                
  ▂▄▆▄▃▂▂▂▆█████▆▄▄▃▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  4.54 μs         Histogram: frequency by time        6.47 μs <

 Memory estimate: 10.23 KiB, allocs estimate: 14.

@ChrisRackauckas ChrisRackauckas merged commit 2574bb9 into master Jun 12, 2024
@devmotion devmotion deleted the dw/sobol_allocations branch June 12, 2024 10:44
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