JuliaFormatter.jl
JuliaFormatter.jl copied to clipboard
Specifying optlevel for faster package loading
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?
Xref https://julialang.zulipchat.com/#narrow/stream/137791-general/topic/python.20-.3E.20julia
Would doing precompilation via SnoopCompile help in this regard?
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