Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Elm closure #15800

Closed
domenkozar opened this issue May 29, 2016 · 17 comments
Closed

Reduce Elm closure #15800

domenkozar opened this issue May 29, 2016 · 17 comments

Comments

@domenkozar
Copy link
Member

It's around 1400MB atm: http://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.elmPackages.elm-compiler.x86_64-linux#tabs-charts

@vcunat
Copy link
Member

vcunat commented May 29, 2016

I suspect most of it is Haskell #4504.

@domenkozar
Copy link
Member Author

I tried setting enableSharedExecutables = false; on each elm package, but that didn't yield much result.

@vcunat
Copy link
Member

vcunat commented May 30, 2016

I guess it needs to compile haskell during runtime.

@domenkozar
Copy link
Member Author

Don't think so, npm has binary compiled elm in 80M:

$ du -sh node_modules/elm/Elm-Platform/0.17.0/.cabal-sandbox/bin/
78M     node_modules/elm/Elm-Platform/0.17.0/.cabal-sandbox/bin/

All statically compiled

@vcunat
Copy link
Member

vcunat commented May 31, 2016

OK, sounds convincing. If it doesn't assume ghc on $PATH or something.

@peti
Copy link
Member

peti commented Jun 14, 2016

@domenkozar, enableSharedExecutables = false; helps only for packages that have no library components. Once a package provides a library, it invariable depends on the transitive closure of its dependencies -- which includes GHC. If the libraries aren't neeed by end-users, then it might make sense to remove them to mitigate this problem.

@domenkozar
Copy link
Member Author

@peti indeed.

I can get it down from 1.7G to 50MB using following patch:

diff --git a/pkgs/development/compilers/elm/packages/elm-compiler.nix b/pkgs/development/compilers/elm/packages/elm-compiler.nix
index f6a92b6..d1c0171 100644
--- a/pkgs/development/compilers/elm/packages/elm-compiler.nix
+++ b/pkgs/development/compilers/elm/packages/elm-compiler.nix
@@ -13,8 +13,10 @@ mkDerivation {
     sha256 = "17y0jlii81mnjywknblcv1nfja51slmwrhz9x8w144b0sblcj0if";
     rev = "e44deafaf9cbf3749484070f267f03a368711adb";
   };
-  isLibrary = true;
+  isLibrary = false;
   isExecutable = true;
+  enableSharedLibraries = false;
+  enableSharedExecutables = false;
   libraryHaskellDepends = [
     aeson aeson-pretty_0_7_2 ansi-terminal ansi-wl-pprint base binary
     bytestring containers directory edit-distance filepath indents

But elm-make and others can't be compiled then since elm-compiler library doesn't exist. Does that mean we have to build elm-compiler twice?

@peti
Copy link
Member

peti commented Aug 19, 2016

If the elm library is required to compile elm programs, then it seems like elm compilation implies Haskell compilation, which in turn requires GHC and friends. I don't see what we could do about that, really (except for some multiple outputs magic).

@domenkozar
Copy link
Member Author

@peti it's not required to compile Elm programs, but to compile all of Elm executables (elm-make, elm, etc).

@peti
Copy link
Member

peti commented Sep 10, 2016

Hmm, in that case you would probably need a full version of elm for compiling the toolchain, and the toolchain itself would then be linked statically so that nothing refers to GHC. I am sorry for being vague, but I know nothing about elm and its internal structure, so I have really no clue what I am talking about here. 😄

@domenkozar
Copy link
Member Author

There is now upstream discussion to join all projects under Elm: https://groups.google.com/forum/#!topic/elm-dev/-qGgYTKyAS8

Until this is decided I don't think it's worth pursuing reducing closure size, but let's keep the issue open as a reminder to myself to check this in a few months.

@domenkozar
Copy link
Member Author

0.19 is going to be great for us and allow really simple change to achieve this: https://groups.google.com/forum/#!topic/elm-dev/qdu3NqOqGrY

@domenkozar
Copy link
Member Author

I'm going to close this, Elm 0.19 ships a single executable so it will be easy to use static haskell dependencies for compiling it with small closure-size.

@domenkozar
Copy link
Member Author

Elm 0.19 should have been released a long time ago.

Once #32082 is done, we can really just do enableSharedExecutables = false; as I intended a year and a half ago.

@domenkozar
Copy link
Member Author

Fixed by f73e524 once #32629 is going to be merged.

@arianvp
Copy link
Member

arianvp commented Aug 24, 2018

Elm 0.19 has just been released!

@domenkozar
Copy link
Member Author

See #45448

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants