# PackageCompiler - Understand how compilation works

**URL:** <https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142>\
**Category:** General Usage\
**Created:** [June 10, 2023, 4:14pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142 "2023-06-10T16:14:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Post date:** [June 10, 2023, 4:14pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142/1 "2023-06-10T16:14:48Z")

</div>

I’m creating an app using PackageCompiler.jl as described [here](https://julialang.github.io/PackageCompiler.jl/dev/apps.html#Creating-an-app)

I’m trying to create an executable of a simple backend application. PackageCompiler works fine since I am able to generate a binary to run my application.

What I didn’t expect is that the first time something is begin executed seems to be slower as if no compilation is made by PackageCompiler. The second time the call is fast as I expected form a normal execution by JIT.

So I’m not understading what kind of compilation is made during the process of create\_app by PackageCompiler and how JIT works during execution time of the binary generated.

Thanks.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 10, 2023, 4:20pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142/2 "2023-06-10T16:20:50Z")

</div>

Well, only the parts of the code that are executed in the precompile\_execution\_file are fully compiled… Make sure your main usecase is covered here…

---

<div class="post-metadata">

**Author:** ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Post date:** [June 10, 2023, 4:51pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142/3 "2023-06-10T16:51:31Z")

</div>

So even bundled binaries are compiled on the first execution, is that correct? Thanks.

---

<div class="post-metadata">

**Author:** ![smldis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/smldis/32/1735_2.png) [@smldis](https://discourse.julialang.org/u/smldis)\
**Post date:** [June 10, 2023, 6:01pm UTC](https://discourse.julialang.org/t/packagecompiler-understand-how-compilation-works/100142/4 "2023-06-10T18:01:54Z")

</div>

PackageCompiler will not bundle binaries for any possible function you might call (this is impractical). With PackageCompiler you need to explicitly declare what you want to precompile and it will build the sysimage with the actual native code inside. The simple way to do this is described in the docs [Sysimages · PackageCompiler](https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html#tracing)
