Slow precompile time with ControlSystems.jl

I’m new to Julia, and I’m excited at the Control Systems design capability! I’m using macOS Catalina on a late 2013 MacBook Pro (2.4 GHz duel-core i5).

I understand the initial startup will take longer than subsequent startups due to just in time compiling, and other concepts I don’t fully understand! But I’m finding extremely long pre-compile times when loading ControlSystems.jl. Is this typical, or an indication that something is wrong? It’s odd to me that the package requires 1.418 GiB, is that typical for packages?

julia> @time using ControlSystems
[ Info: Precompiling ControlSystems [a6e380b2-a6ca-5380-bf3e-84a91bcd477e]
139.132995 seconds (26.78 M allocations: 1.418 GiB, 0.37% gc time)

I know this is a basic question, I’d appreciate someone pointing me in the right direction!

Hello and welcome to the community! Which versions of Julia and Controlsystems.jl are you using? The precompile time can be quite long, in particular if you haven’t previously precompiled Ordinarydiffeq.jl

This is just the total amount of memory allocated during the operation. You can ignore it.

2 Likes

Thank you! I’m using the following versions:

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, haswell)
"ControlSystems"        => v"0.6.0"

That makes sense, sounds good. So the 2+ minute pre-compile time typical for weaker laptops then?

Thank you! To check my understanding, is 1.1418 GiB the amount that each package keeps in memory after using Package? Or is that memory unallocated after loading. Seems like the memory is unallocated.

It’s the total amount that was allocated (cumulative sum) during loading. Almost all of it will have been unallocated.

1 Like

Yep, everything seems to be up to date. Hopefully you’ll only experience the precompilation once, and subsequent uses of the package should be snappier (until it is updated, when you have to precompile again).

1 Like

Thanks for the help, that makes sense. Last question - I need to precompile every time I start Julia, is that the right workflow? I see PackageCompiler.jl can save those package binaries for use next time I start Julia, but to clarify, without PackageCompiler.jl you need to pre-compile package with every new Julia instance?

It should only recompile once and then never again until the package or one of its dependencies is updated. Did you perhaps update any package since the last precompilation? Or did you get a warning message during the precompilation?

1 Like

It’s no longer precompiling every startup, I must have been mistaken.

Following these steps…

  1. julia
  2. @time using ControlSystems

I get the following output:
39.675718 seconds (48.37 M allocations: 2.587 GiB, 3.47% gc time)

It says nothing about pre-compiling, it just takes ~40 seconds to load ControlSystems. Thanks for your help!

I am not sure if you are aware, but I really recommend you looking into: Revise.jl, jupyter notebooks, or Pluto.jl (which one depends on your workflow) to avoid having to load such packages frequently.

I use Jupyter notebooks for data analysis. I load a notebook in the morning, and work in there for the whole day, so I only pay the price for loading, one time, while I am eating breakfast. If you declare many new structures it may not be viable however.

2 Likes

Loading rarely takes more than a minute for me. I guess you must be a fast eater :wink:

1 Like