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

unexpected allocations / slow execution when using @SVector and rand #1229

Closed
BenediktAuer opened this issue Jan 11, 2024 · 0 comments · Fixed by #1230
Closed

unexpected allocations / slow execution when using @SVector and rand #1229

BenediktAuer opened this issue Jan 11, 2024 · 0 comments · Fixed by #1230

Comments

@BenediktAuer
Copy link

Hello,
on v1.9 I experience some wierd allocations and slow execution when using @SVector and rand with a specific type T:

 @benchmark @SVector rand(Float64,5)
BenchmarkTools.Trial: 10000 samples with 174 evaluations.
 Range (min … max):  606.052 ns …  21.025 μs  ┊ GC (min … max): 0.00% … 96.05%
 Time  (median):     626.333 ns               ┊ GC (median):    0.00%
 Time  (mean ± σ):   702.088 ns ± 752.018 ns  ┊ GC (mean ± σ):  4.21% ±  3.84%

  ▂█▇▄▄▄▃▂▂▁  ▁▁    ▂▂   ▁▁                                     ▁
  █████████████████████▇█████▇▆▇▆▇▇▇▇████▇▇▇██▅▆▄▅▄▅▄▅▄▄▄▄▄▄▅▄▄ █
  606 ns        Histogram: log(frequency) by time       1.16 μs <

 Memory estimate: 496 bytes, allocs estimate: 10.

Without a type specifier I get the expected result:

@benchmark @SVector rand(5)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  5.640 ns … 90.822 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.650 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   6.082 ns ±  1.905 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █             ▃                                            ▁
  █▅▄▃▄▃▄▄▅▃▄▃▃▃█▅▃▄▅▆▅▅▅▃▅▆▆▅▅▅▅▅▅▅▅▅▅▆▆▆▆▆▆▆▆▅▆▆▅▅▆▄▆▆▆▆█▇ █
  5.64 ns      Histogram: log(frequency) by time     11.3 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

Note that on v1.8.2 it gives the expected result:

@benchmark (@SVector rand(Float64,5))
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  5.640 ns … 57.621 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.650 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.992 ns ±  1.498 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █             ▃                                            ▁
  █▃▃▂▄▃▄▃▂▃▃▄▄▄█▃▄▄▄▄▄▅▅▄▅▅▅▅▄▅▅▅▅▄▅▅▆▅▅▅▆▅▆▆▆▆▆▅▅▅▃▄▄▅▅▆▇▆ █
  5.64 ns      Histogram: log(frequency) by time     11.3 ns <

Memory estimate: 0 bytes, allocs estimate: 0.

mateuszbaran added a commit that referenced this issue Jan 12, 2024
* Fix allocations for some cases of rand (#1229)

* add test

* this one won't have to be compiled

* version?

* the test doesn't work
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 a pull request may close this issue.

1 participant