Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding Repeated Function Compilation. #1046

Closed
hongyi-zhao opened this issue Apr 18, 2023 · 8 comments
Closed

Avoiding Repeated Function Compilation. #1046

hongyi-zhao opened this issue Apr 18, 2023 · 8 comments

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented Apr 18, 2023

Of course, I know, this is not just a problem related to this package. But I really noticed the following example, which needs so much time each time when I re-start Julia to do the same testing:

werner@X10DAi:~/Downloads/julia-1.9.0-rc2-linux-x86_64/julia-1.9.0-rc2/bin$ ./julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-rc2 (2023-04-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Hecke

Welcome to 

    _    _           _
   | |  | |         | |
   | |__| | ___  ___| | _____
   |  __  |/ _ \/ __| |/ / _ \
   | |  | |  __/ (__|   <  __/
   |_|  |_|\___|\___|_|\_\___|
    
Version 0.18.9 ... 
 ... which comes with absolutely no warranty whatsoever
(c) 2015-2023 by Claus Fieker, Tommy Hofmann and Carlo Sircana


julia> A = [
                  0 1 0 0 0 0 0 0 0 0 0 0 0 0;
                  0 0 1 0 0 0 0 0 0 0 0 0 0 0;
                  0 0 0 1 0 0 0 0 0 0 0 0 0 0;
                  0 0 0 0 1 0 0 0 0 0 0 0 0 0;
                  0 0 0 0 0 1 0 0 0 0 0 0 0 0;
                  0 0 0 0 0 0 1 0 0 0 0 0 0 0;
                  0 0 0 0 0 0 0 1 0 0 0 0 0 0;
                  0 0 0 0 0 0 0 0 1 0 0 0 0 0;
                  0 0 0 0 0 0 0 0 0 1 0 0 0 0;
                  0 0 0 0 0 0 0 0 0 0 1 0 0 0;
                  0 0 0 0 0 0 0 0 0 0 0 1 0 0;
                  0 0 0 0 0 0 0 0 0 0 0 0 1 0;
                  0 0 0 0 0 0 0 0 0 0 0 0 0 1;
                  -2 -2 -2 -2 -1 -1 -1 -1 0 0 -2 0 0 0
              ]
14×14 Matrix{Int64}:
  0   1   0   0   0   0   0   0  0  0   0  0  0  0
  0   0   1   0   0   0   0   0  0  0   0  0  0  0
  0   0   0   1   0   0   0   0  0  0   0  0  0  0
  0   0   0   0   1   0   0   0  0  0   0  0  0  0
  0   0   0   0   0   1   0   0  0  0   0  0  0  0
  0   0   0   0   0   0   1   0  0  0   0  0  0  0
  0   0   0   0   0   0   0   1  0  0   0  0  0  0
  0   0   0   0   0   0   0   0  1  0   0  0  0  0
  0   0   0   0   0   0   0   0  0  1   0  0  0  0
  0   0   0   0   0   0   0   0  0  0   1  0  0  0
  0   0   0   0   0   0   0   0  0  0   0  1  0  0
  0   0   0   0   0   0   0   0  0  0   0  0  1  0
  0   0   0   0   0   0   0   0  0  0   0  0  0  1
 -2  -2  -2  -2  -1  -1  -1  -1  0  0  -2  0  0  0

julia> B = [
                  -21 -11 12 9 15 8 -22 -23 2 6 8 -2 2 -8;
                  32 17 -22 -10 -18 -14 28 35 -5 -6 -13 4 -1 13;
                  1 4 -17 6 11 -12 -6 18 -16 8 -7 7 4 9;
                  21 13 -24 -11 -19 -21 33 48 -15 -4 -15 7 -1 18;
                  14 8 -16 -2 -2 -11 10 23 -9 0 -9 5 0 9;
                  -1 8 -14 -3 13 -9 -2 21 -18 6 -7 8 0 9;
                  29 14 -13 -15 -27 -10 36 31 1 -11 -10 1 -4 10;
                  -26 -8 -8 10 21 -12 -16 14 -25 14 -3 9 5 8;
                  -8 -6 -1 -9 -31 -14 34 31 -8 -7 -4 1 -2 10;
                  -19 -8 11 -15 -39 -8 38 24 -4 -9 2 -2 -3 7;
                  -35 -25 30 3 -11 11 -2 -27 14 -4 14 -9 -2 -13;
                  -19 -21 32 -6 -34 11 21 -21 23 -14 13 -13 -5 -12;
                  10 5 3 11 31 16 -36 -36 11 7 5 -2 3 -12;
                  12 7 -7 -13 -27 -7 30 24 2 -11 -5 -1 -5 6
              ];

julia> is_GLZ_conjugate(matrix(ZZ,A), matrix(ZZ,B))
[...]

So, I wonder whether there is a way to avoid repeated function compilation, especially for those time-consuming ones.

Regards,
Zhao

@fieker
Copy link
Collaborator

fieker commented Apr 19, 2023 via email

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Apr 19, 2023

@fieker Thank you for your tips and it works. But what should I do if I want several or all packages to work in this way?

@fieker
Copy link
Collaborator

fieker commented Apr 19, 2023 via email

@thofma
Copy link
Owner

thofma commented Apr 19, 2023

One could use https://julialang.github.io/PackageCompiler.jl/stable/sysimages.html to do it for as many packages one wants. There is not much we can do on our part.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Apr 20, 2023

@fieker

put it into Hecke/system/precompile.jl

There are currently some code snippets in this file, but they seem to have nothing to do with the issues discussed here. More specifically, the default content in this file seems to be intended for the purpose of completing some tests.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Apr 20, 2023

@thofma

One could use https://julialang.github.io/PackageCompiler.jl/stable/sysimages.html to do it for as many packages one wants. There is not much we can do on our part.

So, the question becomes this:

  1. For several packages, should I compile a separate .so sysimage for each of them, or should I combine them into a huge one?
  2. If I've already compiled some sysimages, then is it possible to combine them into the newly created sysimage without having to compile them from scratch?

@fieker
Copy link
Collaborator

fieker commented Apr 20, 2023

As far as I understand this at this point the answer is: you'll have to produce a single image containing all packages you're interested in. Reason: loading a second package can easily force a change in the bahviour of an older package (think itroducing a special case for a generic function e.g.) thus the sysimage can only be done this way.

Julia is, I think, working on allowing a more incremental approach, but for now, my very limited understanding implies

  • you'll have to do a single image containing all you want
  • do this, mostly from scratch, in one go

@fingolfin
Copy link
Contributor

PackageCompiler.jl should eventually take of this, but it's not yet ready (though it is making steady progress). In the meantime I don't see anything in here we could do much about at this point.

@fieker fieker closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants