Open aaowens opened 6 years ago
Also this only started when I added some additional fields to StaticOptimizationResults
In 1.0.1 it now allocates all the time. It's also faster than it was last I tried this.
Is there some limit to the amount of data you can put in a struct before it starts to allocate?
julia> @btime soptimize(rosenbrock, $sx)
2.015 μs (2 allocations: 160 bytes)
Results of Static Optimization Algorithm
* Initial guess: [3.2,3.2]
* Minimizer: [0.9999999999990606,0.9999999999980389]
* Minimum: [1.5610191722141176e-24]
* Hf(x): [801.6874976886638,-399.8345645795701,-399.83456457957504,199.9124176978296]
* Number of iterations: [31]
* Number of function calls: [69]
* Number of gradient calls: [31]
* Converged: [true]
It does seem to be a real allocation
julia> function test(sx)
for i = 1:10000
soptimize(rosenbrock, sx)
end
end
test (generic function with 1 method)
julia> @btime test($sx)
20.124 ms (20000 allocations: 1.53 MiB)
I'm seing similar things with static arrays, but it's super erratic. Say, I can remove a branch that just prints a string, and then the allocations go away... I'm stumped tbh
Are you interpolating the string? Reminds me of this comment: https://discourse.julialang.org/t/understanding-performance-using-btime-and-code-warntype-code-llvm-etc/16293/2?u=aaowens
Why does it allocate the first time?
@btime
is not supposed to need a warm up.