forked from quinnj/JSONBase.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a hack to avoid inference recursion limit to allow more optimization
For this target: ```julia using JSONBase, BenchmarkTools struct A a::Int b::Int c::Int d::Int end @benchmark JSONBase.materialize("""{ "a": 1, "b": 2, "c": 3, "d": 4}""", A) ``` Before: ```julia BenchmarkTools.Trial: 10000 samples with 331 evaluations. Range (min … max): 258.937 ns … 4.373 μs ┊ GC (min … max): 0.00% … 91.32% Time (median): 279.202 ns ┊ GC (median): 0.00% Time (mean ± σ): 291.054 ns ± 185.340 ns ┊ GC (mean ± σ): 3.24% ± 4.74% ▃█▃ ▂ ▁▂▂▂▁▁▁▁▃███▃▂▂▄█▇▅▅▅▄▂▂▂▃▃▄▃▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂ 259 ns Histogram: frequency by time 334 ns < Memory estimate: 384 bytes, allocs estimate: 10. ``` After: ```julia BenchmarkTools.Trial: 10000 samples with 750 evaluations. Range (min … max): 173.333 ns … 1.618 μs ┊ GC (min … max): 0.00% … 86.43% Time (median): 179.389 ns ┊ GC (median): 0.00% Time (mean ± σ): 184.518 ns ± 58.847 ns ┊ GC (mean ± σ): 1.40% ± 3.86% ▂▄▆██▇▅▄▁▁ ▂▃▄▅▄▄▄▄▂▁▁▁▂▂▂▂▂▂▂▂▂▂▁ ▂ ▂▅▄▅▅▃▃█████████████████████████████████████████████▇▇▅▄▅▆▅▅ █ 173 ns Histogram: log(frequency) by time 200 ns < Memory estimate: 128 bytes, allocs estimate: 2. ``` closes quinnj#2
- Loading branch information
Showing
5 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using JSONBase, JET | ||
|
||
struct OptimizationFailureChecker end | ||
function JET.configured_reports(::OptimizationFailureChecker, reports::Vector{JET.InferenceErrorReport}) | ||
return filter(reports) do @nospecialize report::JET.InferenceErrorReport | ||
isa(report, JET.OptimizationFailureReport) | ||
end | ||
end | ||
|
||
# https://github.com/quinnj/JSONBase.jl/issues/2 | ||
struct RecursiveInferenceTest1 | ||
a::Int | ||
b::Int | ||
end | ||
@test_opt annotate_types=true report_config=OptimizationFailureChecker() JSONBase.materialize("""{ "a": 1, "b": 2 }""", RecursiveInferenceTest1) | ||
|
||
struct RecursiveInferenceTest2Inner | ||
b::Int | ||
end | ||
struct RecursiveInferenceTest2 | ||
a::Int | ||
b::RecursiveInferenceTest2Inner | ||
end | ||
@test_opt annotate_types=true report_config=OptimizationFailureChecker() JSONBase.materialize("""{ "a": 1, "b": { "b": 2 } }""", RecursiveInferenceTest2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters