Closed Lightup1 closed 2 years ago
When it comes to my model, the GC time is around 10%.
After specify saveat=[]
, save_on=false
start to work.
But alloc is still high.
This is not a bug. We already set save_everystep = false
, save_start = false
, and save_end = false
. Setting save_on = false
will probably not have any effect.
For saving we use a SavingCallback
with timepoints specified by the list of times you pass in. If you want to reduce that, just pass in less timepoints, e.g. T = [0.0, pi]
will only store two points.
Also, make sure to interpolate global variables when benchmarking to avoid measuring false allocations, e.g. @benchmark timeevolution.schroedinger($T, $Ψ0, $H)
Dear @david-pl , thanks for your helpful reply, I tried to benchmark again with your tip.
T = [0,0.5pi]
@benchmark tout, Ψt = timeevolution.schroedinger($T, $Ψ0, $H)
BenchmarkTools.Trial: 418 samples with 1 evaluation.
Range (min … max): 9.050 ms … 18.892 ms ┊ GC (min … max): 0.00% … 26.99%
Time (median): 11.346 ms ┊ GC (median): 0.00%
Time (mean ± σ): 11.963 ms ± 2.400 ms ┊ GC (mean ± σ): 5.06% ± 9.29%
▅ ▁█▁
▆██████▆▆▄▇▄▄▅▆▄▄▃▂▆▆▆▅▅▄▆▆▄▄▅▃▅▄▄▆▄▃▆▄▅▆▂▃▂▂▃▂▃▄▁▄▁▃▁▃▃▃▁▃ ▄
9.05 ms Histogram: frequency by time 17.8 ms <
Memory estimate: 10.43 MiB, allocs estimate: 11818.
Alloc is still high. Notice that I run it on another machine. Should we reopen the issue?
Checked the mul!()
of LazyProduct
The high alloc is resulted from tmp1
and tmp2
.
function mul!(result::Ket{B1},a::LazyProduct{B1,B2},b::Ket{B2},alpha,beta) where {B1,B2}
tmp1 = Ket(a.operators[end].basis_l)
mul!(tmp1,a.operators[end],b,a.factor,0)
for i=length(a.operators)-1:-1:2
tmp2 = Ket(a.operators[i].basis_l)
mul!(tmp2,a.operators[i],tmp1)
tmp1 = tmp2
end
mul!(result,a.operators[1],tmp1,alpha,beta)
return result
end
Version info
Benchmark of this example:https://docs.qojulia.org/examples/particle-in-harmonic-trap/#Particle-in-harmonic-trap-potential
Result
[0:0.1:pi;]
[0:0.05:0.5pi;]
tout, Ψt = timeevolution.schroedinger(T, Ψ0, H,save_on=false)
After specify
save_on=false
Still save all resultsReduce save points:
Alloc is still high