JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.41k stars 189 forks source link

julia 1.9.0 sysimage using Pycall cause the function to be recompiled #818

Open 13299118606 opened 1 year ago

13299118606 commented 1 year ago
versioninfo()
Julia Version 1.9.0
Commit 8e63055292 (2023-05-07 11:25 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 20 × 12th Gen Intel(R) Core(TM) i7-12700
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, alderlake)
  Threads: 1 on 20 virtual cores

julia1.9.0 system image using Pycall will cause recompilation: I set up precompiled execution code

glmakie_precompile.jl

@time using GLMakie
@time lines(0:1:10, rand(11))
@time heatmap(rand(10,10))
@time volume(rand(50,100,150))

Create a system image create_sysimage(:GLMakie, sysimage_path="MyJuliaSysimage.dll", precompile_execution_file="glmakie_precompile.jl" ) Then start the image: julia -J MyJuliaSysimage.dll --startup-file=no

use

include("glmakie_precompile.jl")
   0.000642 seconds (309 allocations: 22.336 KiB)
   0.031060 seconds (40.43 k allocations: 2.472 MiB, 65.64% compilation time)
   0.007224 seconds (40.18 k allocations: 2.476 MiB)
   0.021566 seconds (38.96 k allocations: 13.825 MiB, 61.79% gc time)

It can be seen that it is activated, but Onceusing PyCall, it will cause the function to be recompiled:

include("glmakie_precompile.jl")
   0.990671 seconds (1.11 M allocations: 77.773 MiB, 2.09% gc time, 99.92% compilation time: 100% of which was recompilation)
   1.924587 seconds (4.41 M allocations: 294.875 MiB, 4.77% gc time, 99.44% compilation time: 89% of which was recompilation)
   0.137899 seconds (218.10 k allocations: 14.614 MiB, 8.12% gc time, 95.18% compilation time: 86% of which was recompilation)
   0.948697 seconds (2.18 M allocations: 150.802 MiB, 4.64% gc time, 97.70% compilation time: 97% of which was recompilation)