Instructions for profiling; improve default.nix (#704)

pull/700/head
Sam Uwe Alws 3 years ago committed by GitHub
parent 58b4c933f1
commit e2d6c81818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 15
      README.md
  3. 14
      default.nix

1
.gitignore vendored

@ -21,3 +21,4 @@ cabal.project.local
crytic-export/ crytic-export/
echidna.cabal echidna.cabal
*.swp *.swp
profiles/

@ -298,3 +298,18 @@ All these can be solved, from a few seconds to one or two minutes on a laptop co
- [echidna-parade: A Tool for Diverse Multicore Smart Contract Fuzzing](https://agroce.github.io/issta21.pdf), Alex Groce, Gustavo Grieco - ISSTA '21 - [echidna-parade: A Tool for Diverse Multicore Smart Contract Fuzzing](https://agroce.github.io/issta21.pdf), Alex Groce, Gustavo Grieco - ISSTA '21
If you are using Echidna on an academic work, consider applying to the [Crytic $10k Research Prize](https://blog.trailofbits.com/2019/11/13/announcing-the-crytic-10k-research-prize/). If you are using Echidna on an academic work, consider applying to the [Crytic $10k Research Prize](https://blog.trailofbits.com/2019/11/13/announcing-the-crytic-10k-research-prize/).
## Debugging Performance Problems
The best way to deal with an Echidna performance issue is to run `echidna-test` with profiling on.
This creates a text file, `echidna-test.prof`, which shows which functions take up the most CPU and memory usage.
To build a version of `echidna-test` that supports profiling, either Stack or Nix should be used.
With Stack, adding the flag `--profile` will make the build support profiling.
With Nix, running `nix-build --arg profiling true` will make the build support profiling.
To run with profiling on, add the flags `+RTS -p` to your original `echidna-test` command.
Performance issues in the past have been because of functions getting called repeatedly when they could be memoized,
and memory leaks related to Haskell's lazy evaluation;
checking for these would be a good place to start.

@ -2,7 +2,9 @@
name = "nixpkgs-unstable-2021-10-15"; name = "nixpkgs-unstable-2021-10-15";
url = "https://github.com/nixos/nixpkgs/archive/ee084c02040e864eeeb4cf4f8538d92f7c675671.tar.gz"; url = "https://github.com/nixos/nixpkgs/archive/ee084c02040e864eeeb4cf4f8538d92f7c675671.tar.gz";
sha256 = "sha256:1x8amcixdaw3ryyia32pb706vzhvn5whq9n8jin0qcha5qnm1fnh"; sha256 = "sha256:1x8amcixdaw3ryyia32pb706vzhvn5whq9n8jin0qcha5qnm1fnh";
}) {} }) {},
profiling ? false,
tests ? true
}: }:
let let
@ -32,6 +34,8 @@ let
v = "1.7.2"; v = "1.7.2";
testInputs = [ slither-analyzer solc ];
f = { mkDerivation, aeson, ansi-terminal, base, base16-bytestring, binary f = { mkDerivation, aeson, ansi-terminal, base, base16-bytestring, binary
, brick, bytestring, cborg, containers, data-dword, data-has, deepseq , brick, bytestring, cborg, containers, data-dword, data-has, deepseq
, directory, exceptions, filepath, hashable, hevm, hpack, lens, lens-aeson , directory, exceptions, filepath, hashable, hevm, hpack, lens, lens-aeson
@ -58,26 +62,28 @@ let
executableHaskellDepends = libraryHaskellDepends; executableHaskellDepends = libraryHaskellDepends;
testHaskellDepends = [ tasty tasty-hunit tasty-quickcheck ]; testHaskellDepends = [ tasty tasty-hunit tasty-quickcheck ];
libraryToolDepends = [ hpack ]; libraryToolDepends = [ hpack ];
testToolDepends = [ slither-analyzer solc ]; testToolDepends = testInputs;
configureFlags = if profiling then [ "--enable-profiling" "--enable-library-profiling" ] else [];
preConfigure = '' preConfigure = ''
hpack hpack
# re-enable dynamic build for Linux # re-enable dynamic build for Linux
sed -i -e 's/os(linux)/false/' echidna.cabal sed -i -e 's/os(linux)/false/' echidna.cabal
''; '';
shellHook = "hpack";
license = pkgs.lib.licenses.agpl3; license = pkgs.lib.licenses.agpl3;
doHaddock = false; doHaddock = false;
doCheck = true; doCheck = tests;
}; };
echidna = pkgs.haskellPackages.callPackage f { }; echidna = pkgs.haskellPackages.callPackage f { };
echidnaShell = pkgs.haskellPackages.shellFor { echidnaShell = pkgs.haskellPackages.shellFor {
packages = p: [ echidna ]; packages = p: [ echidna ];
shellHook = "hpack";
buildInputs = with pkgs.haskellPackages; [ buildInputs = with pkgs.haskellPackages; [
hlint hlint
cabal-install cabal-install
haskell-language-server haskell-language-server
]; ];
nativeBuildInputs = if tests then [] else testInputs;
}; };
in in
if pkgs.lib.inNixShell if pkgs.lib.inNixShell

Loading…
Cancel
Save