Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: speed up bootstrapping time by 25% #41794

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions base/compiler/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
# especially try to make sure any recursive and leaf functions have concrete signatures,
# since we won't be able to specialize & infer them at runtime

let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call, run_passes],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that besides reordering, pure_eval_call has been removed. How come that it isn't needed anymore?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pure_eval_call can be easily inferred from the entries like typeinf, because we make sure Core.Compiler is very type stable.

world = get_world_counter(),
time() = ccall(:jl_clock_now, Float64, ())

let
world = get_world_counter()
interp = NativeInterpreter(world)

fs = Any[
# we first create caches for the optimizer, because they contain many loop constructions
# and they're better to not run in interpreter even during bootstrapping
run_passes,
# then we create caches for inference entries
typeinf_ext, typeinf, typeinf_edge,
]
# tfuncs can't be inferred from the inference entries above, so here we infer them manually
for x in T_FFUNC_VAL
push!(fs, x[3])
end
Expand All @@ -20,6 +30,7 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call, run_passes],
println(stderr, "WARNING: tfunc missing for ", reinterpret(IntrinsicFunction, Int32(i)))
end
end
starttime = time()
for f in fs
for m in _methods_by_ftype(Tuple{typeof(f), Vararg{Any}}, 10, typemax(UInt))
# remove any TypeVars from the intersection
Expand All @@ -32,4 +43,6 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call, run_passes],
typeinf_type(interp, m.method, Tuple{typ...}, m.sparams)
end
end
endtime = time()
println("Core.Compiler ──── ", sub_float(endtime,starttime), " seconds")
end