Installation and usage
You can easily install the package using the standard packaging system:
] add AutoSysimagesThen, the install() function inserts a small script somewhere into your path depending on your operation system.
using AutoSysimages
install()On Linux and MacOS, it copies scripts/unix/asysimg script into ~/.local/bin or ~/bin, respectively. These directories should be in your PATH. If the bin directory didn't previously exist, it is necessary to re-load the terminal to set PATH correctly.
On Windows, it copies scripts/windows/asysimg.bat script into Sys.BINDIR. It's necessary to have this directory in PATH, as recommended in https://julialang.org/downloads/platform/.
Basic usage
Once you install the package and save the script, you can easily run Julia from terminal, using one of the following options with any additional arguments, as normal. It automatically loads the latest system image for your project and start snooping for new precompile statements.
asysimgasysimg --projectasysimg --project=examples/ExampleWithPlotsHow it works?
In the first step, asysimg script detect if there exists a system image for the current project by calling julia_args() and print argument for Julia to load such image. Example of the produced arguments.
The first argument (-J) loads the latest system image and is present only if such an image is found.
-J /home/user/.julia/asysimg/1.X.X/4KnVCS/asysimg-2022-09-01T14:54:50.395.sowhere 4KnVCS is a hash of the project path.
The second arguments (-L []/src/start.jl) initializes this package and start snooping for new precompiles statements.
-L [AutoSysimages-DIR]/src/start.jlOnce the snooping is started it records precompile statements into a temporary files. When the Julia session is terminate, these statements are copied to project-specific file, like
/home/user/.julia/asysimg/1.X.X/4KnVCS/snoop-file.jlSelect packages
You can select packages to be included into the project-specific system images. There is an interactive selection process that can be triggered by calling
using AutoSysimages
select_packages()That shows the manual selection (asysimg --project=examples/ExampleWithPlots/)
asysimg> select_packages()
[ Info: Please select packages to be included into sysimage:
[press: Enter=toggle, a=all, n=none, d=done, q=abort]
> [ ] LinearAlgebra
[ ] OhMyREPL
[X] Plots
[ ] PrintfThe settings are stored in SysimagePreferences.tomlfile just next to the current Project.toml file. You can modify the settings manually in the file.
[AutoSysimages]
include = ["Plots"]
exclude = []To check which versions of the packages will be included, you can run
asysimg> status()
Project `/home/petr/repos/AutoSysimages/examples/ExampleWithPlots/Project.toml`
Settings `/home/petr/repos/AutoSysimages/examples/ExampleWithPlots/SysimagePreferences.toml`
Packages to be included into sysimage:
[91a5bcdd] Plots v1.31.7(Re)build sysimage
You can rebuild your system image at any time, but the changes will be reflected only after you restart Julia (using asysimg). It automatically includes all the selected packages and recorded precompile statements.
using AutoSysimages
build_sysimage()The sysimage will be generated by PackageCompiler, or by very experimental chained builds.