# Precompile statements files vs Precompile excecution files

**URL:** <https://discourse.julialang.org/t/precompile-statements-files-vs-precompile-excecution-files/77741>\
**Category:** General Usage\
**Tags:** sysimage\
**Created:** [March 11, 2022, 9:23am UTC](https://discourse.julialang.org/t/precompile-statements-files-vs-precompile-excecution-files/77741 "2022-03-11T09:23:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [March 11, 2022, 9:23am UTC](https://discourse.julialang.org/t/precompile-statements-files-vs-precompile-excecution-files/77741/1 "2022-03-11T09:23:20Z")

</div>

On the [VSCode page on sysimages](https://www.julia-vscode.org/docs/dev/userguide/compilesysimage/), one can find the following example content of `./.vscode/JuliaSysimage.toml`

```julia
[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?

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [March 11, 2022, 5:51pm UTC](https://discourse.julialang.org/t/precompile-statements-files-vs-precompile-excecution-files/77741/2 "2022-03-11T17:51:43Z")

</div>

> [@TheLateKronos](#):
>
> I am wondering - what is the difference between “Precompile statements files” and “Precompile execution files”?

An example of a precompile statements could look like

```julia
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:

```julia
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”.

> [@TheLateKronos](#):
>
> 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?

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”:

```julia
Foo.jl/
├── Manifest.toml
├── Project.toml
├── src
│ └── Foo.jl
├── test
│ └── runtests.jl
└── .vscode
    └── JuliaSysimage.jl

```

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [August 2, 2022, 4:57pm UTC](https://discourse.julialang.org/t/precompile-statements-files-vs-precompile-excecution-files/77741/3 "2022-08-02T16:57:35Z")

</div>

Thanks for your response. That makes sense.

I am facing some issues in generating a sysimage. It seems like no execution file is detected:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/7/679bf69b4ab2937750baf49ceddb4b69954d3ce6.png)

with the following code inside `/.vscode/JuliaSysimage.toml`

```julia
[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 to`C:/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.
