snack icon indicating copy to clipboard operation
snack copied to clipboard

`snack build`ing a big project takes 12m.

Open YuMingLiao opened this issue 5 years ago • 2 comments

--Here is a big project.
$ time snack build                                                                           
/nix/store/lw1fskf7gr6fqi4z5y1v39lnxmzf4gvk-build.json                                                                              
                                                                                                                                    
real    12m16.200s
user    12m3.206s
sys     0m1.394s

$ cat package.nix
let
  lib =
    { src = ./src;
      dependencies = [ "aeson" "base" "bytestring" "case-insensitive" "classy-prelude" "classy-prelude-conduit" "classy-prelude-yesod" "conduit" "containers" "data-default" "directory" "fast-logger" "file-embed" "foreign-store" "hjsmin" "http-client-tls" "http-conduit" "monad-control" "monad-logger" "safe" "shakespeare" "template-haskell" "text" "time" "unordered-containers" "vector" "wai" "wai-extra" "wai-logger" "warp" "warp-tls" "yaml" "yesod" "yesod-core" "yesod-form" "yesod-static" "project-m36" "yesod-auth" "rio" "project-m36-typed" "basic-sop" "th-utilities" "yesod-crud" "yesod-auth-fb" "yesod-fb" "fb" "yesod-auth-oauth2" ];                         
      extensions = [ "OverloadedStrings" "TemplateHaskell"];
    };
in
  { main = "main";
    src = ./app;
    packages = [ lib ];
    dependencies = [ "aeson" "base" "bytestring" "case-insensitive" "classy-prelude" "classy-prelude-conduit" "classy-prelude-yesod"
"conduit" "containers" "data-default" "directory" "fast-logger" "file-embed" "foreign-store" "hjsmin" "http-client-tls" "http-conduit" "monad-control" "monad-logger" "safe" "shakespeare" "template-haskell" "text" "time" "unordered-containers" "vector" "wai" "wai-extra" "wai-logger" "warp" "warp-tls" "yaml" "yesod" "yesod-core" "yesod-form" "yesod-static" "project-m36" "yesod-auth" "rio" "project-m36-typed" "basic-sop" ];
    extensions = [ "OverloadedStrings" "TemplateHaskell"];
    extra-directories = (modName: [ ./. ]);
}

--Here is a small project.
$ time snack build
/nix/store/cc05z3rgb87r9ah39dfakkrvahzw3dlb-build.json

real    0m9.668s
user    0m8.463s
sys     0m0.805s

$cat package.nix
let
  lib =
    { src = ./src;
      dependencies = [ "base" "file-embed" "text" "yaml" "yesod" "yesod-core" "yesod-form" "yesod-static" "classy-prelude" "classy-prelude-yesod"]; 
      extensions = [ "OverloadedStrings" "TemplateHaskell"];
#      extra-directories =
#       (modName: [./config]) ;
    };
in
  { main = "main";
    src = ./app;
    packages = [ lib ];
    dependencies = [ "base" "file-embed" "text" "yaml" "yesod" "yesod-core" "yesod-form" "yesod-static" "classy-prelude" "classy-prelude-yesod"]; 
    extra-directories =
       (modName: [./.]) ;
  }

47 packages (several local ones) vs 10 packages.

Is it a normal time?

YuMingLiao avatar Oct 29 '19 10:10 YuMingLiao

It's not "normal" but at the moment it's (unfortunately) kind of expected. There are some performance issues. See these tickets:

  • https://github.com/nmattia/snack/issues/79
  • https://github.com/nmattia/snack/issues/143

I know @zimbatm and @NinjaTrappeur have looked into ways of benchmarking and speeding up evaluation, maybe they have some tips?

nmattia avatar Oct 29 '19 10:10 nmattia

I'm not yet ready to answer this. I'll write a proper blog post + documentation when the callgraph profiler will be ready.

That said, (according to git blame) @zimbatm and @grahamc already delivered a timing-based flamegraph profiler. Some instruction about how to use it there: https://github.com/NixOS/nix/commit/ee9c988a1b2e3c511b8613e698a0f9632ab1538f

picnoir avatar Oct 29 '19 11:10 picnoir