# Adding a sysimage to a julia script - Package Complier

**URL:** <https://discourse.julialang.org/t/adding-a-sysimage-to-a-julia-script-package-complier/74994>\
**Category:** Performance\
**Tags:** package-compiler, sysimage\
**Created:** [January 21, 2022, 4:56pm UTC](https://discourse.julialang.org/t/adding-a-sysimage-to-a-julia-script-package-complier/74994 "2022-01-21T16:56:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maulik.bhatt](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@maulik.bhatt](https://discourse.julialang.org/u/maulik.bhatt)\
**Post date:** [January 21, 2022, 4:56pm UTC](https://discourse.julialang.org/t/adding-a-sysimage-to-a-julia-script-package-complier/74994/1 "2022-01-21T16:56:41Z")

</div>

I have a Julia script which uses several packages and runs several functions from them. This Julia script takes a lot of time every time I run it because every package is precompiled in julia every time I run that script and the time to run the functions is also really high because it runs for the first time every time I call the script. Because of the type of work that I am doing, I necessarily have to run that script from fresh rather then running it in one single session and the time taken in really annoying.

Therefore, I found a nice way to deal with this is creating a sysimage for script which stores everything precompiled to decrease the run time. I followed instructions on [Sysimages · PackageCompiler](https://julialang.github.io/PackageCompiler.jl/stable/sysimages.html) to create a sysimage. But I don’t know how to load that sysimage back into my script. In [Sysimages · PackageCompiler](https://julialang.github.io/PackageCompiler.jl/stable/sysimages.html), it is discussed on how to start julia with a sysimage but I don’t know how to do the same from a script.

I tried doing it by -

```julia
#!/bin/bash
#=
exec julia -J AltroSysimagePrecompile.so --trace-compile=stderr -e 'import Altro' \
    "${BASH_SOURCE[0]}" "$@"
=#

module Julia_Functions

#import Pkg; Pkg.activate(@ __DIR__ ); Pkg.instantiate();
using TrajectoryOptimization
using RobotDynamics
using StaticArrays, LinearAlgebra
using Rotations
#using Altro

```

but it doesn’t seem to work in Linux. Because it still says Altro undefined when I try to call functions from that package. This might be a trivial thing to do but I am new julia and confused on how to go about it. Any help is appreciated.
