From a1cfc6d1bf0db6c99498482906db363f941bf09d Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Tue, 17 Dec 2024 13:01:05 +0100 Subject: [PATCH] Improve latency for `Pkg.add` (#4115) * precompile registry update Before ``` julia> @time @eval Pkg.Registry.update() Updating registry at `~/.julia/registries/General.toml` 1.006864 seconds (2.18 M allocations: 148.068 MiB, 1.42% gc time, 43.47% compilation time: 6% of which was recompilation) ``` After ``` julia> @time @eval Pkg.Registry.update() Updating registry at `~/.julia/registries/General.toml` 0.677679 seconds (1.75 M allocations: 125.226 MiB, 2.03% gc time, 14.63% compilation time: 39% of which was recompilation) ``` * add some explicit precompile statements for `Pkg.add` For some reason, these don't seem to "take" on our precompile workload. Before: ``` 1.379429 seconds (3.39 M allocations: 211.476 MiB, 2.36% gc time, 60.64% compilation time: 38% of which was recompilation) ``` After: ``` 0.963989 seconds (2.83 M allocations: 182.510 MiB, 1.67% gc time, 42.22% compilation time: 75% of which was recompilation) ``` * remove call to update registry --------- Co-authored-by: KristofferC --- src/precompile.jl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/precompile.jl b/src/precompile.jl index c5283d7c51..3a7e2ea32f 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -182,6 +182,32 @@ let Base.precompile(Tuple{typeof(Base.deepcopy_internal), Base.Dict{String, Base.Dict{String, String}}, Base.IdDict{Any, Any}}) Base.precompile(Tuple{typeof(Base.deepcopy_internal), Tuple{String}, Base.IdDict{Any, Any}}) Base.precompile(Tuple{Type{Memory{Pkg.Types.PackageSpec}}, UndefInitializer, Int64}) + + # Manually added from trace compiling Pkg.add + # Why needed? Something with constant prop overspecialization? + Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:io, :update_cooldown), Tuple{Base.IOContext{IO}, Dates.Day}}, typeof(Pkg.Registry.update)}) + + Base.precompile(Tuple{Type{Memory{Pkg.Types.PackageSpec}}, UndefInitializer, Int64}) + Base.precompile(Tuple{typeof(Base.hash), Tuple{String, UInt64}, UInt64}) + Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:context,), Tuple{Base.TTY}}, typeof(Base.sprint), Function, Tuple{Pkg.Versions.VersionSpec}}) + Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:context,), Tuple{Base.TTY}}, typeof(Base.sprint), Function, Tuple{String}}) + Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:context,), Tuple{Base.TTY}}, typeof(Base.sprint), Function, Tuple{Base.VersionNumber}}) + Base.precompile(Tuple{typeof(Base.join), Base.IOContext{Base.GenericIOBuffer{Memory{UInt8}}}, Tuple{String, UInt64}, Char}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}, Base.BitArray{2}}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}, Base.BitArray{2}, Base.BitArray{2}}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}, Base.BitArray{2}, Base.BitArray{2}, Vararg{Base.BitArray{2}}}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{1}, Base.BitArray{1}}) + Base.precompile(Tuple{typeof(Base.vcat), Base.BitArray{1}, Base.BitArray{1}, Base.BitArray{1}, Vararg{Base.BitArray{1}}}) + Base.precompile(Tuple{typeof(Base.:(==)), Base.Dict{String, Any}, Base.Dict{String, Any}}) + Base.precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Memory{UInt8}}, Tuple{String}, Char}) + Base.precompile(Tuple{typeof(Base.values), Base.Dict{String, Array{Base.Dict{String, Any}, 1}}}) + Base.precompile(Tuple{typeof(Base.all), Base.Generator{Base.ValueIterator{Base.Dict{String, Array{Base.Dict{String, Any}, 1}}}, TOML.Internals.Printer.var"#5#6"}}) + Base.precompile(Tuple{typeof(TOML.Internals.Printer.is_array_of_tables), Array{Base.Dict{String, Any}, 1}}) + Base.precompile(Tuple{Type{Array{Dates.DateTime, 1}}, UndefInitializer, Tuple{Int64}}) + Base.precompile(Tuple{Type{Pair{A, B} where B where A}, String, Dates.DateTime}) + Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:internal_call, :strict, :warn_loaded, :timing, :_from_loading, :configs, :manifest, :io), Tuple{Bool, Bool, Bool, Bool, Bool, Pair{Base.Cmd, Base.CacheFlags}, Bool, Base.TTY}}, typeof(Base.Precompilation.precompilepkgs), Array{String, 1}}) + ################ end copy!(DEPOT_PATH, original_depot_path) copy!(LOAD_PATH, original_load_path)