First install Fezzik, this has been around since 2019 and actively maintained, but it's only available from source:
using Pkg
pkg"add https://github.com/TsurHerman/Fezzik"
Now create a script with some code in it that typically takes a while to run, e.g.:
cd `mktemp -d`
nvim file.jl
using Random
using Plots
using FFTW
N = 99
x = rand(Float32, N)
X = fft(x)
plot(abs.(X))
sleep(0.5)
Open a Julia REPL, and run the following code:
using Fezzik
Fezzik.auto_trace()
This inserts Fezzik into Julia's startup so it can trace what runs.
Close the REPL and source that file:
julia < ./file.jl
________________________________________________________
Executed in 9.11 secs fish external
usr time 8.47 secs 226.00 micros 8.47 secs
sys time 0.84 secs 147.00 micros 0.84 secs
Open Julia and save the sys image that was traced by running the following (approx 5 min):
julia --threads=auto
import Fezzik
Fezzik.brute_build_local()
# Optionally stop it from tracing
# It may be desirable to keep building up used packages though.
Fezzik.auto_trace(false)
Close Julia and note the presence of the .so
file in the directory:
ls *.so
JuliaSysimage.so*
This can be loaded as an image to save Julia from recompiling:
julia -J JuliaSysimage.so < ./file.jl
________________________________________________________
Executed in 2.07 secs fish external
usr time 1.53 secs 251.00 micros 1.53 secs
sys time 0.75 secs 166.00 micros 0.75 secs
This SysImage will need to be regenerated between updates, so disable
auto_trace
before an update and re-enable thereafter.
A similar thing can be implemented for the LSP with this Makefile and this config.