@@ -28,23 +28,24 @@ code generation performs optimizations and ultimately generates the assembly
28
28
language (native code) used on CPUs.
29
29
Some aspects of this process are documented [ here] ( https://docs.julialang.org/en/v1/devdocs/eval/ ) .
30
30
31
- Every time you load a package in a fresh Julia session, the methods you use
32
- need to be JIT-compiled, and this contributes to the latency of using the package.
33
- In some circumstances, you can partially cache the results of compilation to a file
34
- (the ` *.ji ` files that live in your ` ~/.julia/compiled ` directory) to reduce the burden
35
- when your package is used.
36
- This is called * precompilation* .
37
- Unfortunately, precompilation is not as comprehensive as one might hope.
38
- Currently, Julia is only able to save inference results (not native code) in the
39
- ` *.ji ` files, and thus precompilation only eliminates the time needed for type inference.
40
- Moreover, there are some significant constraints that sometimes prevent Julia from
41
- saving even the inference results--for example, currently you cannot cache inference results
42
- for "top level" calls to methods defined in Julia or other packages, even if you are calling them
43
- with types defined in your package.
44
- Finally, what does get saved can sometimes be invalidated by loading other packages.
45
-
46
- Despite these limitations, there are many cases where precompilation can substantially reduce
47
- latency.
31
+ Every time you load a package in a fresh Julia session, the methods you use need
32
+ to be JIT-compiled, and this contributes to the latency of using the package.
33
+ In some circumstances, you can cache the results of compilation to files to
34
+ reduce the latency when your package is used. These files are the the ` *.ji ` and
35
+ ` *.so ` files that live in the ` compiled ` directory of the Julia depot, usually
36
+ located at ` ~/.julia/compiled ` . However, if these files become large, loading
37
+ them can be another source for latency. Julia needs time both to load and
38
+ validate the cached compiled code. Minimizing the latency of using a package
39
+ involves focusing on caching the compilation of code that is both commonly used
40
+ and takes time to compile.
41
+
42
+ This is called * precompilation* . Julia is able to save inference results in the
43
+ ` *.ji ` files and ([ since Julia
44
+ 1.9] ( https://julialang.org/blog/2023/04/julia-1.9-highlights/#caching_of_native_code ) )
45
+ native code in the ` *.so ` files, and thus precompilation can eliminate the time
46
+ needed for type inference and native code compilation (though what does get
47
+ saved can sometimes be invalidated by loading other packages).
48
+
48
49
SnoopCompile is designed to try to allow you to analyze the costs of JIT-compilation, identify
49
50
key bottlenecks that contribute to latency, and set up ` precompile ` directives to see whether
50
51
it produces measurable benefits.
0 commit comments