Skip to content

Commit 19bcb64

Browse files
authored
precompile package callback (#341)
With this PR: ``` (ChainRulesCore) pkg> precompile Precompiling project... 1 dependency successfully precompiled in 2 seconds (1 already precompiled) julia> @time using ChainRulesCore 0.082255 seconds (157.13 k allocations: 9.737 MiB, 5.59% compilation time) ``` Before: ``` julia> @time using ChainRulesCore 0.111551 seconds (443.47 k allocations: 25.618 MiB, 3.87% compilation time) ``` Removing the hook alltogether: ``` julia> @time using ChainRulesCore 0.033357 seconds (36.37 k allocations: 2.399 MiB, 17.75% compilation time) ``` That's still more overhead than I'd like, so we should still discuss whether we could avoid these hooks, but it does at least improve the current situation somewhat. Ref #340
1 parent c6402ae commit 19bcb64

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/precompile.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
precompile(_package_hook, (Base.PkgId,))

src/ruleset_loading.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Infastructure to support generating overloads from rules.
2+
_package_hook(::Base.PkgId) = refresh_rules()
23
function __init__()
34
# Need to refresh rules when a package is loaded
4-
push!(Base.package_callbacks, pkgid -> refresh_rules())
5+
push!(Base.package_callbacks, _package_hook)
56
end
67

78
# Holds all the hook functions that are invokes when a new rule is defined

0 commit comments

Comments
 (0)