ronisbr / PrettyTables.jl

Print data in formatted tables.
MIT License
404 stars 38 forks source link

Adding more wholistic precompilation workload #196

Open Moelf opened 1 year ago

Moelf commented 1 year ago

following development of https://github.com/JuliaLang/julia/pull/47184, it seems that this package would benefit from including realistic composite workload.

For example, consider this slow TTFP:

julia> using PrettyTables

julia> @time @eval pretty_table(devnull, Dict(:a=>rand(10), :b=>rand(Float32, 10)))
  0.778972 seconds (1.74 M allocations: 114.494 MiB, 7.43% gc time, 141.16% compilation time)

if we make the following change:

diff --git a/src/PrettyTables.jl b/src/PrettyTables.jl
index a39444d..5fb57d7 100644
--- a/src/PrettyTables.jl
+++ b/src/PrettyTables.jl
@@ -103,6 +103,7 @@ if Base.VERSION >= v"1.4.2" && !haskey(ENV, "PRETTY_TABLES_NO_PRECOMPILATION")
         _precompile_()
     catch
     end
+    pretty_table(devnull, Dict(:a=>rand(UInt8, 10), :b=>rand(Float64, 10)))
 end

 end # module

we get:

julia> using PrettyTables

julia> @time @eval pretty_table(devnull, Dict(:a=>rand(10), :b=>rand(Float32, 10)))
  0.468314 seconds (929.76 k allocations: 59.503 MiB, 10.62% gc time, 141.03% compilation time)

Notice we use different types here to show the precompiled stuff is transferable.

ronisbr commented 1 year ago

Thanks @Moelf ! I will research a little to check how we can use this new feature. Last time I checked, I could drastically reduce the TTFP, but the package loading time was much higher.

ronisbr commented 11 months ago

Hi @Moelf !

I switched to PrecompilationTools.jl (in master). Can you please check if things were improved for you?

Here, the TTFP is very low for your type:

julia> using PrettyTables

julia> @time pretty_table(devnull, Dict(:a=>rand(10), :b=>rand(Float32, 10)))
  0.068245 seconds (94.32 k allocations: 6.304 MiB, 96.88% compilation time)