johnmyleswhite / Benchmarks.jl

A new benchmarking library for Julia
Other
45 stars 15 forks source link

Use gensymed const bindings #24

Closed mbauman closed 9 years ago

mbauman commented 9 years ago

This seems to be a much more sane way to do things here. As far as I can tell, @benchmark from the global scope is working exactly as it was before.

However, there are still some strange effects in local scopes. I believe we're hitting a known Julia performance issue with functions inside let scopes, but I can't find a reference to it now.

julia> x = 10
10

julia> @benchmark x*x
================ Benchmark Results ========================
     Time per evaluation: 3.04 ns [3.03 ns, 3.06 ns]
Proportion of time in GC: 0.00% [0.00%, 0.00%]
        Memory allocated: 0.00 bytes
   Number of allocations: 0 allocations
       Number of samples: 11801
   Number of evaluations: 153241801
         R² of OLS model: 0.991
 Time spent benchmarking: 0.54 s

julia> let
       x = 10
       @benchmark x*x
       end
================ Benchmark Results ========================
     Time per evaluation: 30.96 ns [30.54 ns, 31.39 ns]
Proportion of time in GC: 0.00% [0.00%, 0.00%]
        Memory allocated: 0.00 bytes
   Number of allocations: 0 allocations
       Number of samples: 9401
   Number of evaluations: 15560101
         R² of OLS model: 0.953
 Time spent benchmarking: 0.55 s
mbauman commented 9 years ago

It looks like Julia's not applying the normal optimizations for const bindings in local scope: https://github.com/JuliaLang/julia/issues/13395