You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the last step, you add `Precompiler` and all the package you'll need for your work on `Project1`
119
+
In the last step, you add `PrecompileTools` and all the package you'll need for your work on `Project1`
120
120
as dependencies of `Startup`.
121
121
Then edit the `Startup/src/Startup.jl` file to look similar to the tutorial previous section, e.g.,
122
122
123
123
```julia
124
124
module Startup
125
125
126
126
using LotsOfPackages...
127
-
usingPrecompiler
127
+
usingPrecompileTools
128
128
129
-
Precompiler.@cachebegin
129
+
@compile_workloadbegin
130
130
# inside here, put a "toy example" of everything you want to be fast
131
131
end
132
132
@@ -143,59 +143,59 @@ All the packages will be loaded, together with their precompiled code.
143
143
144
144
There are cases where you might want to precompile code but cannot safely *execute* that code: for example, you may need to connect to a database, or perhaps this is a plotting package but you may be currently on a headless server lacking a display, etc.
145
145
In that case, your best option is to fall back on Julia's own `precompile` function.
146
-
However, as explained in [How Precompiler works](@ref), there are some differences between `precompile` and `Precompiler.@cache`;
146
+
However, as explained in [How PrecompileTools works](@ref), there are some differences between `precompile` and `@compile_workload`;
147
147
most likely, you may need multiple `precompile` directives.
148
148
Analysis with [SnoopCompile](https://github.com/timholy/SnoopCompile.jl) may be required to obtain the results you want.
149
149
150
150
## Package developers: reducing the cost of precompilation during development
151
151
152
152
If you're frequently modifying one or more packages, you may not want to spend the extra time precompiling the full set of workloads that you've chosen to make fast for your "shipped" releases.
153
-
One can *locally* reduce the cost of precompilation for selected packages using the `Preferences.jl`-based mechanism and the `skip_precompile` key: from within your development environment, use
153
+
One can *locally* reduce the cost of precompilation for selected packages using the `Preferences.jl`-based mechanism and the `"precompile_workload"` key: from within your development environment, use
Julia itself has a function `precompile`, to which you can pass specific signatures to force precompilation.
189
189
For example, `precompile(foo, (ArgType1, ArgType2))` will precompile `foo(::ArgType1, ::ArgType2)`*and all of its inferrable callees*.
190
190
Alternatively, you can just execute some code at "top level" within the module, and during precompilation any method or signature "owned" by your package will also be precompiled.
191
191
Thus, base Julia itself has substantial facilities for precompiling code.
192
192
193
-
`Precompiler.@cache` adds one key feature: the *non-inferrable callees* (i.e., those called via runtime dispatch) that get
194
-
made inside the `@cache` block will also be cached, *regardless of module ownership*. In essence, it's like you're adding
195
-
an explicit `precompile(noninferrable_callee, (OtherArgType1, ...))` for every runtime-dispatched call made inside `Precompiler.@cache`.
193
+
`@compile_workload` adds one key feature: the *non-inferrable callees* (i.e., those called via runtime dispatch) that get
194
+
made inside the `@compile_workload` block will also be cached, *regardless of module ownership*. In essence, it's like you're adding
195
+
an explicit `precompile(noninferrable_callee, (OtherArgType1, ...))` for every runtime-dispatched call made inside `@compile_workload`.
196
196
197
-
`Precompiler` adds other features as well:
197
+
`PrecompileTools` adds other features as well:
198
198
199
-
- Statements that occur inside a `Precompiler.@cache` block are executed only if the package is being actively precompiled; it does not run when the package is loaded, nor if you're running Julia with `--compiled-modules=no`.
200
-
- Compared to just running some workload at top-level, `Precompiler.@cache` ensures that your code will be compiled (it disables the interpreter inside the block)
201
-
-Precompiler also defines `Precompiler.@setup`, which you can use to create data for use inside a `Precompiler.@cache` block. Like `Precompiler.@cache`, this code only runs when you are precompiling the package, but it does not necessarily result in the "setup" code being stored in the package precompile file.
199
+
- Statements that occur inside a `@compile_workload` block are executed only if the package is being actively precompiled; it does not run when the package is loaded, nor if you're running Julia with `--compiled-modules=no`.
200
+
- Compared to just running some workload at top-level, `@compile_workload` ensures that your code will be compiled (it disables the interpreter inside the block)
201
+
-PrecompileTools also defines `@setup_workload`, which you can use to create data for use inside a `@compile_workload` block. Like `@compile_workload`, this code only runs when you are precompiling the package, but it does not necessarily result in the `@setup_workload` code being stored in the package precompile file.
0 commit comments