On the VSCode page on sysimages, one can find the following example content of ./.vscode/JuliaSysimage.toml
[sysimage]
exclude=[] # Additional packages to be exlucded in the system image
statements_files=[] # Precompile statements files to be used, relative to the project folder
execution_files=[] # Precompile execution files to be used, relative to the project folder
I am wondering - what is the difference between “Precompile statements files” and “Precompile execution files”?
And just to be sure - relative to the project folder - does that mean relative to the Manifest.toml and Project.toml files of the enviroment?
An example of a precompile statements could look like
precompile(Tuple{typeof(Base.sin), Float64})
which tells the compiler to compile the sin
function when it is applied to one argument of Float64
type.
AFAIU, the VS code “precompile statements file” is a file containing a list of such precompile statements. You can obtain such a file by running julia with the --trace-compile
switch:
shell> julia --trace-compile=/tmp/statements_file.jl
julia> sin(3.0)
0.1411200080598672
julia> exit()
shell> cat /tmp/statements_file.jl
[...]
precompile(Tuple{typeof(Base.sin), Float64})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.TTY}, Base.Multimedia.MIME{Symbol("text/plain")}, Float64})
[...]
Automating this one step further, you can provide a simple julia script (which would contain the call to sin(3)
in my example), so that executing this script would make julia compile everything that you need. IIUC, this is what VS code would call a “precompile execution file”.
Yes, I think so. I’m actually not sure whether “project” here refers to the Pkg
definition, or to what VS code considers a project, but I don’t think it matters in practice because these two typically refer to the same directory on the filesystem. In other words, the .vscode
directory and the Project.toml
& Manifest.toml
files are typically all located under the same “project root directory”:
Foo.jl/
├── Manifest.toml
├── Project.toml
├── src
│ └── Foo.jl
├── test
│ └── runtests.jl
└── .vscode
└── JuliaSysimage.jl
Thanks for your response. That makes sense.
I am facing some issues in generating a sysimage. It seems like no execution file is detected:
with the following code inside /.vscode/JuliaSysimage.toml
[sysimage]
exclude=[] # Additional packages to be exlucded in the system image
statements_files=[] # Precompile statements files to be used, relative to the project folder
execution_files=["C:/Users/my_username/GeekyStuff/Julia/sysimage/stuff_to_precompile.jl", ] # Precompile execution files to be used, relative to the project folder
I have tried removing the brackets around the path above, and I have tried to move the file toC:/Users/my_username/julia/environments/v1.7
and removing everything but the filename, to make it a relative path. In case it is relevant, my_username
contains a space.