Help fixing a huge amount of rerecompilation time when using ODBC.jl

Hi!

We use everyday the ODBC.jl package to fetch satellite telemetries from our database and perform some automatic analysis. However, since Julia v1.9, we are experiencing a huge precompilation time. The first SQL execution takes roughly 50s.

I have opened a PR with a proposal that seems to fix the problem but I am not aware if it can also introduce others. Unfortunately, I have received not feedback yet:

Can anyone help me?

Thanks!

Possibly you could copy these lines to ODBC.jl source file helping that module:

Is this a problem? I mean precompilation is on be default, and is a good thing. Maybe you meant recompilation? You can turn off precompilation, I’m not sure it’s adviced, but since it only happens once, and since 1.9 precompiled to native binaries, they should be fast and the lower compilation trick, first used for Plots.jl, maybe by now outdated? See also there a PR, on how to help tune (I’ve only looked a bit at the former, not yet its successor):

I would also try on 1.10 (or master), about to be released. One way to avoid this is NOT to use that package, SQLAlchemy (is something I’ve seen suggested, maybe something else) with PythonCall.jl. Since I very recently suggested ODBC.jl I would also like to know it works (well). You have no problems, after some initial (on each run?) use? Instead of migrating from the package then to Julia 1.8 or 1.6 temporarily would then also “fix”…?

1 Like

Hi @Palli !

Is this a problem? I mean precompilation is on be default, and is a good thing. Maybe you meant recompilation? You can turn off precompilation, I’m not sure it’s adviced, but since it only happens once, and since 1.9 precompiled to native binaries, they should be fast and the lower compilation trick, first used for Plots.jl, maybe by now outdated? See also there a PR, on how to help tune (I’ve only looked a bit at the former, not yet its successor):

Sorry, that was a typo. I mean recompilation, it happens every new Julia session. Hence, every time the automatic system starts to execute the analysis, it takes 50s only compiling that function mentioned in the PR.

I tried to generate precompile statements using PrecompileTools.jl. However, in this case I get roughly 50s to execute using ODBC.

I would also try on 1.10 (or master), about to be released. One way to avoid this is NOT to use that package, SQLAlchemy (is something I’ve seen suggested, maybe something else) with PythonCall.jl.

I will try in Julia 1.10. I used PyODBC in the past through PythonCall.jl. However, I really do not want to depend on Python for this project.

Since I very recently suggested ODBC.jl I would also like to know it works (well). You have no problems, after some initial (on each run?) use? Instead of migrating from the package then to Julia 1.8 or 1.6 temporarily would then also “fix”…?

It works really well besides this huge time to perform the first query. Going back to 1.8 is not an option because our telemetry analysis system contains the entire satellite telemetry database with a lot of functions. In v1.8, we had recompilation problems which are way worse than I am reporting here in ODBC.jl.

1 Like

For a quick test you can also try starting with

julia -O0

or -O1, or even --compile=min.

It’s good to know, and a clue to what is happening. I think recompilation is a solvable problem in general, a consequence of inlining, and avoidable by completely disabling it with --inline=no (implied above I believe), or with Julia using it more selectively.

I would at least want this problem to go away; in general. Doesn’t happen with Python use…! Should be possible, and do you agree with my analysis of it? I want to know if I’m wrong and (then) understand the problem better.

Ok!

Here are the results of the time it takes to execute DBInterface.execute for the first time:

  1. Current (v1.9 without modifications): 35.1s
  2. julia -O1: 34.9s
  3. julia --compile=min: 34.6s
  4. @optlevel 1 and @max_methods 1: 34.9s
  5. Julia v1.10-RC1: 0.7s!!!

So indeed, something happened in Julia 1.10 that drastically reduced this recompilation time :slight_smile:

Thanks @Palli !

2 Likes

Just for future reference, I can confirm that Julia 1.10 leads to a huge gain in the compilation time I mentioned here in macOS (ARM) and FreeBSD (Intel).

1 Like

Just for curiosity, can anyone tell me what changed between 1.9 and 1.10 that can explain this huge gain?

1 Like