Haskell tools could loose some weight

With my beginner mind, I’m thinking we could get a good compromise between speed and size if we forbid cross-library inlining. All inlining to be contained inside a library and no code-leaks to other libraries or executables. I’ve looked a bit for it and it seems to me that cabal/ghc doesn’t have that build option.

The big gain of containing inlining inside library borders is we’ll get true shared libraries. And a hackage binary repo, maybe?

(Much) smaller sizes (less inlining), simplified processes (less compilation, more abstract dependencies), but slower speeds… who knows how slow…?

Cross-library inlining is essential for libraries like parsec, vector, and lens, because they define combinators that should optimize when composed together.

Is there any hope that installing bindists becomes simply unpacking them, without any make to run? This seems to be possible for other toolchains (with less history…)

This.
Until cross-compiling to the platforms of low-memory devices works easily, it would be nice if one could reduce the footprint of the toolchain.

I have a number of GHC versions on disk (‘official’ versions, installed by Stack) and I drew a graph of their ‘size on disk’ by release date (below). Something odd seems to have happened with GHC 9.10.1 (I deleted it and reinstalled it, so I am pretty sure it is not a mistake on my part):

EDIT: I’ve added a few more minor versions to the same chart.

EDIT2: The ‘odd thing’ with GHC 9.10.1 was an error in packaging, now fixed: #24800.

One can also observe the slow but inevitable increase here: Grafana

I just rediscovered my issue #5: Images could be smaller · Issues · Glasgow Haskell Compiler / ci-images · GitLab

On that issue, @flip101 mentioned slim, which looks interesting.

A MicroHs package with the compiler and base is about 1M. Installed it might be about 3M. This includes sources.
But you pay the price for that in performance, the generated code is about 10 times slower than code from ghc.
On the other hand, the compiler itself is about 10x faster than ghc. :slightly_smiling_face:

It is and has been for years. As far back as 8.4.4. The ios cross compilers I built back then were just that, unpack and run. Here is a bindist.zip from a recent ghc HEAD checkout. (Credit to @hsyl20).

I’ll use ubuntu as an example here

docker run -it  ubuntu bash

and then inside the container (we’ll need curl, gcc, and unzip):

apt-get update && apt-get install -y unzip curl gcc
cd ~
curl -LO "https://www.dropbox.com/scl/fi/jz2r0skhv41sl869lb15i/bindist.zip?rlkey=skukxobiku83zkp9pkny58hag&st=n5ni6499&dl=1"
unzip bindist.zip

and this leaves us with

./bin/ghc --interactive
GHCi, version 9.13: https://www.haskell.org/ghc/  :? for help
ghci>

Now there are some caveats about making GHC a bit more resilient to system, and in-flight changes. Unzip and run has been possible for years. (Yes, there are some caveats and technicalities where this can fall apart; and it requires some system features which are not necessarily available on every operating system).

This as well as other changes to GHC bindists is something my team and I are exploring and hope to upstream to GHC eventually.

With the recent ghcup version 0.1.50.0, you can now do:

ghcup install ghc --install-targets "install_bin install_lib install_extra update_package_db" 9.12.2

The list of install targets is not stable, so e.g. the above line will fail for GHC 9.6.7. That’s why this is a low-level feature.

Feel free to ask GHC devs to stabilize the bindist Makefile.


Before:

$ du -sh ~/.ghcup/ghc/9.12.2
3.6G	/home/hasufell/.ghcup/ghc/9.12.2

After:

$ du -sh ~/.ghcup/ghc/9.12.2
2.8G	/home/hasufell/.ghcup/ghc/9.12.2

Have you ever looked what is in debian ghc package ? Most of size are *.hi and *.dyn_hi files. Which are needed when you link anything from base and libraries distributed with ghc.

Same as -devel packages for c/c++ libraries etc. Its debian decision to distribute this file in one package. For example fedora and opensuse have this files in separated subpackages for base and libraries … and you can install only what you really need.

see: openSUSE Tumbleweed GHC-9.12.2 or Fedora 42 - GHC 9.12