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

ChainRulesCore dependency causes 4x load time regression #310

Closed
KristofferC opened this issue May 2, 2021 · 4 comments · Fixed by #319
Closed

ChainRulesCore dependency causes 4x load time regression #310

KristofferC opened this issue May 2, 2021 · 4 comments · Fixed by #319

Comments

@KristofferC
Copy link
Member

KristofferC commented May 2, 2021

The quite recent addition of ChainRulesCore (#238) causes a 4x load time regression for this package. This is quite unfortunate since this package is a very common dependency. This has the effect that e.g. complaints are made upstream of slow loading packages (for example JuliaDiff/ForwardDiff.jl#518).

Current master:

julia> @time using SpecialFunctions
  0.256169 seconds (627.68 k allocations: 37.144 MiB, 4.97% gc time, 2.64% compilation time)

Without ChainRulesCore:

julia> @time using SpecialFunctions
  0.053946 seconds (51.40 k allocations: 4.460 MiB, 7.50% compilation time)

There is a bit of irony here in that ForwardDiff (or rather DiffRules) already has derivatives defined for SpecialFunctions (and its tests pass perfectly fine without the ChainRulesCore definitions). Is there any way you could make the people that don't need the (big) ChainRulesCore overhead able to avoid it?

In addition, ChainRulesCore does a bunch of quite exotic stuff (https://github.com/JuliaDiff/ChainRulesCore.jl/blob/63de708a85611f4a65604bec582c71b53d6d5d43/src/ruleset_loading.jl#L84-L126), for example adding hooks that run at every package load (which call into reflection of all things) and it seems unwanted to have such things in such a core dependency as SpecialFunctions.jl is.

@KristofferC KristofferC changed the title ChainRulesCore dependency causes 5x load time regression ChainRulesCore dependency causes 4x load time regression May 2, 2021
@stevengj
Copy link
Member

stevengj commented May 2, 2021

@ChrisRackauckas, this is a bit unfortunate. Why can't ChainRulesCore be a more lightweight dependency? Don't we just need a package defining a few functions that we can overload?

@ChrisRackauckas
Copy link
Member

@oxinabox

@oxinabox
Copy link
Contributor

oxinabox commented May 2, 2021

We are working on it.
Will be fixed in v0.8, might be fixed before then.

See JuliaDiff/ChainRulesCore.jl#340

@oschulz
Copy link

oschulz commented May 3, 2021

This has the effect that e.g. complaints are made upstream of slow loading packages (for example JuliaDiff/ForwardDiff.jl#518).

It wasn't a complaint, really, I was just wondering if ForwardDiff might not profit from a lightweight abstract interface. :-) But I had indeed not realized that the load time of ForwardDiff had regressed recently.

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

Successfully merging a pull request may close this issue.

5 participants