# Making use of \`optlevel\` etc

**URL:** https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917
**Category:** Performance
**Created:** [November 10, 2020, 2:31pm UTC](https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917 "2020-11-10T14:31:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [November 10, 2020, 2:31pm UTC](https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917/1 "2020-11-10T14:31:50Z")

</div>

The Makie ecosystem still suffers from large compilation latency. Tim Holy has kindly been looking at invalidations for us, but that is relatively slow work and hard to do for the amount of code that is there. One option we could try is using the relatively new `@optlevel` macro. But this only allows setting one level per module. There is a hierarchy of functions in AbstractPlotting, some of which definitely need to be optimized, others probably not much or not at all. Is there any way to achieve that, short of reorganizing everything and forcing different code into modules just for this?

The hierarchy is something comparable to the following:

```julia
# called less often, less optimization needed
top-level plotting functions
plot objects
.
.
.
low-level objects
projection math
backend interface code
# called more often, more optimization needed

```

I suspect that a lot of time is spent optimizing / compiling / inferring top to medium level functions, even though the cost of calling these is very small compared to all the low-level functions that do the interesting stuff. Any advice on how to disentangle these and spend the least amount of processing power on unnecessary optimizations?

Ideally, I’d want to “pythonize” the top level stuff, it can be inefficient for all I care, if it gets the startup time down.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [November 10, 2020, 2:35pm UTC](https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917/2 "2020-11-10T14:35:05Z")

</div>

You can try adding `@nospecialize` at top level, which should apply until disabled:

```julia
@nospecialize

function slow(x) ... end

@specialize

function fast(x,y) ... end

```
