From 536df303d3d9b6aa24678ba210cc73abb6c25c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claes=20Wallin=20=28=E9=9F=8B=E5=98=89=E8=AA=A0=29?= Date: Tue, 14 Aug 2018 19:03:17 +0800 Subject: [PATCH] Problem: We have no measurements of how slow testing is Solution: Add 'time -p' to the fractalide-tests* commands. Result: pkgs$ nix-build -A fractalide-tests 2>/dev/null | xargs nix-store --read-log | tail -n 3 real 99.86 user 216.53 sys 155.04 $ nix-build -A fractalide-tests-flat 2>/dev/null | xargs nix-store --read-log | tail -n 3 real 16.67 user 48.75 sys 10.58 Each time a tested file requires a dependency, racket has to chase through 200 directories for it. This is made worse by the fact that we start racket once for each file we find. Without modifying 'raco test' itself, we could perhaps make our own wrapper around the test runner to keep everything in one racket process. Flattening fractalide is probably not an option. It takes so much longer to build, and the derivations for the dependencies cannot be reused. It would negate any speed advantage for the tests. The real improvement would probably be to solve fractalide/racket2nix#158 : Build separate derivations for all packages, then build a racket environment that links them all in one folder. --- pkgs/default.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgs/default.nix b/pkgs/default.nix index 6ce69cc9..1f9dc398 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -60,13 +60,22 @@ pkgs { }); fractalide-tests = self.runCommand "fractalide-tests" { - buildInputs = [ fractalide-tests-pkg.env ]; + buildInputs = [ fractalide-tests-pkg.env self.parallel self.time ]; } '' - racket -l- raco test ${fractalide-tests-pkg.env}/share/racket/pkgs/*/modules/rkt/rkt-fbp/agents + # If we do raco test the discovery process will try to mkdir $HOME. + # If we allow raco test to run on anything in agents/gui it will fail because + # requiring gui fails on headless. + + find ${fractalide-tests-pkg.env}/share/racket/pkgs/*/modules/rkt/rkt-fbp/agents \ + '(' -name gui -prune ')' -o '(' -name '*.rkt' -print ')' | + time -p parallel -n 1 -j ''${NIX_BUILD_CORES:-1} -I {} \ + 'racket -l- raco test {} |& grep -v -e "warning: tool .* registered twice" -e "@[(]test-responsible"; exit ''${PIPESTATUS[0]}' | + tee $out + exit ''${PIPESTATUS[1]} ''; fractalide-tests-flat = fractalide-tests.overrideAttrs (oldAttrs: { - buildInputs = [ (fractalide.override { flat = true; }) ]; + buildInputs = [ (fractalide.override { flat = true; }).env self.parallel self.time ]; }); }) ];