difftreelog
doc: fix spoiler
in: master
2 files changed
docs/benchmarks.mddiffbeforeafterboth--- a/docs/benchmarks.md
+++ b/docs/benchmarks.md
@@ -169,8 +169,6 @@
```
-</details>
-
Rust (alternative):
```
@@ -201,7 +199,6 @@
```
</details>
-
## Real world
nix/benchmarks.nixdiffbeforeafterboth1{2 lib,3 runCommand,4 jsonnet-bundler,5 cacert,6 stdenv,7 fetchFromGitHub,8 go-jsonnet,9 sjsonnet,10 jsonnet,11 rsjsonnet,12 hyperfine,13 quick ? false,14 jrsonnetVariants,15}:16with lib; let17 jsonnetBench = fetchFromGitHub {18 rev = "v0.19.1";19 owner = "google";20 repo = "jsonnet";21 hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";22 };23 goJsonnetBench =24 (fetchFromGitHub {25 owner = "google";26 repo = "go-jsonnet";27 rev = "v0.19.1";28 hash = "sha256-FgQYnas0qkIedRAA8ApZXLzEylg6PS6+8zzl7j+yOeI=";29 })30 + "/builtin-benchmarks";31 graalvmBench = fetchFromGitHub {32 owner = "oracle";33 repo = "graal";34 rev = "bc305df3fe587960f7635f0185571500e5988475";35 hash = "sha256-4EKB1b2o4/qtYQ+nqbbs621OJrtjApsAWEBcw5EjrYc=";36 };37 kubePrometheusBench = let38 src = fetchFromGitHub {39 owner = "prometheus-operator";40 repo = "kube-prometheus";41 rev = "d3889807798d1697ea0691f10caf1b6a1997a8bd";42 hash = "sha256-TeYWHzoZAmDp2PzT7EH8XRUcvb3tR8Qfxel7o2QBvIM=";43 };44 in45 runCommand "kube-prometheus-vendor"46 {47 outputHash = "sha256-AGc0dHlD/Ld7I5b1+gOotzJkYrn+bB1VjISdD5NITtw=";48 outputHashMode = "recursive";49 buildInputs = [cacert];50 }51 ''52 mkdir -p $out53 cp -r ${src}/* $out/54 cd $out55 mkdir vendor56 ${jsonnet-bundler}/bin/jb install57 '';5859 # Removes outsiders from the output60 # Useful when comparing performance of different jrsonnet releases61 skipSlow =62 if quick63 then "slow benchmark, but only quick requested"64 else "";65in66 stdenv.mkDerivation {67 name = "benchmarks";68 __impure = true;69 unpackPhase = "true";7071 buildInputs = [72 sjsonnet73 jsonnet74 rsjsonnet75 go-jsonnet7677 hyperfine78 ];7980 installPhase = let81 mkBench = {82 name,83 path,84 omitSource ? false,85 pathIsGenerator ? false,86 skipRustAlternative ? "",87 skipScala ? "",88 skipCpp ? "",89 skipGo ? "",90 vendor ? "",91 }: ''92 echo >> $out93 echo "### ${name}" >> $out94 echo >> $out95 ${optionalString(skipRustAlternative!="")''96 echo "> Note: No results for Rust (alternative), ${skipRustAlternative}" >> $out97 echo >> $out98 ''}99 ${optionalString(skipGo!="")''100 echo "> Note: No results for Go, ${skipGo}" >> $out101 echo >> $out102 ''}103 ${optionalString(skipScala!="")''104 echo "> Note: No results for Scala, ${skipScala}" >> $out105 echo >> $out106 ''}107 ${optionalString(skipCpp!="")''108 echo "> Note: No results for C++, ${skipCpp}" >> $out109 echo >> $out110 ''}111 ${optionalString(!quick&&!omitSource)''112 echo "<details>" >> $out113 echo "<summary>Source</summary>" >> $out114 echo >> $out115 echo "\`\`\`jsonnet" >> $out116 ${optionalStringpathIsGenerator"echo \"// Generator source\" >> $out"}117 cat ${path} >> $out118 echo >> $out119 echo "\`\`\`" >> $out120 echo "</details>" >> $out121 echo >> $out122 ''}123 path=${path}124 ${optionalStringpathIsGenerator''125 go-jsonnet $path > generated.jsonnet126 path=generated.jsonnet127 ''}128 hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \129 ${concatStringsSep" "(forEachjrsonnetVariants(130variant"\"${variant.drv}/bin/jrsonnet $path${optionalString(vendor!="")" -J${vendor}"}\" -n \"Rust${131 ifvariant.name!=""132then" (${variant.name})"133else""134 }\""135))} \136 ${optionalString(skipRustAlternative=="")"\"rsjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Rust (alternative, rsjsonnet)\""} \137 ${optionalString(skipGo=="")"\"go-jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Go\""} \138 ${optionalString(skipScala=="")"\"sjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Scala\""} \139 ${optionalString(skipCpp=="")"\"jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"C++\""}140 cat result.md >> $out141 '';142 in ''143 set -oux144145 temp=$(mktemp -d)146 cd $temp147148 touch $out149 ${optionalString(!quick)''150 cat ${} >> $out151 echo >> $out152153 echo "<details>" >> $out154 echo "<summary>Tested versions</summary>" >> $out155 echo >> $out156 echo Go: $(go-jsonnet --version) >> $out157 echo >> $out158 echo "\`\`\`" >> $out159 go-jsonnet --help >> $out160 echo "\`\`\`" >> $out161 echo >> $out162 echo C++: $(jsonnet --version) >> $out163 echo >> $out164 echo "\`\`\`" >> $out165 jsonnet --help >> $out166 echo "\`\`\`" >> $out167 echo >> $out168 echo Scala: >> $out169 echo >> $out170 echo "\`\`\`" >> $out171 sjsonnet 2>> $out || true172 echo "\`\`\`" >> $out173 echo >> $out174 echo "</details>" >> $out175 echo >> $out176 echo "Rust (alternative):" >> $out177 echo >> $out178 echo "\`\`\`" >> $out179 rsjsonnet --help 2>> $out || true180 echo "\`\`\`" >> $out181 echo >> $out182 echo "</details>" >> $out183 echo >> $out184185 echo >> $out186 ''}187 echo "## Real world" >> $out188 ${mkBench{189name="Graalvm CI";190path="${graalvmBench}/ci.jsonnet";191skipCpp="takes longer than a hour";192skipGo=skipSlow;193skipScala=skipSlow;194}}195 ${mkBench{196name="Kube-prometheus manifests";197vendor="${kubePrometheusBench}/vendor";198path="${kubePrometheusBench}/example.jsonnet";199skipCpp=skipSlow;200skipGo=skipSlow;201skipScala=skipSlow;202}}203204 echo >> $out205 echo "## Benchmarks from C++ jsonnet (/perf_tests)" >> $out206 ${mkBench{207name="Large string join";208path="${jsonnetBench}/perf_tests/large_string_join.jsonnet";209skipScala=skipSlow;210}}211 ${mkBench{212name="Large string template";213omitSource=true;214path="${jsonnetBench}/perf_tests/large_string_template.jsonnet";215skipGo="fails with os stack size exhausion";216skipCpp=skipSlow;217skipScala=skipSlow;218}}219 ${mkBench{220name="Realistic 1";221path="${jsonnetBench}/perf_tests/realistic1.jsonnet";222skipGo=skipSlow;223skipCpp=skipSlow;224skipScala=skipSlow;225}}226 ${mkBench{227name="Realistic 2";228path="${jsonnetBench}/perf_tests/realistic2.jsonnet";229skipGo=skipSlow;230skipCpp=skipSlow;231skipScala=skipSlow;232}}233234 echo >> $out235 echo "## Benchmarks from C++ jsonnet (/benchmarks)" >> $out236 ${mkBench{237name="Tail call";238path="${jsonnetBench}/benchmarks/bench.01.jsonnet";239skipScala=skipSlow;240}}241 ${mkBench{242name="Inheritance recursion";243path="${jsonnetBench}/benchmarks/bench.02.jsonnet";244skipCpp=skipSlow;245skipGo=skipSlow;246}}247 ${mkBench{248name="Simple recursive call";249path="${jsonnetBench}/benchmarks/bench.03.jsonnet";250skipScala=skipSlow;251skipGo=skipSlow;252}}253 ${mkBench{254name="Foldl string concat";255path="${jsonnetBench}/benchmarks/bench.04.jsonnet";256skipCpp=skipSlow;257skipScala=skipSlow;258}}259 ${mkBench{260name="Array sorts";261path="${jsonnetBench}/benchmarks/bench.06.jsonnet";262skipCpp=skipSlow;263# std.assertEqual(reverse(std.range(1, 1000)), sort(std.range(1, 1000), keyF=function(x) -x))264skipScala="sjsonnet doesn't support keyF in std.sort: https://github.com/databricks/sjsonnet/issues/204";265}}266 ${mkBench{267name="Lazy array";268path="${jsonnetBench}/benchmarks/bench.07.jsonnet";269skipGo=skipSlow;270skipScala=skipSlow;271}}272 ${mkBench{273name="Inheritance function recursion";274path="${jsonnetBench}/benchmarks/bench.08.jsonnet";275skipCpp=skipSlow;276skipScala=skipSlow;277}}278 ${mkBench{279name="String strips";280path="${jsonnetBench}/benchmarks/bench.09.jsonnet";281skipCpp=skipSlow;282skipScala=skipSlow;283}}284 ${mkBench{285name="Big object";286path="${jsonnetBench}/benchmarks/gen_big_object.jsonnet";287pathIsGenerator=true;288skipScala=skipSlow;289}}290291 echo >> $out292 echo "## Benchmarks from Go jsonnet (builtins)" >> $out293 ${mkBench{294name="std.base64";295path="${goJsonnetBench}/base64.jsonnet";296skipRustAlternative=skipSlow;297skipCpp=skipSlow;298skipScala=skipSlow;299}}300 ${mkBench{301name="std.base64Decode";302path="${goJsonnetBench}/base64Decode.jsonnet";303skipRustAlternative=skipSlow;304skipCpp=skipSlow;305skipScala=skipSlow;306}}307 ${mkBench{308name="std.base64DecodeBytes";309path="${goJsonnetBench}/base64DecodeBytes.jsonnet";310skipRustAlternative=skipSlow;311skipCpp=skipSlow;312skipGo=skipSlow;313skipScala=skipSlow;314}}315 ${mkBench{316name="std.base64 (byte array)";317path="${goJsonnetBench}/base64_byte_array.jsonnet";318skipRustAlternative=skipSlow;319skipCpp=skipSlow;320skipGo=skipSlow;321skipScala=skipSlow;322}}323 ${mkBench{324name="std.foldl";325path="${goJsonnetBench}/foldl.jsonnet";326skipScala=skipSlow;327}}328 ${mkBench{329name="std.manifestJsonEx";330path="${goJsonnetBench}/manifestJsonEx.jsonnet";331skipScala=skipSlow;332skipCpp=skipSlow;333}}334 ${mkBench{335name="std.manifestTomlEx";336path="${goJsonnetBench}/manifestTomlEx.jsonnet";337skipScala="std.manifestTomlEx is not implemented: https://github.com/databricks/sjsonnet/issues/111";338skipCpp=skipSlow;339}}340 ${mkBench{341name="std.parseInt";342path="${goJsonnetBench}/parseInt.jsonnet";343skipScala=skipSlow;344skipCpp=skipSlow;345}}346 ${mkBench{347name="std.reverse";348path="${goJsonnetBench}/reverse.jsonnet";349skipCpp=skipSlow;350skipGo=skipSlow;351}}352 ${mkBench{353name="std.substr";354path="${goJsonnetBench}/substr.jsonnet";355skipScala=skipSlow;356}}357 ${mkBench{358name="Comparsion for array";359path="${goJsonnetBench}/comparison.jsonnet";360skipScala="array comparsion is not implemented";361skipCpp=skipSlow;362}}363 ${mkBench{364name="Comparsion for primitives";365path="${goJsonnetBench}/comparison2.jsonnet";366skipRustAlternative=skipSlow;367skipCpp="can't run: uses up to 192GB of RAM";368skipGo=skipSlow;369skipScala=skipSlow;370}}371 '';372 }1{2 lib,3 runCommand,4 jsonnet-bundler,5 cacert,6 stdenv,7 fetchFromGitHub,8 go-jsonnet,9 sjsonnet,10 jsonnet,11 rsjsonnet,12 hyperfine,13 quick ? false,14 jrsonnetVariants,15}:16with lib; let17 jsonnetBench = fetchFromGitHub {18 rev = "v0.19.1";19 owner = "google";20 repo = "jsonnet";21 hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";22 };23 goJsonnetBench =24 (fetchFromGitHub {25 owner = "google";26 repo = "go-jsonnet";27 rev = "v0.19.1";28 hash = "sha256-FgQYnas0qkIedRAA8ApZXLzEylg6PS6+8zzl7j+yOeI=";29 })30 + "/builtin-benchmarks";31 graalvmBench = fetchFromGitHub {32 owner = "oracle";33 repo = "graal";34 rev = "bc305df3fe587960f7635f0185571500e5988475";35 hash = "sha256-4EKB1b2o4/qtYQ+nqbbs621OJrtjApsAWEBcw5EjrYc=";36 };37 kubePrometheusBench = let38 src = fetchFromGitHub {39 owner = "prometheus-operator";40 repo = "kube-prometheus";41 rev = "d3889807798d1697ea0691f10caf1b6a1997a8bd";42 hash = "sha256-TeYWHzoZAmDp2PzT7EH8XRUcvb3tR8Qfxel7o2QBvIM=";43 };44 in45 runCommand "kube-prometheus-vendor"46 {47 outputHash = "sha256-AGc0dHlD/Ld7I5b1+gOotzJkYrn+bB1VjISdD5NITtw=";48 outputHashMode = "recursive";49 buildInputs = [cacert];50 }51 ''52 mkdir -p $out53 cp -r ${src}/* $out/54 cd $out55 mkdir vendor56 ${jsonnet-bundler}/bin/jb install57 '';5859 # Removes outsiders from the output60 # Useful when comparing performance of different jrsonnet releases61 skipSlow =62 if quick63 then "slow benchmark, but only quick requested"64 else "";65in66 stdenv.mkDerivation {67 name = "benchmarks";68 __impure = true;69 unpackPhase = "true";7071 buildInputs = [72 sjsonnet73 jsonnet74 rsjsonnet75 go-jsonnet7677 hyperfine78 ];7980 installPhase = let81 mkBench = {82 name,83 path,84 omitSource ? false,85 pathIsGenerator ? false,86 skipRustAlternative ? "",87 skipScala ? "",88 skipCpp ? "",89 skipGo ? "",90 vendor ? "",91 }: ''92 echo >> $out93 echo "### ${name}" >> $out94 echo >> $out95 ${optionalString(skipRustAlternative!="")''96 echo "> Note: No results for Rust (alternative), ${skipRustAlternative}" >> $out97 echo >> $out98 ''}99 ${optionalString(skipGo!="")''100 echo "> Note: No results for Go, ${skipGo}" >> $out101 echo >> $out102 ''}103 ${optionalString(skipScala!="")''104 echo "> Note: No results for Scala, ${skipScala}" >> $out105 echo >> $out106 ''}107 ${optionalString(skipCpp!="")''108 echo "> Note: No results for C++, ${skipCpp}" >> $out109 echo >> $out110 ''}111 ${optionalString(!quick&&!omitSource)''112 echo "<details>" >> $out113 echo "<summary>Source</summary>" >> $out114 echo >> $out115 echo "\`\`\`jsonnet" >> $out116 ${optionalStringpathIsGenerator"echo \"// Generator source\" >> $out"}117 cat ${path} >> $out118 echo >> $out119 echo "\`\`\`" >> $out120 echo "</details>" >> $out121 echo >> $out122 ''}123 path=${path}124 ${optionalStringpathIsGenerator''125 go-jsonnet $path > generated.jsonnet126 path=generated.jsonnet127 ''}128 hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \129 ${concatStringsSep" "(forEachjrsonnetVariants(130variant"\"${variant.drv}/bin/jrsonnet $path${optionalString(vendor!="")" -J${vendor}"}\" -n \"Rust${131 ifvariant.name!=""132then" (${variant.name})"133else""134 }\""135))} \136 ${optionalString(skipRustAlternative=="")"\"rsjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Rust (alternative, rsjsonnet)\""} \137 ${optionalString(skipGo=="")"\"go-jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Go\""} \138 ${optionalString(skipScala=="")"\"sjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Scala\""} \139 ${optionalString(skipCpp=="")"\"jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"C++\""}140 cat result.md >> $out141 '';142 in ''143 set -oux144145 temp=$(mktemp -d)146 cd $temp147148 touch $out149 ${optionalString(!quick)''150 cat ${} >> $out151 echo >> $out152153 echo "<details>" >> $out154 echo "<summary>Tested versions</summary>" >> $out155 echo >> $out156 echo Go: $(go-jsonnet --version) >> $out157 echo >> $out158 echo "\`\`\`" >> $out159 go-jsonnet --help >> $out160 echo "\`\`\`" >> $out161 echo >> $out162 echo C++: $(jsonnet --version) >> $out163 echo >> $out164 echo "\`\`\`" >> $out165 jsonnet --help >> $out166 echo "\`\`\`" >> $out167 echo >> $out168 echo Scala: >> $out169 echo >> $out170 echo "\`\`\`" >> $out171 sjsonnet 2>> $out || true172 echo "\`\`\`" >> $out173 echo >> $out174 echo "Rust (alternative):" >> $out175 echo >> $out176 echo "\`\`\`" >> $out177 rsjsonnet --help 2>> $out || true178 echo "\`\`\`" >> $out179 echo >> $out180 echo "</details>" >> $out181 echo >> $out182183 echo >> $out184 ''}185 echo "## Real world" >> $out186 ${mkBench{187name="Graalvm CI";188path="${graalvmBench}/ci.jsonnet";189skipCpp="takes longer than a hour";190skipGo=skipSlow;191skipScala=skipSlow;192}}193 ${mkBench{194name="Kube-prometheus manifests";195vendor="${kubePrometheusBench}/vendor";196path="${kubePrometheusBench}/example.jsonnet";197skipCpp=skipSlow;198skipGo=skipSlow;199skipScala=skipSlow;200}}201202 echo >> $out203 echo "## Benchmarks from C++ jsonnet (/perf_tests)" >> $out204 ${mkBench{205name="Large string join";206path="${jsonnetBench}/perf_tests/large_string_join.jsonnet";207skipScala=skipSlow;208}}209 ${mkBench{210name="Large string template";211omitSource=true;212path="${jsonnetBench}/perf_tests/large_string_template.jsonnet";213skipGo="fails with os stack size exhausion";214skipCpp=skipSlow;215skipScala=skipSlow;216}}217 ${mkBench{218name="Realistic 1";219path="${jsonnetBench}/perf_tests/realistic1.jsonnet";220skipGo=skipSlow;221skipCpp=skipSlow;222skipScala=skipSlow;223}}224 ${mkBench{225name="Realistic 2";226path="${jsonnetBench}/perf_tests/realistic2.jsonnet";227skipGo=skipSlow;228skipCpp=skipSlow;229skipScala=skipSlow;230}}231232 echo >> $out233 echo "## Benchmarks from C++ jsonnet (/benchmarks)" >> $out234 ${mkBench{235name="Tail call";236path="${jsonnetBench}/benchmarks/bench.01.jsonnet";237skipScala=skipSlow;238}}239 ${mkBench{240name="Inheritance recursion";241path="${jsonnetBench}/benchmarks/bench.02.jsonnet";242skipCpp=skipSlow;243skipGo=skipSlow;244}}245 ${mkBench{246name="Simple recursive call";247path="${jsonnetBench}/benchmarks/bench.03.jsonnet";248skipScala=skipSlow;249skipGo=skipSlow;250}}251 ${mkBench{252name="Foldl string concat";253path="${jsonnetBench}/benchmarks/bench.04.jsonnet";254skipCpp=skipSlow;255skipScala=skipSlow;256}}257 ${mkBench{258name="Array sorts";259path="${jsonnetBench}/benchmarks/bench.06.jsonnet";260skipCpp=skipSlow;261# std.assertEqual(reverse(std.range(1, 1000)), sort(std.range(1, 1000), keyF=function(x) -x))262skipScala="sjsonnet doesn't support keyF in std.sort: https://github.com/databricks/sjsonnet/issues/204";263}}264 ${mkBench{265name="Lazy array";266path="${jsonnetBench}/benchmarks/bench.07.jsonnet";267skipGo=skipSlow;268skipScala=skipSlow;269}}270 ${mkBench{271name="Inheritance function recursion";272path="${jsonnetBench}/benchmarks/bench.08.jsonnet";273skipCpp=skipSlow;274skipScala=skipSlow;275}}276 ${mkBench{277name="String strips";278path="${jsonnetBench}/benchmarks/bench.09.jsonnet";279skipCpp=skipSlow;280skipScala=skipSlow;281}}282 ${mkBench{283name="Big object";284path="${jsonnetBench}/benchmarks/gen_big_object.jsonnet";285pathIsGenerator=true;286skipScala=skipSlow;287}}288289 echo >> $out290 echo "## Benchmarks from Go jsonnet (builtins)" >> $out291 ${mkBench{292name="std.base64";293path="${goJsonnetBench}/base64.jsonnet";294skipRustAlternative=skipSlow;295skipCpp=skipSlow;296skipScala=skipSlow;297}}298 ${mkBench{299name="std.base64Decode";300path="${goJsonnetBench}/base64Decode.jsonnet";301skipRustAlternative=skipSlow;302skipCpp=skipSlow;303skipScala=skipSlow;304}}305 ${mkBench{306name="std.base64DecodeBytes";307path="${goJsonnetBench}/base64DecodeBytes.jsonnet";308skipRustAlternative=skipSlow;309skipCpp=skipSlow;310skipGo=skipSlow;311skipScala=skipSlow;312}}313 ${mkBench{314name="std.base64 (byte array)";315path="${goJsonnetBench}/base64_byte_array.jsonnet";316skipRustAlternative=skipSlow;317skipCpp=skipSlow;318skipGo=skipSlow;319skipScala=skipSlow;320}}321 ${mkBench{322name="std.foldl";323path="${goJsonnetBench}/foldl.jsonnet";324skipScala=skipSlow;325}}326 ${mkBench{327name="std.manifestJsonEx";328path="${goJsonnetBench}/manifestJsonEx.jsonnet";329skipScala=skipSlow;330skipCpp=skipSlow;331}}332 ${mkBench{333name="std.manifestTomlEx";334path="${goJsonnetBench}/manifestTomlEx.jsonnet";335skipScala="std.manifestTomlEx is not implemented: https://github.com/databricks/sjsonnet/issues/111";336skipCpp=skipSlow;337}}338 ${mkBench{339name="std.parseInt";340path="${goJsonnetBench}/parseInt.jsonnet";341skipScala=skipSlow;342skipCpp=skipSlow;343}}344 ${mkBench{345name="std.reverse";346path="${goJsonnetBench}/reverse.jsonnet";347skipCpp=skipSlow;348skipGo=skipSlow;349}}350 ${mkBench{351name="std.substr";352path="${goJsonnetBench}/substr.jsonnet";353skipScala=skipSlow;354}}355 ${mkBench{356name="Comparsion for array";357path="${goJsonnetBench}/comparison.jsonnet";358skipScala="array comparsion is not implemented";359skipCpp=skipSlow;360}}361 ${mkBench{362name="Comparsion for primitives";363path="${goJsonnetBench}/comparison2.jsonnet";364skipRustAlternative=skipSlow;365skipCpp="can't run: uses up to 192GB of RAM";366skipGo=skipSlow;367skipScala=skipSlow;368}}369 '';370 }