Skip to content

Commit

Permalink
Merge pull request #144 from Plutonomicon/mc/benchmark-diff
Browse files Browse the repository at this point in the history
PR Benchmark Diffing
  • Loading branch information
srid committed Jan 19, 2022
2 parents 15b082a + 5735d70 commit 1920514
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To run benchmarks on a particular commit,
nix run github:Plutonomicon/plutarch/<COMMIT-GOES-HERE>#benchmark
```

Note that you can also view these benchmarks on a per-commit basis by looking at Hercules CI logs. Go to the Hercules CI job run for a given commit, and navigate to the `nixCi.checks.x86_64-linux.benchmark` page in the Attributes table, and then click on the "Log" header to view its output.
Note that you can also view these benchmarks on a per-commit basis by looking at Hercules CI logs. Go to the Hercules CI job run for a given commit, and navigate to the `checks.x86_64-linux.benchmark` page in the Attributes table, and then click on the "Log" header to view its output.

Eventually we will have PR integration for running benchmarks.

Expand Down
3 changes: 3 additions & 0 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if builtins?getFlake
then (builtins.getFlake (toString ./.)).ciNix
else (import ./flake-compat.nix).defaultNix.ciNix
9 changes: 9 additions & 0 deletions flake-compat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
flake-compat = builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};
in
import flake-compat { src = ./.; }
223 changes: 215 additions & 8 deletions flake.lock

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

42 changes: 40 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
inputs.haskell-nix.url = "github:L-as/haskell.nix?ref=master";
inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
inputs.flake-compat-ci.url = "github:hercules-ci/flake-compat-ci";
inputs.hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};

# https://github.com/input-output-hk/plutus/pull/4328
inputs.plutus.url = "github:L-as/plutus?ref=master";
Expand Down Expand Up @@ -41,7 +46,7 @@
inputs.Shrinker.url = "github:Plutonomicon/Shrinker";
inputs.Shrinker.flake = false;

outputs = inputs@{ self, nixpkgs, haskell-nix, plutus, flake-compat-ci, ... }:
outputs = inputs@{ self, nixpkgs, haskell-nix, plutus, flake-compat, flake-compat-ci, hercules-ci-effects, ... }:
let
extraSources = [
{
Expand Down Expand Up @@ -451,9 +456,42 @@
);
devShell = perSystem (system: self.flake.${system}.devShell);

nixCi = flake-compat-ci.lib.recurseIntoFlakeWith {
effects = { src }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
hci-effects = hercules-ci-effects.lib.withPkgs pkgs;
in
{
benchmark-diff = hci-effects.runIf (src.ref == "refs/heads/staging") (
hci-effects.mkEffect {
src = self;
buildInputs = with pkgs; [ git nixFlakes ];
effectScript = ''
git clone https://github.com/Plutonomicon/plutarch.git plutarch
cd plutarch
git checkout $(git merge-base origin/staging ${src.rev})
nix --extra-experimental-features 'nix-command flakes' run .#benchmark > before.csv
git checkout ${src.rev}
nix --extra-experimental-features 'nix-command flakes' run .#benchmark > after.csv
echo
echo
echo "Benchmark diff between $(git merge-base origin/staging ${src.rev}) and ${src.rev}:"
echo
echo
diff before.csv after.csv
'';
}
);
};

ciNix = args@{ src }: flake-compat-ci.lib.recurseIntoFlakeWith {
flake = self;
systems = [ "x86_64-linux" ];
effectsArgs = args;
};
};
}

0 comments on commit 1920514

Please sign in to comment.