@@ -11,6 +11,13 @@ This benchmark group `"inference"` is composed of the following subgroups:
11
11
"""
12
12
module InferenceBenchmarks
13
13
14
+ # InferenceBenchmarker
15
+ # ====================
16
+ # this new `AbstractInterpreter` satisfies the minimum interface requirements and manages
17
+ # its cache independently in a way it is totally separated from the native code cache
18
+ # managed by the runtime system: this allows us to profile Julia-level inference reliably
19
+ # without being influenced by previous trials or some native execution
20
+
14
21
using BenchmarkTools, InteractiveUtils
15
22
16
23
const CC = Core. Compiler
@@ -147,39 +154,78 @@ function tune_benchmarks!(
147
154
end
148
155
end
149
156
150
- const SUITE = BenchmarkGroup ()
157
+ # "inference" benchmark targets
158
+ # =============================
151
159
152
160
# TODO add TTFP?
161
+ # XXX some targets below really depends on the compiler implementation itself
162
+ # (e.g. `abstract_call_gf_by_type`) and thus a bit more unreliable -- ideally
163
+ # we want to replace them with other functions that have the similar characteristics
164
+ # but whose call graph are orthogonal to the Julia's compiler implementation
165
+
166
+ using REPL
167
+ brdcast (xs, x) = findall (> (x), abs .(xs))
168
+ let # see https://github.com/JuliaLang/julia/pull/45276
169
+ n = 10000
170
+ ex = Expr (:block )
171
+ var = gensym ()
172
+ push! (ex. args, :($ var = x))
173
+ for _ = 1 : n
174
+ newvar = gensym ()
175
+ push! (ex. args, :($ newvar = $ var + 1 ))
176
+ var = newvar
177
+ end
178
+ @eval global function quadratic (x)
179
+ $ ex
180
+ end
181
+ end
182
+
183
+ const SUITE = BenchmarkGroup ()
153
184
154
185
let g = addgroup! (SUITE, " abstract interpretation" )
155
186
g[" sin(42)" ] = @benchmarkable (@abs_call sin (42 ))
156
187
g[" rand(Float64)" ] = @benchmarkable (@abs_call rand (Float64))
157
188
g[" println(::QuoteNode)" ] = @benchmarkable (abs_call (println, (QuoteNode,)))
189
+ g[" broadcast" ] = @benchmarkable abs_call (brdcast, (Vector{Float64},Float64))
190
+ g[" REPL.REPLCompletions.completions" ] = @benchmarkable abs_call (
191
+ REPL. REPLCompletions. completions, (String,Int))
192
+ g[" Base.init_stdio(::Ptr{Cvoid})" ] = @benchmarkable abs_call (Base. init_stdio, (Ptr{Cvoid},))
158
193
g[" abstract_call_gf_by_type" ] = @benchmarkable abs_call (
159
194
CC. abstract_call_gf_by_type, (NativeInterpreter,Any,CC. ArgInfo,Any,InferenceState,Int))
160
195
g[" construct_ssa!" ] = @benchmarkable abs_call (CC. construct_ssa!, (Core. CodeInfo,CC. IRCode,CC. DomTree,Vector{CC. SlotInfo},Vector{Any}))
161
196
g[" domsort_ssa!" ] = @benchmarkable abs_call (CC. domsort_ssa!, (CC. IRCode,CC. DomTree))
197
+ g[" quadratic" ] = @benchmarkable abs_call (quadratic, (Int,))
162
198
tune_benchmarks! (g)
163
199
end
164
200
165
201
let g = addgroup! (SUITE, " optimization" )
166
202
g[" sin(42)" ] = @benchmarkable f () (setup = (f = @opt_call sin (42 )))
167
203
g[" rand(Float64)" ] = @benchmarkable f () (setup = (f = @opt_call rand (Float64)))
168
204
g[" println(::QuoteNode)" ] = @benchmarkable f () (setup = (f = opt_call (println, (QuoteNode,))))
205
+ g[" broadcast" ] = @benchmarkable f () (setup = (f = opt_call (brdcast, (Vector{Float64},Float64))))
206
+ g[" REPL.REPLCompletions.completions" ] = @benchmarkable f () (setup = (f = opt_call (
207
+ REPL. REPLCompletions. completions, (String,Int))))
208
+ g[" Base.init_stdio(::Ptr{Cvoid})" ] = @benchmarkable f () (setup = (f = opt_call (Base. init_stdio, (Ptr{Cvoid},))))
169
209
g[" abstract_call_gf_by_type" ] = @benchmarkable f () (setup = (f = opt_call (CC. abstract_call_gf_by_type, (NativeInterpreter,Any,CC. ArgInfo,Any,InferenceState,Int))))
170
210
g[" construct_ssa!" ] = @benchmarkable f () (setup = (f = opt_call (CC. construct_ssa!, (Core. CodeInfo,CC. IRCode,CC. DomTree,Vector{CC. SlotInfo},Vector{Any}))))
171
211
g[" domsort_ssa!" ] = @benchmarkable f () (setup = (f = opt_call (CC. domsort_ssa!, (CC. IRCode,CC. DomTree))))
212
+ g[" quadratic" ] = @benchmarkable f () (setup = (f = opt_call (quadratic, (Int,))))
172
213
tune_benchmarks! (g)
173
214
end
174
215
175
216
let g = addgroup! (SUITE, " allinference" )
176
217
g[" sin(42)" ] = @benchmarkable (@inf_call sin (42 ))
177
218
g[" rand(Float64)" ] = @benchmarkable (@inf_call rand (Float64))
178
219
g[" println(::QuoteNode)" ] = @benchmarkable (inf_call (println, (QuoteNode,)))
220
+ g[" broadcast" ] = @benchmarkable inf_call (brdcast, (Vector{Float64},Float64))
221
+ g[" REPL.REPLCompletions.completions" ] = @benchmarkable inf_call (
222
+ REPL. REPLCompletions. completions, (String,Int))
223
+ g[" Base.init_stdio(::Ptr{Cvoid})" ] = @benchmarkable inf_call (Base. init_stdio, (Ptr{Cvoid},))
179
224
g[" abstract_call_gf_by_type" ] = @benchmarkable inf_call (
180
225
CC. abstract_call_gf_by_type, (NativeInterpreter,Any,CC. ArgInfo,Any,InferenceState,Int))
181
226
g[" construct_ssa!" ] = @benchmarkable inf_call (CC. construct_ssa!, (Core. CodeInfo,CC. IRCode,CC. DomTree,Vector{CC. SlotInfo},Vector{Any}))
182
227
g[" domsort_ssa!" ] = @benchmarkable inf_call (CC. domsort_ssa!, (CC. IRCode,CC. DomTree))
228
+ g[" quadratic" ] = @benchmarkable inf_call (quadratic, (Int,))
183
229
tune_benchmarks! (g)
184
230
end
185
231
0 commit comments