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

Precompilation is cool, we should do more of it #2160

Merged
merged 9 commits into from
Dec 4, 2024
Merged

Precompilation is cool, we should do more of it #2160

merged 9 commits into from
Dec 4, 2024

Conversation

wsmoses
Copy link
Member

@wsmoses wsmoses commented Dec 3, 2024

No description provided.

@wsmoses wsmoses requested a review from vchuravy December 3, 2024 11:05
@wsmoses
Copy link
Member Author

wsmoses commented Dec 3, 2024

ERROR: The following 1 direct dependency failed to precompile:

Enzyme [7da242da-08ed-463a-9acd-ee780be4f1d9]

Failed to precompile Enzyme [7da242da-08ed-463a-9acd-ee780be4f1d9] to "/home/wmoses/.julia/compiled/v1.10/Enzyme/jl_cLDM8s".
[3550387] signal (11.1): Segmentation fault
in expression starting at /home/wmoses/git/Enzyme.jl/src/precompile.jl:3
operator() at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Target/TargetMachine.cpp:219 [inlined]
__invoke_impl<llvm::TargetTransformInfo, llvm::TargetMachine::getTargetIRAnalysis() const::<lambda(const llvm::Function&)>&, const llvm::Function&> at /usr/include/c++/11/bits/invoke.h:61 [inlined]
__invoke_r<llvm::TargetTransformInfo, llvm::TargetMachine::getTargetIRAnalysis() const::<lambda(const llvm::Function&)>&, const llvm::Function&> at /usr/include/c++/11/bits/invoke.h:143 [inlined]
_M_invoke at /usr/include/c++/11/bits/std_function.h:291
operator() at /usr/include/c++/11/bits/std_function.h:590 [inlined]
run at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Analysis/TargetTransformInfo.cpp:1202 [inlined]
getTTI at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Analysis/TargetTransformInfo.cpp:1233
getAssumptionCache at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Analysis/AssumptionCache.cpp:295
runOnFunction at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Analysis/BasicAliasAnalysis.cpp:1899
runOnFunction at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/LegacyPassManager.cpp:1430
runOnModule at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/LegacyPassManager.cpp:1476
runOnModule at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/LegacyPassManager.cpp:1545 [inlined]
run at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/LegacyPassManager.cpp:535
LLVMRunPassManager at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/Core.cpp:4172
LLVMRunPassManager at /home/wmoses/.julia/packages/LLVM/wMjUU/lib/15/libLLVM.jl:6353 [inlined]
run! at /home/wmoses/.julia/packages/LLVM/wMjUU/src/passmanager.jl:39 [inlined]
#18867 at /home/wmoses/git/Enzyme.jl/src/compiler/optimize.jl:472
#ModulePassManager#49 at /home/wmoses/.julia/packages/LLVM/wMjUU/src/passmanager.jl:33
ModulePassManager at /home/wmoses/.julia/packages/LLVM/wMjUU/src/passmanager.jl:30 [inlined]
optimize! at /home/wmoses/git/Enzyme.jl/src/compiler/optimize.jl:457
#codegen#18938 at /home/wmoses/git/Enzyme.jl/src/compiler.jl:4088
codegen at /home/wmoses/git/Enzyme.jl/src/compiler.jl:3218 [inlined]
_thunk at /home/wmoses/git/Enzyme.jl/src/compiler.jl:5265
_thunk at /home/wmoses/git/Enzyme.jl/src/compiler.jl:5265
unknown function (ip: 0x7cbbfb5393d9)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2895
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
cached_compilation at /home/wmoses/git/Enzyme.jl/src/compiler.jl:5306
unknown function (ip: 0x7cbc02369449)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2895
ijl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2902
thunkbase at /home/wmoses/git/Enzyme.jl/src/compiler.jl:5410
thunk_generator at /home/wmoses/git/Enzyme.jl/src/compiler.jl:5562
unknown function (ip: 0x7cbc0235ecd5)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2895
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_call_staged at /home/wmoses/git/Enzyme.jl/julia10/src/method.c:540
ijl_code_for_staged at /home/wmoses/git/Enzyme.jl/julia10/src/method.c:593
get_staged at ./compiler/utilities.jl:123
retrieve_code_info at ./compiler/utilities.jl:135 [inlined]
InferenceState at ./compiler/inferencestate.jl:430
typeinf_edge at ./compiler/typeinfer.jl:920
abstract_call_method at ./compiler/abstractinterpretation.jl:629
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:95
abstract_call_known at ./compiler/abstractinterpretation.jl:2087
abstract_call at ./compiler/abstractinterpretation.jl:2169
abstract_call at ./compiler/abstractinterpretation.jl:2162
abstract_call at ./compiler/abstractinterpretation.jl:2354
abstract_eval_call at ./compiler/abstractinterpretation.jl:2370
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2380
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2624
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2889
typeinf_local at ./compiler/abstractinterpretation.jl:3098
typeinf_nocycle at ./compiler/abstractinterpretation.jl:3186
_typeinf at ./compiler/typeinfer.jl:247
typeinf at ./compiler/typeinfer.jl:212
typeinf_edge at ./compiler/typeinfer.jl:930
abstract_call_method at ./compiler/abstractinterpretation.jl:629
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:95
abstract_call_known at ./compiler/abstractinterpretation.jl:2087
abstract_call at ./compiler/abstractinterpretation.jl:2169
abstract_apply at ./compiler/abstractinterpretation.jl:1612
abstract_call_known at ./compiler/abstractinterpretation.jl:2004
abstract_call at ./compiler/abstractinterpretation.jl:2169
abstract_call at ./compiler/abstractinterpretation.jl:2162
abstract_call at ./compiler/abstractinterpretation.jl:2354
abstract_eval_call at ./compiler/abstractinterpretation.jl:2370
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2380
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2624
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2913
typeinf_local at ./compiler/abstractinterpretation.jl:3098
typeinf_nocycle at ./compiler/abstractinterpretation.jl:3186
_typeinf at ./compiler/typeinfer.jl:247
typeinf at ./compiler/typeinfer.jl:212
typeinf_edge at ./compiler/typeinfer.jl:930
abstract_call_method at ./compiler/abstractinterpretation.jl:629
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:95
abstract_call_known at ./compiler/abstractinterpretation.jl:2087
abstract_call at ./compiler/abstractinterpretation.jl:2169
abstract_apply at ./compiler/abstractinterpretation.jl:1612
abstract_call_known at ./compiler/abstractinterpretation.jl:2004
abstract_call at ./compiler/abstractinterpretation.jl:2169
abstract_call at ./compiler/abstractinterpretation.jl:2162
abstract_call at ./compiler/abstractinterpretation.jl:2354
abstract_eval_call at ./compiler/abstractinterpretation.jl:2370
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2380
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2624
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2913
typeinf_local at ./compiler/abstractinterpretation.jl:3098
typeinf_nocycle at ./compiler/abstractinterpretation.jl:3186
_typeinf at ./compiler/typeinfer.jl:247
typeinf at ./compiler/typeinfer.jl:212
typeinf_ext at ./compiler/typeinfer.jl:1051
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1082
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1078
jfptr_typeinf_ext_toplevel_35947 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
jl_type_infer at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:394
jl_generate_fptr_impl at /home/wmoses/git/Enzyme.jl/julia10/src/jitlayers.cpp:504
jl_compile_method_internal at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2481
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2887
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
macro expansion at /home/wmoses/git/Enzyme.jl/src/precompile.jl:11 [inlined]
macro expansion at /home/wmoses/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
macro expansion at /home/wmoses/git/Enzyme.jl/src/precompile.jl:10 [inlined]
macro expansion at /home/wmoses/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:140 [inlined]
top-level scope at /home/wmoses/git/Enzyme.jl/src/precompile.jl:139
jl_fptr_args at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2537
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2895
ijl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2902
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:925
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:877
ijl_toplevel_eval at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:943
ijl_toplevel_eval_in at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
jl_fptr_args at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2537
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
_include at ./loading.jl:2136
include at ./Base.jl:495
jfptr_include_46713 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
jl_f__call_latest at /home/wmoses/git/Enzyme.jl/julia10/src/builtins.c:812
include at /home/wmoses/git/Enzyme.jl/src/Enzyme.jl:1
unknown function (ip: 0x7cbc04100759)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
do_call at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:126
eval_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:223
eval_stmt_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:174
eval_body at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:617
jl_interpret_toplevel_thunk at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:775
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:934
jl_eval_module_expr at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:215
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:736
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:877
ijl_toplevel_eval at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:943
ijl_toplevel_eval_in at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
jl_fptr_args at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2537
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
_include at ./loading.jl:2136
include at ./Base.jl:495 [inlined]
include_package_for_output at ./loading.jl:2222
jfptr_include_package_for_output_81296 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
do_call at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:126
eval_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:223
eval_stmt_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:174
eval_body at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:617
jl_interpret_toplevel_thunk at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:775
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:934
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:877
ijl_toplevel_eval at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:943
ijl_toplevel_eval_in at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
include_string at ./loading.jl:2086 [inlined]
exec_options at ./client.jl:316
_start at ./client.jl:552
jfptr__start_82996 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
true_main at /home/wmoses/git/Enzyme.jl/julia10/src/jlapi.c:582
jl_repl_entrypoint at /home/wmoses/git/Enzyme.jl/julia10/src/jlapi.c:731
jl_load_repl at /home/wmoses/git/Enzyme.jl/julia10/cli/loader_lib.c:568
main at /home/wmoses/git/Enzyme.jl/julia10/cli/loader_exe.c:58
unknown function (ip: 0x7cbc0482a1c9)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/wmoses/git/Enzyme.jl/julia10/usr/bin/julia-debug (unknown line)
Allocations: 84594354 (Pool: 84492748; Big: 101606); GC: 7
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/git/Enzyme.jl/julia10/usr/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{io::Base.TTY})
    @ Pkg.API ~/git/Enzyme.jl/julia10/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:1700
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API ~/git/Enzyme.jl/julia10/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
  [4] precompile
    @ ~/git/Enzyme.jl/julia10/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
  [5] #precompile#114
    @ ~/git/Enzyme.jl/julia10/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
  [6] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1963
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [10] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [11] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [13] macro expansion
    @ ./loading.jl:1790 [inlined]
 [14] macro expansion
    @ ./lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [16] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [17] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746

@vchuravy
Copy link
Member

vchuravy commented Dec 3, 2024

Won't this run into the issues from #1549 (comment)?

Copy link
Contributor

github-actions bot commented Dec 4, 2024

Benchmark Results

main d38f1a4... main/d38f1a4b8ffd90...
basics/overhead 4.33 ± 0.34 ns 4.33 ± 0.01 ns 1
time_to_load 1.05 ± 0.019 s 1.06 ± 0.01 s 0.989

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@wsmoses
Copy link
Member Author

wsmoses commented Dec 4, 2024

Reduces first compile time down from 8s -> 0.3s

@wsmoses
Copy link
Member Author

wsmoses commented Dec 4, 2024

@wsmoses wsmoses merged commit 358d647 into main Dec 4, 2024
21 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants