# Can PackageCompiler.jl compile just parts of packages?

**URL:** https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000
**Category:** General Usage
**Tags:** package-compiler
**Created:** [July 3, 2021, 7:31pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000 "2021-07-03T19:31:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)
#### Post date: [July 3, 2021, 7:31pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/1 "2021-07-03T19:31:09Z")

</div>

I’m developing a package, and it takes quite a while to compile (~30s), which is long enough to be annoying when trying to test/bugfix/retest. `PackageCompiler.jl` is awesome and can get rid of the compilation overhead (by creating a `.so`), so a test run takes \<1s instead of ~30s, but that’s not helpful if I need to edit the code and re-run. However, at any one time I’ll only be working on part of the code - it would be wonderful if the other parts could be compiled into a `.so`, while leaving the parts that I’m working on to be recompiled on each run. Is this possible? To be concrete, I’d like to be able to pass a list of submodules or functions from my package to the `create_sysimage` function, and have only those be added.

---

<div class="post-metadata">

### Author: ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)
#### Post date: [July 3, 2021, 7:58pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/2 "2021-07-03T19:58:12Z")

</div>

> [@johnomotani](#):
>
> I’m developing a package, and it takes quite a while to compile (~30s), which is long enough to be annoying when trying to test/bugfix/retest.

Are you using [Revise.jl](https://timholy.github.io/Revise.jl/stable/) already?

---

<div class="post-metadata">

### Author: ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)
#### Post date: [July 3, 2021, 9:36pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/3 "2021-07-03T21:36:40Z")

</div>

> [@rikh](#):
>
> Are you using [Revise.jl](https://timholy.github.io/Revise.jl/stable/) already?

I’m not - I’ve seen the name a couple of times but not looked into that package yet.

Thanks! I’ll put Revise.jl on my reading list.

---

<div class="post-metadata">

### Author: ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)
#### Post date: [July 3, 2021, 10:00pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/4 "2021-07-03T22:00:52Z")

</div>

If you’re developing a package you should definitely try out Revise the next time you open a Julia REPL.

It is so crucial that it is in my autostart and the first one I load in Pluto/Jupyter.

---

<div class="post-metadata">

### Author: ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)
#### Post date: [July 3, 2021, 10:24pm UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/5 "2021-07-03T22:24:39Z")

</div>

Revise.jl does look very nice. On a very quick test though, it doesn’t seem to work with PackageCompiler.jl - in the sense that if I precompile my package with `PackageCompiler.create_sysimage()` (even passing a script to the `precompile_execution_file` argument that has `using Revise` before `using my_package`) then even using the REPL and calling `using Revise` before `using my_package`, and editing `my_package` after doing both of those, the functions called from `my_package` are the ones that were compiled into the `.so`, not the edited ones. It’s not a big issue, as I guess the best practice is to just keep the REPL open and develop using Revise.jl, so PackageCompiler.jl is not needed during development - it would be nice to combine the benefits though!

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [July 4, 2021, 1:55am UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/6 "2021-07-04T01:55:37Z")

</div>

One option is to use PackageCompiler for all your dependencies but not the code you’re actively working on, and then use Revise for the code you are developing.

---

<div class="post-metadata">

### Author: ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)
#### Post date: [July 4, 2021, 10:49am UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/7 "2021-07-04T10:49:45Z")

</div>

Yeah, that seems like it might be the best option. I’m going to try out that workflow and see how it goes!

---

<div class="post-metadata">

### Author: ![ktdq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ktdq/32/37377_2.png) [@ktdq](https://discourse.julialang.org/u/ktdq)
#### Post date: [June 23, 2022, 3:07am UTC](https://discourse.julialang.org/t/can-packagecompiler-jl-compile-just-parts-of-packages/64000/8 "2022-06-23T03:07:36Z")

</div>

I have a function to track a package that is already compiled into a sysimage:

```julia
const SYSIMAGE_TIME = time()

function track_sysimage_package(p)
    id = Base.PkgId(p)
    Revise.watch_package(id)
    pkgdata = Revise.pkgdatas[id]
    for file in Revise.srcfiles(pkgdata)
        fullfile = joinpath(Revise.basedir(pkgdata), file)
        if stat(fullfile).mtime > SYSIMAGE_TIME
            push!(Revise.revision_queue, (pkgdata, file))
        end
    end
end

```

Can it be improved? The speedup is huge!

[https://github.com/timholy/Revise.jl/issues/685](https://github.com/timholy/Revise.jl/issues/685)
