Skip to content

Commit

Permalink
Upgrade JSON Toolkit to improve dynamic references detection (#314)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Dec 19, 2024
1 parent bdc63bc commit b0dbe56
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 99f8b42d5f1a8b0f9b3c024f5957dc399bc0262f
jsontoolkit https://github.com/sourcemeta/jsontoolkit 18207a35d087c85f5acfb5176f2ec37283e91420
jsontoolkit https://github.com/sourcemeta/jsontoolkit 47856cbaeb80d72705c655dd0085d4bc4f579b67
googletest https://github.com/google/googletest a7f443b80b105f940225332ed3c31f2790092f47
googlebenchmark https://github.com/google/benchmark 378fe693a1ef51500db21b11ff05a8018c5f0e55
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite c2badb1298a8698f86dadf1aea7b44b3a894e5ac
21 changes: 3 additions & 18 deletions test/evaluator/evaluator_2020_12_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1244,29 +1244,14 @@ TEST(Evaluator_2020_12, dynamicRef_1) {
})JSON")};

const sourcemeta::jsontoolkit::JSON instance{"foo"};
EVALUATE_WITH_TRACE_FAST_SUCCESS(schema, instance, 3);
EVALUATE_WITH_TRACE_FAST_SUCCESS(schema, instance, 1);

EVALUATE_TRACE_PRE(0, ControlMark, "", "#/$defs/string", "");
EVALUATE_TRACE_PRE(1, ControlDynamicAnchorJump, "/$dynamicRef",
"#/$dynamicRef", "");
EVALUATE_TRACE_PRE(2, AssertionTypeStrict, "/$dynamicRef/type",
EVALUATE_TRACE_PRE(0, AssertionTypeStrict, "/$dynamicRef/type",
"#/$defs/string/type", "");

EVALUATE_TRACE_POST_SUCCESS(0, ControlMark, "", "#/$defs/string", "");
EVALUATE_TRACE_POST_SUCCESS(1, AssertionTypeStrict, "/$dynamicRef/type",
EVALUATE_TRACE_POST_SUCCESS(0, AssertionTypeStrict, "/$dynamicRef/type",
"#/$defs/string/type", "");
EVALUATE_TRACE_POST_SUCCESS(2, ControlDynamicAnchorJump, "/$dynamicRef",
"#/$dynamicRef", "");

EVALUATE_TRACE_POST_DESCRIBE(instance, 0,
"The schema location was marked for "
"future use");
EVALUATE_TRACE_POST_DESCRIBE(instance, 1,
"The value was expected to be of type string");
EVALUATE_TRACE_POST_DESCRIBE(
instance, 2,
"The string value was expected to validate against the first subschema "
"in scope that declared the dynamic anchor \"foo\"");
}

TEST(Evaluator_2020_12, definitions_1) {
Expand Down
72 changes: 71 additions & 1 deletion vendor/jsontoolkit/src/jsonschema/reference.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 comments on commit b0dbe56

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark (macos/llvm)

Benchmark suite Current: b0dbe56 Previous: bdc63bc Ratio
Compiler_Draft6_AdaptiveCard 33701604290.999966 ns/iter 33785979999.999996 ns/iter 1.00
Compiler_2019_09_OMC_JSON_V2 7859069125.000019 ns/iter 7841983708.000044 ns/iter 1.00
Evaluator_Draft4_Meta_1_No_Callback 169.49840007240775 ns/iter 166.21466796265207 ns/iter 1.02
Evaluator_Draft4_Required_Properties 450.83163397014874 ns/iter 437.29636581372546 ns/iter 1.03
Evaluator_Draft4_Many_Optional_Properties_Minimal_Match 18.925005905882617 ns/iter 18.86903155251137 ns/iter 1.00
Evaluator_Draft4_Few_Optional_Properties_Minimal_Match 9.20463123814013 ns/iter 9.103260829013058 ns/iter 1.01
Evaluator_Draft4_Items_Schema 265.9390861738754 ns/iter 255.86887596953736 ns/iter 1.04
Evaluator_Draft4_Nested_Object 3.13778333904908 ns/iter 3.151550554594849 ns/iter 1.00
Evaluator_Draft4_Properties_Triad_Optional 743.9118346244679 ns/iter 734.4323758938381 ns/iter 1.01
Evaluator_Draft4_Properties_Triad_Closed 611.7792482393158 ns/iter 613.4053509473293 ns/iter 1.00
Evaluator_Draft4_Properties_Triad_Required 757.8258046633241 ns/iter 752.8499913293316 ns/iter 1.01
Evaluator_Draft4_Properties_Closed 47.97851450510459 ns/iter 47.68687159946659 ns/iter 1.01
Evaluator_Draft4_Non_Recursive_Ref 9.398376646238193 ns/iter 9.407752649884314 ns/iter 1.00
Evaluator_Draft4_Pattern_Properties_True 157.1727012708528 ns/iter 158.16143335469948 ns/iter 0.99
Evaluator_Draft4_Ref_To_Single_Property 9.131983734785841 ns/iter 9.12053957624424 ns/iter 1.00
Evaluator_Draft4_Additional_Properties_Type 15.600777685918867 ns/iter 16.47421821760238 ns/iter 0.95
Evaluator_Draft4_Nested_Oneof 48.67216136185197 ns/iter 48.640893753671314 ns/iter 1.00
Evaluator_Draft4_Long_Enum 27.098636848660213 ns/iter 26.500267725496315 ns/iter 1.02
Evaluator_Draft4_Type_Object 5.378732900759959 ns/iter 5.414288131132482 ns/iter 0.99
Evaluator_Draft6_Property_Names 86.51968011067643 ns/iter 87.61528916939564 ns/iter 0.99
Evaluator_Draft7_If_Then_Else 24.194754126928174 ns/iter 24.630269356167048 ns/iter 0.98
Evaluator_Draft7_Vercel_1 33493.360277133164 ns/iter 33298.94911504153 ns/iter 1.01
Evaluator_Draft7_Helm_Chart_Lock_1 141.59963189831572 ns/iter 140.72262991154875 ns/iter 1.01
Evaluator_Draft7_Jasmine_1 120.9317096648427 ns/iter 122.7309127548932 ns/iter 0.99
Evaluator_2019_09_Unevaluated_Properties 176.2580908070022 ns/iter 175.67863634766888 ns/iter 1.00
Evaluator_2019_09_OMC_JSON_V2_1 990.1309999033903 ns/iter 983.379984682522 ns/iter 1.01
Evaluator_2020_12_Dynamic_Ref 368.2846344359645 ns/iter 364.2294661187902 ns/iter 1.01
Evaluator_2020_12_Dynamic_Ref_Single 5.4090116185103705 ns/iter 32.55911098744096 ns/iter 0.17
Evaluator_2020_12_CQL_1 3410.7605552029722 ns/iter 3109.93271014231 ns/iter 1.10

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark (linux/llvm)

Benchmark suite Current: b0dbe56 Previous: bdc63bc Ratio
Compiler_Draft6_AdaptiveCard 50260761906.99996 ns/iter 49870812780.00005 ns/iter 1.01
Compiler_2019_09_OMC_JSON_V2 10644236054.999966 ns/iter 10515422338.000008 ns/iter 1.01
Evaluator_Draft4_Meta_1_No_Callback 239.58610710649054 ns/iter 239.45344808814534 ns/iter 1.00
Evaluator_Draft4_Required_Properties 583.8419306349134 ns/iter 589.525657761402 ns/iter 0.99
Evaluator_Draft4_Many_Optional_Properties_Minimal_Match 28.38598328228666 ns/iter 29.645150426053167 ns/iter 0.96
Evaluator_Draft4_Few_Optional_Properties_Minimal_Match 16.268975386535214 ns/iter 16.3712368080396 ns/iter 0.99
Evaluator_Draft4_Items_Schema 605.306733559606 ns/iter 631.4781221922051 ns/iter 0.96
Evaluator_Draft4_Nested_Object 4.973869370904231 ns/iter 4.944255175601759 ns/iter 1.01
Evaluator_Draft4_Properties_Triad_Optional 851.2292476815461 ns/iter 864.808948400159 ns/iter 0.98
Evaluator_Draft4_Properties_Triad_Closed 684.7887144024619 ns/iter 700.1912667219292 ns/iter 0.98
Evaluator_Draft4_Properties_Triad_Required 881.8432350891624 ns/iter 903.2666745784271 ns/iter 0.98
Evaluator_Draft4_Properties_Closed 75.80737976842035 ns/iter 80.66711181409538 ns/iter 0.94
Evaluator_Draft4_Non_Recursive_Ref 33.057180336900224 ns/iter 32.337470964245036 ns/iter 1.02
Evaluator_Draft4_Pattern_Properties_True 258.0380766315266 ns/iter 251.50809098700714 ns/iter 1.03
Evaluator_Draft4_Ref_To_Single_Property 16.22688132424409 ns/iter 16.539334492759163 ns/iter 0.98
Evaluator_Draft4_Additional_Properties_Type 60.968033627650186 ns/iter 61.02759459620867 ns/iter 1.00
Evaluator_Draft4_Nested_Oneof 85.53950656394214 ns/iter 87.91529020030406 ns/iter 0.97
Evaluator_Draft4_Long_Enum 19.284985272533838 ns/iter 19.597075908794725 ns/iter 0.98
Evaluator_Draft4_Type_Object 9.959813806021495 ns/iter 10.281664293822017 ns/iter 0.97
Evaluator_Draft6_Property_Names 127.26443124453093 ns/iter 129.6237269557134 ns/iter 0.98
Evaluator_Draft7_If_Then_Else 39.20573785554483 ns/iter 40.033119265255536 ns/iter 0.98
Evaluator_Draft7_Vercel_1 52784.78725825142 ns/iter 47624.46477140512 ns/iter 1.11
Evaluator_Draft7_Helm_Chart_Lock_1 302.469823022284 ns/iter 295.7993066057546 ns/iter 1.02
Evaluator_Draft7_Jasmine_1 173.73994206910527 ns/iter 174.68328322266635 ns/iter 0.99
Evaluator_2019_09_Unevaluated_Properties 197.7894752615293 ns/iter 198.15682187089357 ns/iter 1.00
Evaluator_2019_09_OMC_JSON_V2_1 1570.7312741244523 ns/iter 1493.9478897742379 ns/iter 1.05
Evaluator_2020_12_Dynamic_Ref 563.2126209961026 ns/iter 582.7759393876337 ns/iter 0.97
Evaluator_2020_12_Dynamic_Ref_Single 9.979774750101546 ns/iter 49.87936857595142 ns/iter 0.20
Evaluator_2020_12_CQL_1 4608.107605518704 ns/iter 5454.021599908193 ns/iter 0.84

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark (macos/gcc)

Benchmark suite Current: b0dbe56 Previous: bdc63bc Ratio
Compiler_Draft6_AdaptiveCard 47213049173.3551 ns/iter 41582784891.12854 ns/iter 1.14
Compiler_2019_09_OMC_JSON_V2 9370724201.202393 ns/iter 8088567018.508911 ns/iter 1.16
Evaluator_Draft4_Meta_1_No_Callback 167.6851311734669 ns/iter 160.4034513281527 ns/iter 1.05
Evaluator_Draft4_Required_Properties 453.5305782235508 ns/iter 370.25321639666095 ns/iter 1.22
Evaluator_Draft4_Many_Optional_Properties_Minimal_Match 20.918658003366247 ns/iter 17.1681814399825 ns/iter 1.22
Evaluator_Draft4_Few_Optional_Properties_Minimal_Match 12.784032329801994 ns/iter 9.778761050391543 ns/iter 1.31
Evaluator_Draft4_Items_Schema 467.21926026427326 ns/iter 465.8656895347175 ns/iter 1.00
Evaluator_Draft4_Nested_Object 2.083222070485872 ns/iter 1.9573627371649907 ns/iter 1.06
Evaluator_Draft4_Properties_Triad_Optional 828.4719551843273 ns/iter 773.5603391302462 ns/iter 1.07
Evaluator_Draft4_Properties_Triad_Closed 678.6616833046686 ns/iter 670.740312191895 ns/iter 1.01
Evaluator_Draft4_Properties_Triad_Required 834.4636212082074 ns/iter 788.246165863451 ns/iter 1.06
Evaluator_Draft4_Properties_Closed 68.34690097262536 ns/iter 63.64824694543224 ns/iter 1.07
Evaluator_Draft4_Non_Recursive_Ref 14.559706961100002 ns/iter 13.215773015400748 ns/iter 1.10
Evaluator_Draft4_Pattern_Properties_True 190.23706154968798 ns/iter 171.240700246882 ns/iter 1.11
Evaluator_Draft4_Ref_To_Single_Property 11.21274996455708 ns/iter 9.773434674484875 ns/iter 1.15
Evaluator_Draft4_Additional_Properties_Type 26.393674617742825 ns/iter 24.81802510067989 ns/iter 1.06
Evaluator_Draft4_Nested_Oneof 59.52253814091812 ns/iter 53.94317207734513 ns/iter 1.10
Evaluator_Draft4_Long_Enum 9.955813600722749 ns/iter 8.829722857223002 ns/iter 1.13
Evaluator_Draft4_Type_Object 5.581629820254502 ns/iter 5.20897384503294 ns/iter 1.07
Evaluator_Draft6_Property_Names 120.26702611814024 ns/iter 112.38100985082666 ns/iter 1.07
Evaluator_Draft7_If_Then_Else 27.137781696481753 ns/iter 25.185288176326054 ns/iter 1.08
Evaluator_Draft7_Vercel_1 39896.25469421567 ns/iter 37207.65078712876 ns/iter 1.07
Evaluator_Draft7_Helm_Chart_Lock_1 205.99664211512348 ns/iter 192.76135892650964 ns/iter 1.07
Evaluator_Draft7_Jasmine_1 129.70691623062572 ns/iter 130.80268517453408 ns/iter 0.99
Evaluator_2019_09_Unevaluated_Properties 179.32234636508852 ns/iter 167.74727077081548 ns/iter 1.07
Evaluator_2019_09_OMC_JSON_V2_1 1059.3530717935166 ns/iter 1057.2693366340916 ns/iter 1.00
Evaluator_2020_12_Dynamic_Ref 465.3964277003208 ns/iter 471.2955329782675 ns/iter 0.99
Evaluator_2020_12_Dynamic_Ref_Single 5.36956720343996 ns/iter 37.8075416324003 ns/iter 0.14
Evaluator_2020_12_CQL_1 2871.11760836115 ns/iter 4171.086330651328 ns/iter 0.69

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark (linux/gcc)

Benchmark suite Current: b0dbe56 Previous: bdc63bc Ratio
Evaluator_2020_12_Dynamic_Ref 627.5275922150101 ns/iter 618.9160592946419 ns/iter 1.01
Evaluator_2020_12_Dynamic_Ref_Single 9.782146473384685 ns/iter 47.092155110606065 ns/iter 0.21
Evaluator_2020_12_CQL_1 4149.434831447264 ns/iter 6095.945019752658 ns/iter 0.68
Evaluator_2019_09_Unevaluated_Properties 241.618938536056 ns/iter 232.5243314398982 ns/iter 1.04
Evaluator_2019_09_OMC_JSON_V2_1 1377.2114849487996 ns/iter 1350.4431075257928 ns/iter 1.02
Evaluator_Draft7_If_Then_Else 43.88645311707645 ns/iter 44.060573425633734 ns/iter 1.00
Evaluator_Draft7_Vercel_1 46639.75025237118 ns/iter 45150.32679866517 ns/iter 1.03
Evaluator_Draft7_Helm_Chart_Lock_1 205.89126320559834 ns/iter 198.57594135198394 ns/iter 1.04
Evaluator_Draft7_Jasmine_1 161.42541585037392 ns/iter 161.34273796326212 ns/iter 1.00
Evaluator_Draft6_Property_Names 147.91995358187526 ns/iter 154.16737835090322 ns/iter 0.96
Evaluator_Draft4_Meta_1_No_Callback 239.99500841412433 ns/iter 234.94467654144216 ns/iter 1.02
Evaluator_Draft4_Required_Properties 459.194619325739 ns/iter 440.98467700045285 ns/iter 1.04
Evaluator_Draft4_Many_Optional_Properties_Minimal_Match 28.524293536841583 ns/iter 26.76679763336043 ns/iter 1.07
Evaluator_Draft4_Few_Optional_Properties_Minimal_Match 12.014666790969075 ns/iter 12.314306396590808 ns/iter 0.98
Evaluator_Draft4_Items_Schema 477.0910115537585 ns/iter 497.0381348753979 ns/iter 0.96
Evaluator_Draft4_Nested_Object 4.219551086247019 ns/iter 4.6627226328552585 ns/iter 0.90
Evaluator_Draft4_Properties_Triad_Optional 1124.4470181344295 ns/iter 1061.5286124846978 ns/iter 1.06
Evaluator_Draft4_Properties_Triad_Closed 918.8264994202947 ns/iter 842.0137186882248 ns/iter 1.09
Evaluator_Draft4_Properties_Triad_Required 1121.6008959162086 ns/iter 1045.822052520263 ns/iter 1.07
Evaluator_Draft4_Properties_Closed 73.76912648198808 ns/iter 72.67991310435961 ns/iter 1.01
Evaluator_Draft4_Non_Recursive_Ref 12.622033923178218 ns/iter 12.885326670604195 ns/iter 0.98
Evaluator_Draft4_Pattern_Properties_True 250.9396414852993 ns/iter 240.0550695354049 ns/iter 1.05
Evaluator_Draft4_Ref_To_Single_Property 11.905107204269443 ns/iter 12.191793183045249 ns/iter 0.98
Evaluator_Draft4_Additional_Properties_Type 15.370767242061191 ns/iter 15.624050425246677 ns/iter 0.98
Evaluator_Draft4_Nested_Oneof 108.30037227139721 ns/iter 109.20091179333585 ns/iter 0.99
Evaluator_Draft4_Long_Enum 22.7597397543913 ns/iter 23.275531889513935 ns/iter 0.98
Evaluator_Draft4_Type_Object 9.799310256185219 ns/iter 9.618389219415173 ns/iter 1.02
Compiler_2019_09_OMC_JSON_V2 10478507423.999987 ns/iter 10247358299.000097 ns/iter 1.02
Compiler_Draft6_AdaptiveCard 53174990335.999954 ns/iter 52100338879.999985 ns/iter 1.02

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark (windows/msvc)

Benchmark suite Current: b0dbe56 Previous: a2cb6f5 Ratio
Compiler_Draft6_AdaptiveCard 114712823800.00003 ns/iter 114663102799.99994 ns/iter 1.00
Compiler_2019_09_OMC_JSON_V2 21892865199.99996 ns/iter 21754276800.000072 ns/iter 1.01
Evaluator_Draft4_Meta_1_No_Callback 375.2455814841533 ns/iter 364.8108198576412 ns/iter 1.03
Evaluator_Draft4_Required_Properties 1032.616146153503 ns/iter 1003.5726562499292 ns/iter 1.03
Evaluator_Draft4_Many_Optional_Properties_Minimal_Match 37.00722098213736 ns/iter 37.716620755059125 ns/iter 0.98
Evaluator_Draft4_Few_Optional_Properties_Minimal_Match 21.773287500000293 ns/iter 20.84968755602055 ns/iter 1.04
Evaluator_Draft4_Items_Schema 661.7341071428688 ns/iter 715.7416964284989 ns/iter 0.92
Evaluator_Draft4_Nested_Object 6.208115000000589 ns/iter 5.9046589285713935 ns/iter 1.05
Evaluator_Draft4_Properties_Triad_Optional 1680.9606823922559 ns/iter 1648.0599008527063 ns/iter 1.02
Evaluator_Draft4_Properties_Triad_Closed 1369.5448214286491 ns/iter 1325.602321428424 ns/iter 1.03
Evaluator_Draft4_Properties_Triad_Required 1705.953746012957 ns/iter 1661.479400795124 ns/iter 1.03
Evaluator_Draft4_Properties_Closed 94.30279936148116 ns/iter 91.85313875656446 ns/iter 1.03
Evaluator_Draft4_Non_Recursive_Ref 35.07501803704902 ns/iter 31.941192686580607 ns/iter 1.10
Evaluator_Draft4_Pattern_Properties_True 218.45003124997928 ns/iter 233.63909374999992 ns/iter 0.93
Evaluator_Draft4_Ref_To_Single_Property 21.718562500002037 ns/iter 20.605693749999435 ns/iter 1.05
Evaluator_Draft4_Additional_Properties_Type 65.95432142857152 ns/iter 56.3865299999975 ns/iter 1.17
Evaluator_Draft4_Nested_Oneof 114.53778571428026 ns/iter 106.27243749999238 ns/iter 1.08
Evaluator_Draft4_Long_Enum 22.47699416878272 ns/iter 22.97098437499656 ns/iter 0.98
Evaluator_Draft4_Type_Object 13.039714285714663 ns/iter 12.794564285714824 ns/iter 1.02
Evaluator_Draft6_Property_Names 164.50682798038557 ns/iter 174.7631255421646 ns/iter 0.94
Evaluator_Draft7_If_Then_Else 69.90042410713723 ns/iter 54.64166964285612 ns/iter 1.28
Evaluator_Draft7_Vercel_1 70588.09151785997 ns/iter 73727.77678571854 ns/iter 0.96
Evaluator_Draft7_Helm_Chart_Lock_1 333.75797402467435 ns/iter 313.22717932731075 ns/iter 1.07
Evaluator_Draft7_Jasmine_1 254.48432142858172 ns/iter 222.03296874998557 ns/iter 1.15
Evaluator_2019_09_Unevaluated_Properties 416.8737370115346 ns/iter 406.1155131198858 ns/iter 1.03
Evaluator_2019_09_OMC_JSON_V2_1 1927.690828295308 ns/iter 1928.790099096279 ns/iter 1.00
Evaluator_2020_12_Dynamic_Ref 849.8981473670973 ns/iter 848.4072551752758 ns/iter 1.00
Evaluator_2020_12_Dynamic_Ref_Single 12.718864285716336 ns/iter 73.41513392855603 ns/iter 0.17
Evaluator_2020_12_CQL_1 4827.044064324846 ns/iter 6624.049107141364 ns/iter 0.73

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.