difftreelog
ci add benchmarks against other implementations
in: master
5 files changed
nix/benchmarks.mddiffbeforeafterboth--- /dev/null
+++ b/nix/benchmarks.md
@@ -0,0 +1,7 @@
+# Benchmarks
+
+There are multiple implementations of jsonnet implemented in different languages: Rust (this repo), [Go](https://github.com/google/go-jsonnet/), [Scala](https://github.com/databricks/sjsonnet), [C++](https://github.com/google/jsonnet), [Haskell](https://github.com/moleike/haskell-jsonnet).
+
+For simplicity, I will call these implementations by the language of their implementation.
+
+Unfortunately, I haven't managed to measure performance of Haskell implementation, because I wasn't able to build it, and there is no binaries published anywhere, so this implementation is omitted from the following benchmarks
nix/benchmarks.nixdiffbeforeafterbothnix/go-jsonnet.nixdiffbeforeafterboth--- a/nix/go-jsonnet.nix
+++ b/nix/go-jsonnet.nix
@@ -1,4 +1,4 @@
-{ lib, buildGo119Module, fetchFromGitHub }:
+{ lib, buildGo119Module, fetchFromGitHub, makeWrapper }:
buildGo119Module rec {
pname = "go-jsonnet";
@@ -11,11 +11,13 @@
rev = "${version}";
hash = "sha256-J+bGdbYo2Ch3ORYD57yJA4jiPiS8IYASZ6kJHhyaqeU=";
};
+ vendorHash = "sha256-j1fTOUpLx34TgzW94A/BctLrg9XoTtb3cBizhVJoEEI=";
- vendorHash = "sha256-j1fTOUpLx34TgzW94A/BctLrg9XoTtb3cBizhVJoEEI=";
+ buildInputs = [ makeWrapper ];
postInstall = ''
mv $out/bin/jsonnet $out/bin/go-jsonnet
+ wrapProgram $out/bin/go-jsonnet --add-flags "--max-stack 200000"
'';
doCheck = false;
nix/jrsonnet.nixdiffbeforeafterboth--- a/nix/jrsonnet.nix
+++ b/nix/jrsonnet.nix
@@ -1,22 +1,33 @@
-{ lib, fetchFromGitHub, rustPlatform }:
+{ lib, fetchFromGitHub, rustPlatform, runCommand, makeWrapper }:
let
- jsonnet = fetchFromGitHub {
- rev = "v${version}";
- owner = "google";
- repo = "jsonnet";
- hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";
+ filteredSrc = builtins.path {
+ name = "jrsonnet-src-filtered";
+ filter = path: type: !(builtins.baseNameOf path == "flake.nix" || builtins.baseNameOf path == "nix");
+ path = ../.;
};
+
+ # for some reason, filteredSrc hash still depends on nix directory contents
+ # Moving it into a CA store drops leftover references
+ src = runCommand "jrsonnet-src"
+ {
+ __contentAddressed = true;
+ } "cp -r '${filteredSrc}' $out";
in
rustPlatform.buildRustPackage rec {
+ inherit src;
pname = "jrsonnet";
version = "git";
- src = ./..;
+ cargoTestFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
+ cargoBuildFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
+
+ buildInputs = [ makeWrapper ];
- cargoTestFlags = [ "--package=jrsonnet" ];
- cargoBuildFlags = [ "--package=jrsonnet" ];
+ postInstall = ''
+ wrapProgram $out/bin/jrsonnet --add-flags "--max-stack=200000 --os-stack=200000"
+ '';
cargoLock = {
lockFile = ../Cargo.lock;
nix/jsonnet.nixdiffbeforeafterboth--- a/nix/jsonnet.nix
+++ b/nix/jsonnet.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, jekyll, fetchFromGitHub }:
+{ stdenv, lib, jekyll, fetchFromGitHub, makeWrapper }:
stdenv.mkDerivation rec {
pname = "jsonnet";
@@ -15,8 +15,11 @@
"jsonnet"
];
+ buildInputs = [ makeWrapper ];
+
installPhase = ''
mkdir -p $out/bin
cp jsonnet $out/bin/jsonnet
+ wrapProgram $out/bin/jsonnet --add-flags "--max-stack 200000"
'';
}