I am having trouble precompiling a function I am writing. It is pretty important that I precompile this function as the current compile time is ~700 seconds, and I would like to only pay this the first time I call it with using, even compiling every run of the code is painful.
The function is currently inside its own module, but even though Julia precompiles the module (or at least says that it does), the first function call is still extremely long.
Here is the relevant beginning and end snippet of the file
module Mnlitest2
using OffsetArrays
using TwoFAST # https://github.com/hsgg/TwoFAST.jl
function ξ(Pk,ℓ,n; q=:auto)
N = 1024
kmin = exp(-25)
kmax = exp(25)
r0 = 1/kmax
if q == :auto
q = max(.5, 1+n)
end
r, xi = xicalc(Pk, ℓ, -n, N=N, kmin=kmino, kmax=kmaxo, r0=r0o; q=q)
return r, xi .* (r .^ (-n))
end
export generateMnli
function generateMnli(Pk::Function; BiasDict22::Dict{String,Int64}, f::Float64)
M = OffsetArray{Array{Float64}}(undef, 0:4, 0:8, 0:8)
b1 = BiasDict22["b1"]
bη = BiasDict22["bη"]
b2 = BiasDict22["b2"]
bK² = BiasDict22["bK2"]
bδη = BiasDict22["bδη"]
bη² = BiasDict22["bη2"]
bKKpara = BiasDict22["bKK∥"]
bΠ2para = BiasDict22["bΠ2∥"]
r, xi20 = ξ(Pk,2,0)
_, xi00 = ξ(Pk,0,0)
# There are more xi terms but no need to have them all here
# Below is just one of the terms, many are much longer
M[4,0,0] = @. ((45*b1^2 - 10*b1*f^2 + 3*f^4)/540. - (f*(5*b1 - f^2)*bη)/90. + (f^2*bη^2)/60.)*xi0m2^2 +
((225*b1^2 - 50*b1*f^2 + 6*f^4)/1350. - (f*(5*b1 - f^2)*bη)/45. + (f^2*bη^2)/30.)*xi2m2^2
return r, M
end
end
I think the above is a pretty accurate representation of my function. Of course I can provide the entire file, but felt the ~500 lines of code was too much.
I would really appreciate if anyone could help me find what I need to do to get this function precompiled.