difftreelog
ci default jrsonnet variant
in: master
2 files changed
flake.nixdiffbeforeafterboth--- a/flake.nix
+++ b/flake.nix
@@ -50,14 +50,14 @@
benchmarks = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
jrsonnetVariants = [
- { drv = jrsonnet; name = "current"; }
+ { drv = jrsonnet; name = ""; }
];
};
benchmarks-quick = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
quick = true;
jrsonnetVariants = [
- { drv = jrsonnet; name = "current"; }
+ { drv = jrsonnet; name = ""; }
];
};
benchmarks-against-release = pkgs.callPackage ./nix/benchmarks.nix {
nix/benchmarks.nixdiffbeforeafterboth1{ lib2, runCommand3, jsonnet-bundler4, cacert5, stdenv6, fetchFromGitHub7, go-jsonnet8, sjsonnet9, jsonnet10, hyperfine11, quick ? false12, jrsonnetVariants13}:1415with lib;1617let18 jsonnetBench = fetchFromGitHub {19 rev = "v0.19.1";20 owner = "google";21 repo = "jsonnet";22 hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";23 };24 goJsonnetBench = (fetchFromGitHub {25 owner = "google";26 repo = "go-jsonnet";27 rev = "v0.19.1";28 hash = "sha256-FgQYnas0qkIedRAA8ApZXLzEylg6PS6+8zzl7j+yOeI=";29 }) + "/builtin-benchmarks";30 graalvmBench = fetchFromGitHub {31 owner = "oracle";32 repo = "graal";33 rev = "bc305df3fe587960f7635f0185571500e5988475";34 hash = "sha256-4EKB1b2o4/qtYQ+nqbbs621OJrtjApsAWEBcw5EjrYc=";35 };36 kubePrometheusBench =37 let38 src = fetchFromGitHub {39 owner = "prometheus-operator";40 repo = "kube-prometheus";41 rev = "6a570e3154eac26e32da61d784fbe626da4804df";42 hash = "sha256-s6BK8KQiSjql2w6R+8m5pvPPAcKW+SKjQwqxZHjimFw=";43 };44 in45 runCommand "kube-prometheus-vendor"46 {47 outputHash = "sha256-R60RI/7FQPOHisnzANb34m9WPj5D9FeMVoGOjB19zl8=";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 = if quick then "slow benchmark, but only quick requested" else "";62in63stdenv.mkDerivation {64 name = "benchmarks";65 __impure = true;66 unpackPhase = "true";6768 buildInputs = [69 go-jsonnet70 sjsonnet71 jsonnet7273 hyperfine74 ];7576 installPhase =77 let78 mkBench = { name, path, omitSource ? false, pathIsGenerator ? false, skipScala ? "", skipCpp ? "", skipGo ? "", vendor ? "" }: ''79 set -oux8081 echo >> $out82 echo "### ${name}" >> $out83 echo >> $out84 ${optionalString(skipGo!="")''85 echo "> Note: No results for Go, ${skipGo}" >> $out86 echo >> $out87 ''}88 ${optionalString(skipScala!="")''89 echo "> Note: No results for Scala, ${skipScala}" >> $out90 echo >> $out91 ''}92 ${optionalString(skipCpp!="")''93 echo "> Note: No results for C++, ${skipCpp}" >> $out94 echo >> $out95 ''}96 ${optionalString(!quick&&!omitSource)''97 echo "<details>" >> $out98 echo "<summary>Source</summary>" >> $out99 echo >> $out100 echo "\`\`\`jsonnet" >> $out101 ${optionalStringpathIsGenerator"echo \"// Generator source\" >> $out"}102 cat ${path} >> $out103 echo >> $out104 echo "\`\`\`" >> $out105 echo "</details>" >> $out106 echo >> $out107 ''}108 path=${path}109 ${optionalStringpathIsGenerator''110 go-jsonnet $path > generated.jsonnet111 path=generated.jsonnet112 ''}113 hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \114 ${concatStringsSep" "(forEachjrsonnetVariants(variant115"\"${variant.drv}/bin/jrsonnet $path ${optionalString(vendor!="")"-J${vendor}"}\" -n \"Rust (${variant.name})\""116))} \117 ${optionalString(skipGo=="")"\"go-jsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"Go\""} \118 ${optionalString(skipScala=="")"\"sjsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"Scala\""} \119 ${optionalString(skipCpp=="")"\"jsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"C++\""}120 cat result.md >> $out121 '';122 in123 ''124 touch $out125 ${optionalString(!quick)''126 cat ${} >> $out127 echo >> $out128129 echo "<details>" >> $out130 echo "<summary>Tested versions</summary>" >> $out131 echo >> $out132 echo Go: $(go-jsonnet --version) >> $out133 echo >> $out134 echo "\`\`\`" >> $out135 go-jsonnet --help >> $out136 echo "\`\`\`" >> $out137 echo >> $out138 echo C++: $(jsonnet --version) >> $out139 echo >> $out140 echo "\`\`\`" >> $out141 jsonnet --help >> $out142 echo "\`\`\`" >> $out143 echo >> $out144 echo Scala: >> $out145 echo >> $out146 echo "\`\`\`" >> $out147 sjsonnet 2>> $out || true148 echo "\`\`\`" >> $out149 echo >> $out150 echo "</details>" >> $out151 echo >> $out152153 echo >> $out154 ''}155 echo "## Real world" >> $out156 ${mkBench{name="Graalvm CI";path="${graalvmBench}/ci.jsonnet";skipCpp="takes longer than a hour";skipGo=skipSlow;skipScala=skipSlow;}}157 ${mkBench{name="Kube-prometheus manifests";vendor="${kubePrometheusBench}/vendor";path="${kubePrometheusBench}/example.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}158159 echo >> $out160 echo "## Benchmarks from C++ jsonnet (/perf_tests)" >> $out161 ${mkBench{name="Large string join";path="${jsonnetBench}/perf_tests/large_string_join.jsonnet";skipScala=skipSlow;}}162 ${mkBench{name="Large string template";omitSource=true;path="${jsonnetBench}/perf_tests/large_string_template.jsonnet";skipGo="fails with os stack size exhausion";skipCpp=skipSlow;skipScala=skipSlow;}}163 ${mkBench{name="Realistic 1";path="${jsonnetBench}/perf_tests/realistic1.jsonnet";skipGo=skipSlow;skipCpp=skipSlow;skipScala=skipSlow;}}164 ${mkBench{name="Realistic 2";path="${jsonnetBench}/perf_tests/realistic2.jsonnet";skipGo=skipSlow;skipCpp=skipSlow;skipScala=skipSlow;}}165166 echo >> $out167 echo "## Benchmarks from C++ jsonnet (/benchmarks)" >> $out168 ${mkBench{name="Tail call";path="${jsonnetBench}/benchmarks/bench.01.jsonnet";skipScala=skipSlow;}}169 ${mkBench{name="Inheritance recursion";path="${jsonnetBench}/benchmarks/bench.02.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;}}170 ${mkBench{name="Simple recursive call";path="${jsonnetBench}/benchmarks/bench.03.jsonnet";skipScala=skipSlow;skipGo=skipSlow;}}171 ${mkBench{name="Foldl string concat";path="${jsonnetBench}/benchmarks/bench.04.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}172 ${mkBench{name="Array sorts";path="${jsonnetBench}/benchmarks/bench.06.jsonnet";skipScala="std.reverse is not implemented";skipCpp=skipSlow;}}173 ${mkBench{name="Lazy array";path="${jsonnetBench}/benchmarks/bench.07.jsonnet";skipGo=skipSlow;skipScala=skipSlow;}}174 ${mkBench{name="Inheritance function recursion";path="${jsonnetBench}/benchmarks/bench.08.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}175 ${mkBench{name="String strips";path="${jsonnetBench}/benchmarks/bench.09.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}176 ${mkBench{name="Big object";path="${jsonnetBench}/benchmarks/gen_big_object.jsonnet";pathIsGenerator=true;skipScala=skipSlow;}}177178 echo >> $out179 echo "## Benchmarks from Go jsonnet (builtins)" >> $out180 ${mkBench{name="std.base64";path="${goJsonnetBench}/base64.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}181 ${mkBench{name="std.base64Decode";path="${goJsonnetBench}/base64Decode.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}182 ${mkBench{name="std.base64DecodeBytes";path="${goJsonnetBench}/base64DecodeBytes.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}183 ${mkBench{name="std.base64 (byte array)";path="${goJsonnetBench}/base64_byte_array.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}184 ${mkBench{name="std.foldl";path="${goJsonnetBench}/foldl.jsonnet";skipScala=skipSlow;}}185 ${mkBench{name="std.manifestJsonEx";path="${goJsonnetBench}/manifestJsonEx.jsonnet";skipScala=skipSlow;skipCpp=skipSlow;}}186 ${mkBench{name="std.manifestTomlEx";path="${goJsonnetBench}/manifestTomlEx.jsonnet";skipScala="std.manifestTomlEx is not implemented";skipCpp=skipSlow;}}187 ${mkBench{name="std.parseInt";path="${goJsonnetBench}/parseInt.jsonnet";skipScala=skipSlow;skipCpp=skipSlow;}}188 ${mkBench{name="std.reverse";path="${goJsonnetBench}/reverse.jsonnet";skipScala="std.reverse is not implemented";skipCpp=skipSlow;skipGo=skipSlow;}}189 ${mkBench{name="std.substr";path="${goJsonnetBench}/substr.jsonnet";skipScala=skipSlow;}}190 ${mkBench{name="Comparsion for array";path="${goJsonnetBench}/comparison.jsonnet";skipScala="array comparsion is not implemented";skipCpp=skipSlow;}}191 ${mkBench{name="Comparsion for primitives";path="${goJsonnetBench}/comparison2.jsonnet";skipCpp="can't run: uses up to 192GB of RAM";skipGo=skipSlow;skipScala=skipSlow;}}192 '';193}1{ lib2, runCommand3, jsonnet-bundler4, cacert5, stdenv6, fetchFromGitHub7, go-jsonnet8, sjsonnet9, jsonnet10, hyperfine11, quick ? false12, jrsonnetVariants13}:1415with lib;1617let18 jsonnetBench = fetchFromGitHub {19 rev = "v0.19.1";20 owner = "google";21 repo = "jsonnet";22 hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";23 };24 goJsonnetBench = (fetchFromGitHub {25 owner = "google";26 repo = "go-jsonnet";27 rev = "v0.19.1";28 hash = "sha256-FgQYnas0qkIedRAA8ApZXLzEylg6PS6+8zzl7j+yOeI=";29 }) + "/builtin-benchmarks";30 graalvmBench = fetchFromGitHub {31 owner = "oracle";32 repo = "graal";33 rev = "bc305df3fe587960f7635f0185571500e5988475";34 hash = "sha256-4EKB1b2o4/qtYQ+nqbbs621OJrtjApsAWEBcw5EjrYc=";35 };36 kubePrometheusBench =37 let38 src = fetchFromGitHub {39 owner = "prometheus-operator";40 repo = "kube-prometheus";41 rev = "6a570e3154eac26e32da61d784fbe626da4804df";42 hash = "sha256-s6BK8KQiSjql2w6R+8m5pvPPAcKW+SKjQwqxZHjimFw=";43 };44 in45 runCommand "kube-prometheus-vendor"46 {47 outputHash = "sha256-R60RI/7FQPOHisnzANb34m9WPj5D9FeMVoGOjB19zl8=";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 = if quick then "slow benchmark, but only quick requested" else "";62in63stdenv.mkDerivation {64 name = "benchmarks";65 __impure = true;66 unpackPhase = "true";6768 buildInputs = [69 go-jsonnet70 sjsonnet71 jsonnet7273 hyperfine74 ];7576 installPhase =77 let78 mkBench = { name, path, omitSource ? false, pathIsGenerator ? false, skipScala ? "", skipCpp ? "", skipGo ? "", vendor ? "" }: ''79 set -oux8081 echo >> $out82 echo "### ${name}" >> $out83 echo >> $out84 ${optionalString(skipGo!="")''85 echo "> Note: No results for Go, ${skipGo}" >> $out86 echo >> $out87 ''}88 ${optionalString(skipScala!="")''89 echo "> Note: No results for Scala, ${skipScala}" >> $out90 echo >> $out91 ''}92 ${optionalString(skipCpp!="")''93 echo "> Note: No results for C++, ${skipCpp}" >> $out94 echo >> $out95 ''}96 ${optionalString(!quick&&!omitSource)''97 echo "<details>" >> $out98 echo "<summary>Source</summary>" >> $out99 echo >> $out100 echo "\`\`\`jsonnet" >> $out101 ${optionalStringpathIsGenerator"echo \"// Generator source\" >> $out"}102 cat ${path} >> $out103 echo >> $out104 echo "\`\`\`" >> $out105 echo "</details>" >> $out106 echo >> $out107 ''}108 path=${path}109 ${optionalStringpathIsGenerator''110 go-jsonnet $path > generated.jsonnet111 path=generated.jsonnet112 ''}113 hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \114 ${concatStringsSep" "(forEachjrsonnetVariants(variant115"\"${variant.drv}/bin/jrsonnet $path ${optionalString(vendor!="")"-J${vendor}"}\" -n \"Rust${ifvariant.name!=""then" (${variant.name})"else""}\""116))} \117 ${optionalString(skipGo=="")"\"go-jsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"Go\""} \118 ${optionalString(skipScala=="")"\"sjsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"Scala\""} \119 ${optionalString(skipCpp=="")"\"jsonnet $path ${optionalString(vendor!="")"-J ${vendor}"}\" -n \"C++\""}120 cat result.md >> $out121 '';122 in123 ''124 touch $out125 ${optionalString(!quick)''126 cat ${} >> $out127 echo >> $out128129 echo "<details>" >> $out130 echo "<summary>Tested versions</summary>" >> $out131 echo >> $out132 echo Go: $(go-jsonnet --version) >> $out133 echo >> $out134 echo "\`\`\`" >> $out135 go-jsonnet --help >> $out136 echo "\`\`\`" >> $out137 echo >> $out138 echo C++: $(jsonnet --version) >> $out139 echo >> $out140 echo "\`\`\`" >> $out141 jsonnet --help >> $out142 echo "\`\`\`" >> $out143 echo >> $out144 echo Scala: >> $out145 echo >> $out146 echo "\`\`\`" >> $out147 sjsonnet 2>> $out || true148 echo "\`\`\`" >> $out149 echo >> $out150 echo "</details>" >> $out151 echo >> $out152153 echo >> $out154 ''}155 echo "## Real world" >> $out156 ${mkBench{name="Graalvm CI";path="${graalvmBench}/ci.jsonnet";skipCpp="takes longer than a hour";skipGo=skipSlow;skipScala=skipSlow;}}157 ${mkBench{name="Kube-prometheus manifests";vendor="${kubePrometheusBench}/vendor";path="${kubePrometheusBench}/example.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}158159 echo >> $out160 echo "## Benchmarks from C++ jsonnet (/perf_tests)" >> $out161 ${mkBench{name="Large string join";path="${jsonnetBench}/perf_tests/large_string_join.jsonnet";skipScala=skipSlow;}}162 ${mkBench{name="Large string template";omitSource=true;path="${jsonnetBench}/perf_tests/large_string_template.jsonnet";skipGo="fails with os stack size exhausion";skipCpp=skipSlow;skipScala=skipSlow;}}163 ${mkBench{name="Realistic 1";path="${jsonnetBench}/perf_tests/realistic1.jsonnet";skipGo=skipSlow;skipCpp=skipSlow;skipScala=skipSlow;}}164 ${mkBench{name="Realistic 2";path="${jsonnetBench}/perf_tests/realistic2.jsonnet";skipGo=skipSlow;skipCpp=skipSlow;skipScala=skipSlow;}}165166 echo >> $out167 echo "## Benchmarks from C++ jsonnet (/benchmarks)" >> $out168 ${mkBench{name="Tail call";path="${jsonnetBench}/benchmarks/bench.01.jsonnet";skipScala=skipSlow;}}169 ${mkBench{name="Inheritance recursion";path="${jsonnetBench}/benchmarks/bench.02.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;}}170 ${mkBench{name="Simple recursive call";path="${jsonnetBench}/benchmarks/bench.03.jsonnet";skipScala=skipSlow;skipGo=skipSlow;}}171 ${mkBench{name="Foldl string concat";path="${jsonnetBench}/benchmarks/bench.04.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}172 ${mkBench{name="Array sorts";path="${jsonnetBench}/benchmarks/bench.06.jsonnet";skipScala="std.reverse is not implemented";skipCpp=skipSlow;}}173 ${mkBench{name="Lazy array";path="${jsonnetBench}/benchmarks/bench.07.jsonnet";skipGo=skipSlow;skipScala=skipSlow;}}174 ${mkBench{name="Inheritance function recursion";path="${jsonnetBench}/benchmarks/bench.08.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}175 ${mkBench{name="String strips";path="${jsonnetBench}/benchmarks/bench.09.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}176 ${mkBench{name="Big object";path="${jsonnetBench}/benchmarks/gen_big_object.jsonnet";pathIsGenerator=true;skipScala=skipSlow;}}177178 echo >> $out179 echo "## Benchmarks from Go jsonnet (builtins)" >> $out180 ${mkBench{name="std.base64";path="${goJsonnetBench}/base64.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}181 ${mkBench{name="std.base64Decode";path="${goJsonnetBench}/base64Decode.jsonnet";skipCpp=skipSlow;skipScala=skipSlow;}}182 ${mkBench{name="std.base64DecodeBytes";path="${goJsonnetBench}/base64DecodeBytes.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}183 ${mkBench{name="std.base64 (byte array)";path="${goJsonnetBench}/base64_byte_array.jsonnet";skipCpp=skipSlow;skipGo=skipSlow;skipScala=skipSlow;}}184 ${mkBench{name="std.foldl";path="${goJsonnetBench}/foldl.jsonnet";skipScala=skipSlow;}}185 ${mkBench{name="std.manifestJsonEx";path="${goJsonnetBench}/manifestJsonEx.jsonnet";skipScala=skipSlow;skipCpp=skipSlow;}}186 ${mkBench{name="std.manifestTomlEx";path="${goJsonnetBench}/manifestTomlEx.jsonnet";skipScala="std.manifestTomlEx is not implemented";skipCpp=skipSlow;}}187 ${mkBench{name="std.parseInt";path="${goJsonnetBench}/parseInt.jsonnet";skipScala=skipSlow;skipCpp=skipSlow;}}188 ${mkBench{name="std.reverse";path="${goJsonnetBench}/reverse.jsonnet";skipScala="std.reverse is not implemented";skipCpp=skipSlow;skipGo=skipSlow;}}189 ${mkBench{name="std.substr";path="${goJsonnetBench}/substr.jsonnet";skipScala=skipSlow;}}190 ${mkBench{name="Comparsion for array";path="${goJsonnetBench}/comparison.jsonnet";skipScala="array comparsion is not implemented";skipCpp=skipSlow;}}191 ${mkBench{name="Comparsion for primitives";path="${goJsonnetBench}/comparison2.jsonnet";skipCpp="can't run: uses up to 192GB of RAM";skipGo=skipSlow;skipScala=skipSlow;}}192 '';193}