JuliaFormatter.jl icon indicating copy to clipboard operation
JuliaFormatter.jl copied to clipboard

Specifying optlevel for faster package loading

Open baggepinnen opened this issue 4 years ago • 3 comments

It was recently noted in a Zulip chat that JuliaFormatter takes quite a while to load, while subsequent applications of formatting are very snappy. Perhaps specifying a module specific optlevel for JuliaFormatter would be a good idea to reduce the time to first format?

baggepinnen avatar Jan 25 '21 19:01 baggepinnen

Xref https://julialang.zulipchat.com/#narrow/stream/137791-general/topic/python.20-.3E.20julia

MasonProtter avatar Jan 25 '21 20:01 MasonProtter

Would doing precompilation via SnoopCompile help in this regard?

domluna avatar Jan 25 '21 21:01 domluna

I tried it out and it gave an ok speedup

# default
julia> @time format_file("/tmp/testformat.jl")
 10.234360 seconds (4.44 M allocations: 233.703 MiB, 0.72% gc time, 99.93% compilation time)
false


# optlevel 1
julia> @time format_file("/tmp/testformat.jl")
  6.806009 seconds (4.30 M allocations: 226.507 MiB, 2.83% gc time, 99.87% compilation time)

julia> @time format_file("/tmp/testformat.jl") # subsequent calls are still fast, testformat.jl is a file with 400+ sloc
  0.007949 seconds (54.00 k allocations: 3.003 MiB)

optlevel 0 didn't improve the timing any further

baggepinnen avatar Jan 30 '21 09:01 baggepinnen