AFAIU Julia supports an intermediate technique between the two you mention: it can bake into one sysimage several versions of the same code, compiled and optimized for different micro architectures. So that it achieves the best of both worlds: (almost-)fully optimized code and no run-time latency (for what gets baked into the system image).
As explained in the devdocs, this is what’s used for the default sysimage that is shipped with official pre-built julia releases is compiled.
If you want to use PackageCompiler
to produce custom system images for your own packages, you can achieve the same effect (i.e. produce sysimages that are both portable and optimized) using the cpu_target
keyword argument to create_sysimage
. For example for x86_64
architectures:
create_sysimage(
packages,
sysimage_path = "my_sysimage.so",
# [other kw args]
cpu_target = "generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"
)