Skip to content

Commit

Permalink
Improve latency for Pkg.add (#4115)
Browse files Browse the repository at this point in the history
* 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 <kristoffer.carlsson@juliacomputing.com>
  • Loading branch information
KristofferC and KristofferC authored Dec 17, 2024
1 parent 47ad7e3 commit a1cfc6d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a1cfc6d

Please sign in to comment.