# Can I set @optlevel as a user per module or per function?

**URL:** <https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192>\
**Category:** Performance\
**Created:** [August 3, 2020, 2:28pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192 "2020-08-03T14:28:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 3, 2020, 2:28pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/1 "2020-08-03T14:28:36Z")

</div>

Specifically, I’m playing with rapidly updating plots in a Pluto environment and would like to _increase_ the level of optimizations applied to Plots.jl as a user to see if it changes update rates.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 3, 2020, 3:05pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/2 "2020-08-03T15:05:27Z")

</div>

Module. The docs should be pretty clear.

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 3, 2020, 3:07pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/3 "2020-08-03T15:07:12Z")

</div>

Where did you find documentation of @optlevel?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 3, 2020, 3:10pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/4 "2020-08-03T15:10:31Z")

</div>

```julia
julia> apropos("@optlevel")
Base.Experimental.@optlevel

help?> Base.Experimental.@optlevel
  Experimental.@optlevel n::Int

  Set the optimization level (equivalent to the -O command line argument) for code in the current module. Submodules inherit the setting of their parent module.

  Supported values are 0, 1, 2, and 3.

  The effective optimization level is the minimum of that specified on the command line and in per-module settings.

```

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [August 3, 2020, 8:08pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/5 "2020-08-03T20:08:20Z")

</div>

Great, only if they didn’t choose that strange function name! Does `apropos` mean “on that subject” from French? Wasn’t just `docsearch` clear and good enough? Of course my native language is neither English nor French. Any way, thanks for that useful information.

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 3, 2020, 8:58pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/6 "2020-08-03T20:58:29Z")

</div>

I had looked for it using `?` and a few attempts, also in the online docs, but had forgotten about `apropros`.

I would really like to be able to do something like `using Plots optlevel=3` but it seems I have to modify the module itself, which means I need to learn a few things first.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 4, 2020, 6:15am UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/7 "2020-08-04T06:15:43Z")

</div>

> [@Seif\_Shebl](#):
>
> Does `apropos` mean “on that subject” from French? Wasn’t just `docsearch` clear and good enough?

This usage goes back to [Unix](https://en.wikipedia.org/wiki/Apropos_(Unix)).

---

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [August 4, 2020, 6:56am UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/8 "2020-08-04T06:56:26Z")

</div>

I’m also interested in playing with the optimization level in current packages.  
Here’s a snippet from Plots.jl:

```julia
module Plots

if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
    @eval Base.Experimental.@optlevel 1
end

const _current_plots_version = VersionNumber(split(first(filter(line -> occursin("version", line), readlines(normpath(@ __DIR__ , "..", "Project.toml")))), "\"")[2])
........

```

Does this mean I simply have to modify the optlevel and rebuild Plots?

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [August 5, 2020, 12:23am UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/9 "2020-08-05T00:23:56Z")

</div>

Did you try different plotting packages?

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [August 5, 2020, 4:57am UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/10 "2020-08-05T04:57:48Z")

</div>

I tried a couple of different backends, `plotly()` (which is my goto in many situations due to the interactivity) is slower than using `gr()`, but I haven’t had time to do a lot more exploring.

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [August 5, 2020, 12:27pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192/11 "2020-08-05T12:27:11Z")

</div>

Okay! Also curious to hear about the speed of other packages (without Plots.jl).
