Skip to content

Commit

Permalink
Merge pull request #21 from ranocha/hr/precompile
Browse files Browse the repository at this point in the history
precompile `__init__`
  • Loading branch information
chriselrod authored May 28, 2023
2 parents 93aef78 + d765c12 commit 7bf2d64
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name = "CPUSummary"
uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
authors = ["chriselrod <[email protected]> and contributors"]
version = "0.2.2"
version = "0.2.3"

[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


2 comments on commit 7bf2d64

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/84417

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" 7bf2d6418655e8f0073f0170771aafb8c0acc596
git push origin v0.2.3

Please sign in to comment.