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

compile times degraded on using Hecke #111

Closed
martinra opened this issue Dec 7, 2020 · 4 comments
Closed

compile times degraded on using Hecke #111

martinra opened this issue Dec 7, 2020 · 4 comments

Comments

@martinra
Copy link
Contributor

martinra commented Dec 7, 2020

I started to investigate some of my compile times, and tracked down the following issue to Hecke.

Not using Hecke

using Nemo
fm = FreeModule(QQ, 5);
vs = Vector{fmpq}[];
@time sub(fm, map(fm,vs));
0.410914 seconds (1.64 M allocations: 84.424 MiB, 5.92% gc time)

Using Hecke

using Nemo, Hecke
fm = FreeModule(QQ, 5);
vs = Vector{fmpq}[];
julia> @time sub(fm, map(fm,vs));
178.114302 seconds (488.43 M allocations: 23.518 GiB, 3.03% gc time)

I'm not sufficiently deep into the code base to find the source, but I can provide some experience from a similar phenomenon that I discovered in my own code. The compile time exploded in the same way. I had a function of the shape

function fct(m::MatElem{R}) where R
  rref!(m)
end

which caused Julia type interference to almost break down. My fix was

function fct(m::MatElem{R}) where R
  if R == fmpq
    rref!(m::fmpq_mat)
  else
    rref!(m)
  end
end

I believe I didn't have these problems in Julia 1.4, but I haven't double checked this. In any case, the work around is not great, but 180s is neither.

@thofma
Copy link
Owner

thofma commented Dec 7, 2020

Thanks for the report. Which julia version is this?

P.S.: The FreeModules provided by AbstractAlgebra are inherently type unstable and prone to problems with inference/compilation (try having a look at @code_warntype). But this increase in the compile time should not happen.

@martinra
Copy link
Contributor Author

martinra commented Dec 7, 2020

This is Julia 1.5.3 on Fedora. But I don't think they modify upstream.

I didn't know about @code_warntype. This seems very use. Thank you!

@thofma
Copy link
Owner

thofma commented Dec 7, 2020

Thanks for the version.

Be careful, @code_warntype is very addictive. In a similar vein, you might find https://github.com/JuliaDebug/Cthulhu.jl useful. We use it all the time to track down type problems.

@thofma
Copy link
Owner

thofma commented Dec 16, 2020

The inference fix has been merged in AA. I will close this for now @martinra. Feel free to open another issue if you encounter this again. These slowdowns hint at some non-optimal code on our side.

@thofma thofma closed this as completed Dec 16, 2020
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

No branches or pull requests

2 participants