Skip to content

Commit 4687d0f

Browse files
authored
inference: add benchmark target to check benefit of method match cache (#299)
This benchmark target corresponds to JuliaLang/julia/pull/46535. `method_match_cache` contains many artificially generated broadcasting operations, that will lead to constant propagations and accompanying method match analysis on call sites with same abstract signatures, e.g. - `Tuple{typeof(convert), Type{Int64}, Int64}` - `Tuple{typeof(convert), Type{Float64}, Float64}` Since we currently don't cache method match result for abstract call signatures on the level of the runtime system, we can obtain the best performance if we cache such abstract method match results on Julia level, that will be revived by JuliaLang/julia/pull/46535.
1 parent f68f9ee commit 4687d0f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/inference/InferenceBenchmarks.jl

+17
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ let # see https://github.com/JuliaLang/julia/pull/45276
179179
$ex
180180
end
181181
end
182+
let # see https://github.com/JuliaLang/julia/pull/46535
183+
n = 100
184+
ex = Expr(:block)
185+
var = gensym()
186+
push!(ex.args, :(y = sum(x)))
187+
for i = 1:n
188+
push!(ex.args, :(x .= $(Float64(i))))
189+
push!(ex.args, :(y += sum(x)))
190+
end
191+
push!(ex.args, :(return y))
192+
@eval global function method_match_cache(x)
193+
$ex
194+
end
195+
end
182196

183197
const SUITE = BenchmarkGroup()
184198

@@ -195,6 +209,7 @@ let g = addgroup!(SUITE, "abstract interpretation")
195209
g["construct_ssa!"] = @benchmarkable abs_call(CC.construct_ssa!, (Core.CodeInfo,CC.IRCode,CC.DomTree,Vector{CC.SlotInfo},Vector{Any}))
196210
g["domsort_ssa!"] = @benchmarkable abs_call(CC.domsort_ssa!, (CC.IRCode,CC.DomTree))
197211
g["quadratic"] = @benchmarkable abs_call(quadratic, (Int,))
212+
g["method_match_cache"] = @benchmarkable abs_call(method_match_cache, (Float64,))
198213
tune_benchmarks!(g)
199214
end
200215

@@ -210,6 +225,7 @@ let g = addgroup!(SUITE, "optimization")
210225
g["construct_ssa!"] = @benchmarkable f() (setup = (f = opt_call(CC.construct_ssa!, (Core.CodeInfo,CC.IRCode,CC.DomTree,Vector{CC.SlotInfo},Vector{Any}))))
211226
g["domsort_ssa!"] = @benchmarkable f() (setup = (f = opt_call(CC.domsort_ssa!, (CC.IRCode,CC.DomTree))))
212227
g["quadratic"] = @benchmarkable f() (setup = (f = opt_call(quadratic, (Int,))))
228+
g["method_match_cache"] = @benchmarkable f() (setup = (f = opt_call(method_match_cache, (Float64,))))
213229
tune_benchmarks!(g)
214230
end
215231

@@ -226,6 +242,7 @@ let g = addgroup!(SUITE, "allinference")
226242
g["construct_ssa!"] = @benchmarkable inf_call(CC.construct_ssa!, (Core.CodeInfo,CC.IRCode,CC.DomTree,Vector{CC.SlotInfo},Vector{Any}))
227243
g["domsort_ssa!"] = @benchmarkable inf_call(CC.domsort_ssa!, (CC.IRCode,CC.DomTree))
228244
g["quadratic"] = @benchmarkable inf_call(quadratic, (Int,))
245+
g["method_match_cache"] = @benchmarkable inf_call(method_match_cache, (Float64,))
229246
tune_benchmarks!(g)
230247
end
231248

0 commit comments

Comments
 (0)