Skip to content

Commit

Permalink
precompile __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha committed May 28, 2023
1 parent 93aef78 commit 33b606c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ version = "0.2.2"
[deps]
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"

[compat]
CpuId = "0.3"
IfElse = "0.1"
Static = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8"
PrecompileTools = "1.1"
julia = "1.6"

[extras]
Expand Down
6 changes: 6 additions & 0 deletions src/CPUSummary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function __init__()
@eval sys_threads() = static($syst)
end
_extra_init()
return nothing
end


Expand Down Expand Up @@ -94,4 +95,9 @@ function num_cache_levels()
)
end

# explicit precompilation only on Julia v1.9 and newer
if VERSION >= v"1.9"
include("precompile.jl")
end

end
10 changes: 10 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using PrecompileTools: @compile_workload

@compile_workload begin
__init__()
# `_extra_init()` is called by `__init__()`
# However, it does not seem to be recognized correctly since we can
# further reduce the time of `using CPUSummary` significantly by
# precompiling it here in addition ot `__init__()`.
_extra_init()
end
1 change: 1 addition & 0 deletions src/x86.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function _extra_init()
cs !== PrecompiledCacheSize && _eval_cache_size(cs)
ci = CpuId.cacheinclusive()
ci !== PrecompiledCacheInclusive && _eval_cache_inclusive(ci)
return nothing
end


0 comments on commit 33b606c

Please sign in to comment.