Skip to content

Commit

Permalink
add precompilation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
marius311 committed May 11, 2023
1 parent 72a4c94 commit eb372ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ makedocs(
"04_from_python.md",
"05_field_basics.md",
"06_gpu.md",
"precompilation.md",
"api.md"
],
)
Expand Down
25 changes: 25 additions & 0 deletions docs/src/precompilation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Startup

If using Julia 1.9 or above, you can get large speedups (about 10X) in startup time by using the native code caching feature. The idea is that when precompiling CMBLensing, several typically-used functions are run and precompiled, making them much faster to use in subsequent sessions.

Because this can make precompilation of CMBLensing take somewhat longer (a few minutes), its disabled by default. But you can enable it by running,

```julia
julia> using CMBLensing

julia> CMBLensing.set_preferences!(CMBLensing, "precompile" => true)
```

The setting will be stored in a file called `LocalPreferences.toml` in your active environment (which you are free to edit by hand). The next time you start Julia it will precompile CMBLensing (which will now take a few minutes), but after that startup will be much faster. The precompilation calls the following functions:

* `load_sim`
* `logpdf`
* `gradient` of `logpdf`

with `Float32` and `Float64` CPU arrays for a dataset with `pol=:I`, `pol=:P`, and `pol=:IP`. Those funtions and any called by those functions will be _much_ faster on first call after precompilation is enabled. If you don't need all those combinations, its also possible to specify just a subset of them, e.g.:

```julia
julia> CMBLensing.set_preferences!(CMBLensing, "precompile" => "[(:P, Float32, Array))]")
```

For even more speedups and control over what to precompile, you can create a "Startup" package following the instruction here: [PrecompileTools.jl#Startup](https://julialang.github.io/PrecompileTools.jl/stable/#Tutorial:-local-%22Startup%22-packages).

0 comments on commit eb372ae

Please sign in to comment.