Very slow pre-compiling and `using`of custom Julia package

I’ve been working on a Julia package at work, call it Unicorns.jl. The package is currently in dev mode. Whenever I make changes to the source and then call using Unicorns (yes, I know about Revise.jl), it takes a very long time to pre-compile (> 30 seconds). Similarly, if I start up a fresh REPL session with no changes to the Unicorns.jl code and I call using Unicorns, it still takes a very long time (~ 30 seconds) to load the package.

Are there certain coding practices that lead to long pre-compile times and long loading times? I don’t think Unicorns.jl is a terribly large package. However, it does have a fairly large number of dependencies. Here is a snapshot of the src/Unicorns.jl file where the Unicorns module is defined:

module Unicorns

using Base.Iterators: product
using CSV
using DataFrames
using DataFramesMeta
import Dates: day, Date, datetime2unix
using Dates
using GLPK
using Interpolations
using JLD2
import JuMP: optimize!
using JuMP
using Lazy: @forward
using Parameters
using RLEVectors
using Statistics
using StatsBase
import TimeZones: astimezone
using TimeZones

const RealVector = AbstractVector{T} where {T <: Real}

# include source files

export # export things

1 Like

Not an expert here, but there is a lot to load. Maybe the compilation of your package is not slow, but loading everything is. In this case, there is not much you can do except from compiling a custom system image as described in PackageCompiler.jl.


I’m finding myself in the same situation. @CameronBieganek Did you find any workaround?

1 Like

I haven’t found a general solution for this, but some helpful tips are in [ANN] Turing 0.9.0.