Skip to content

Commit 35431bf

Browse files
LilithHafnerpetvanaoscardssmith
authored
Stabilize, optimize, and increase robustness of QuickSort (#45222)
* Change partitioning scheme to use scratch space * Randomize pivot selection with a hash-based fallback for when `rand` is unavailable * remove an unnecessary sorting operation in typealias construction in base/show.jl * Seed rng before generating precompile statements * Add presorted check to avoid performance regressions * test invalid `lt` to close #11429 & #32675 * test that PartialQuickSort is stable * update radix sort dispatch heuristics because quicksort is now faster and the primary competition Co-authored-by: Petr Vana <[email protected]> Co-authored-by: Oscar Smith <[email protected]>
1 parent 05cfe24 commit 35431bf

File tree

7 files changed

+254
-188
lines changed

7 files changed

+254
-188
lines changed

base/reflection.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ since it is not idiomatic to explicitly export names from `Main`.
100100
See also: [`@locals`](@ref Base.@locals), [`@__MODULE__`](@ref).
101101
"""
102102
names(m::Module; all::Bool = false, imported::Bool = false) =
103-
sort!(ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint), m, all, imported))
103+
sort!(unsorted_names(m; all, imported))
104+
unsorted_names(m::Module; all::Bool = false, imported::Bool = false) =
105+
ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint), m, all, imported)
104106

105107
isexported(m::Module, s::Symbol) = ccall(:jl_module_exports_p, Cint, (Any, Any), m, s) != 0
106108
isdeprecated(m::Module, s::Symbol) = ccall(:jl_is_binding_deprecated, Cint, (Any, Any), m, s) != 0

base/show.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ function make_typealias(@nospecialize(x::Type))
606606
end
607607
x isa UnionAll && push!(xenv, x)
608608
for mod in mods
609-
for name in names(mod)
609+
for name in unsorted_names(mod)
610610
if isdefined(mod, name) && !isdeprecated(mod, name) && isconst(mod, name)
611611
alias = getfield(mod, name)
612612
if alias isa Type && !has_free_typevars(alias) && !print_without_params(alias) && x <: alias
@@ -810,7 +810,7 @@ function make_typealiases(@nospecialize(x::Type))
810810
end
811811
x isa UnionAll && push!(xenv, x)
812812
for mod in mods
813-
for name in names(mod)
813+
for name in unsorted_names(mod)
814814
if isdefined(mod, name) && !isdeprecated(mod, name) && isconst(mod, name)
815815
alias = getfield(mod, name)
816816
if alias isa Type && !has_free_typevars(alias) && !print_without_params(alias) && !(alias <: Tuple)

0 commit comments

Comments
 (0)