# Bad performance for dispatch-heavy code

**URL:** <https://discourse.julialang.org/t/bad-performance-for-dispatch-heavy-code/28989>\
**Category:** Performance\
**Tags:** question\
**Created:** [September 20, 2019, 8:52am UTC](https://discourse.julialang.org/t/bad-performance-for-dispatch-heavy-code/28989 "2019-09-20T08:52:02Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [September 20, 2019, 9:22am UTC](https://discourse.julialang.org/t/bad-performance-for-dispatch-heavy-code/28989/5 "2019-09-20T09:22:59Z")

</div>

`@snoopi` from [SnoopCompile](https://github.com/timholy/SnoopCompile.jl) will tell you the top-level call to inference (which is the main cost of compilation). You can try explicitly precompiling specific calls, see e.g., [https://github.com/JuliaDebug/JuliaInterpreter.jl/blob/master/src/precompile.jl](https://github.com/JuliaDebug/JuliaInterpreter.jl/blob/master/src/precompile.jl) which gets called during module definition from [here](https://github.com/JuliaDebug/JuliaInterpreter.jl/blob/08333287554a7aa54df447ee13dd465c87afef8b/src/JuliaInterpreter.jl#L125-L126).  
I should say that precompilation doesn’t always “work” because of current limitations in the serialization format of `*.ji` files, but that is expected to change someday ([Change precompilation format to be more amenable to copying by timholy · Pull Request #32705 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/32705)).

There’s also [PkgCompiler](https://github.com/JuliaLang/PackageCompiler.jl) but that may not be so helpful for a package that you’re working on extensively (you have to build Julia itself along with your package, and that is slow).

Reducing compile time is at the top of the priority list now ([Compiler work priorities](https://discourse.julialang.org/t/compiler-work-priorities/17623)).

---

_[View the full topic](https://discourse.julialang.org/t/bad-performance-for-dispatch-heavy-code/28989)._
