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

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.

1 Like

Module. The docs should be pretty clear.

Where did you find documentation of @optlevel?

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.
4 Likes

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.

4 Likes

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.

This usage goes back to Unix.

2 Likes

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

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?

1 Like

Did you try different plotting packages?

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.

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