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

**URL:** https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708
**Category:** General Usage
**Created:** [May 28, 2019, 8:59pm UTC](https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708 "2019-05-28T20:59:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [May 28, 2019, 8:59pm UTC](https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708/1 "2019-05-28T20:59:18Z")

</div>

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:

```julia
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 MathOptInterface: OPTIMAL, OPTIMIZE_NOT_CALLED
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

end

```

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [May 28, 2019, 9:29pm UTC](https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708/2 "2019-05-28T21:29:48Z")

</div>

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](https://github.com/JuliaLang/PackageCompiler.jl).

---

<div class="post-metadata">

### Author: ![donquicote](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@donquicote](https://discourse.julialang.org/u/donquicote)
#### Post date: [May 9, 2020, 12:33pm UTC](https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708/3 "2020-05-09T12:33:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ianfiske](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ianfiske](https://discourse.julialang.org/u/ianfiske)
#### Post date: [May 12, 2020, 4:12pm UTC](https://discourse.julialang.org/t/very-slow-pre-compiling-and-using-of-custom-julia-package/24708/4 "2020-05-12T16:12:10Z")

</div>

I haven’t found a general solution for this, but some helpful tips are in [[ANN] Turing 0.9.0 - #5 by cpfiffer](https://discourse.julialang.org/t/ann-turing-0-9-0/35102/5).
