How to programmatically update my PackageCompiler's sysimage, using a precompile_execution_file?

bertulli
Wed, 30 Nov 2022 13:24:30 +0000
General Usage

Hi all!

I am using PackageCompiler to speed up Julia usage. It works enthusiastically well, and it saves me some time, but I also want to keep the sysimage updated. Specifically, I want to update it (even manually) once in a while, when:

a package gets updated

I use a new function in my scripts

First and main question (to avoid the XY problem): how can I do that?

I’ve thought I could embed the package compilation in a script to invoke periodically:

## update_sysimage.jl

using PackageCompiler;

PackageCompiler.create_sysimage(["Package1", "Package2"];
                                sysimage_path="/path/to/sysimage.so",
                                precompile_execution_file="???.jl")

Since I run multiple scripts in a specific directory, and since you have to use the precompile_execution_file to instruct Julia to detect and compile the functions you use, what should I put in there, to make it aware of new functions? I thought I can simply get the list of the scripts I wrote, and include them all:

# precompile_execution_file.jl
script_files = readdir(abspath(scripts_source_dir), join=true);

include.(script_files);

Now, I think this should work (I’m not sure), BUT:

1. Do I do unnecessary computation? Is there a more efficient/idiomatic way?

2. When using PackageCompiler.create_sysimage, does the precompile_execution_file effectively get run? IOW, will it be run, and modify my data with side-effects, or PackageCompiler simply reads it to extract the signatures of the functions to compile?

3. do you know any method to automatically detect also the list of packages to pass in the first argument array?

Thanks!

2 posts - 2 participants