Skip to content

Modules' contribution to binary size

bloaty is a tool that helps diagnose why binaries are large.

It can break down the size of binaries along several axes, but in particular it allows you to make use of DWARF information to find the relative contributions of source modules to the binary size.

I compiled f5eb0f29 with the release flavour and -g1 and ran the following command to give this output:

❯ nix run nixpkgs#bloaty -- _build/stage1/lib/x86_64-linux-ghc-9.9.20231203/libHSghc-9.9-inplace-ghc9.9.20231203.so -d compileunits -n 50
    FILE SIZE        VM SIZE
 --------------  --------------
  50.4%  84.4Mi  55.6%  61.7Mi    [733 Others]
  11.7%  19.6Mi   0.0%       0    [section .debug_frame]
   5.6%  9.44Mi   6.6%  7.30Mi    compiler/GHC/Hs/Instances.hs
   2.3%  3.86Mi   2.8%  3.13Mi    compiler/GHC/Driver/Session.hs
   2.0%  3.36Mi   2.3%  2.52Mi    compiler/GHC/Builtin/PrimOps.hs
   1.7%  2.87Mi   2.2%  2.47Mi    compiler/GHC/Hs/Dump.hs
   1.3%  2.14Mi   1.2%  1.33Mi    compiler/GHC/Tc/Errors/Types.hs
   1.2%  1.98Mi   1.5%  1.72Mi    compiler/GHC/Tc/Errors/Ppr.hs
   1.2%  1.96Mi   1.2%  1.38Mi    compiler/GHC/Iface/Ext/Ast.hs
   1.0%  1.70Mi   1.2%  1.30Mi    _build/stage1/compiler/build/GHC/Parser.hs
   1.0%  1.60Mi   1.3%  1.47Mi    _build/stage1/compiler/build/GHC/Platform/Constants.hs
   0.9%  1.50Mi   0.9%  1018Ki    compiler/GHC/Parser/Annotation.hs
   0.9%  1.48Mi   0.8%   907Ki    compiler/GHC/Builtin/Names.hs
   0.9%  1.47Mi   1.2%  1.27Mi    compiler/GHC/CmmToAsm/X86/CodeGen.hs
   0.9%  1.46Mi   1.0%  1.11Mi    _build/stage1/compiler/build/GHC/Parser/Lexer.hs
   0.9%  1.44Mi   1.0%  1.07Mi    compiler/GHC/Hs/Expr.hs
   0.8%  1.35Mi   1.2%  1.35Mi    [section .gnu.hash]
   0.7%  1.24Mi   1.1%  1.24Mi    [section .hash]
   0.7%  1.10Mi   0.7%   789Ki    compiler/GHC/Tc/Deriv/Generate.hs
   0.6%  1.03Mi   0.7%   757Ki    compiler/GHC/Iface/Syntax.hs
   0.6%  1.02Mi   0.7%   835Ki    compiler/GHC/Driver/Make.hs
   0.6%   999Ki   0.7%   828Ki    compiler/GHC/Core/Lint.hs
   0.6%   989Ki   0.6%   724Ki    compiler/GHC/Parser/PostProcess.hs
   0.5%   927Ki   0.7%   775Ki    compiler/GHC/Core/Opt/ConstantFold.hs
   0.5%   927Ki   0.6%   629Ki    compiler/GHC/Iface/Ext/Types.hs
   0.5%   920Ki   0.5%   585Ki    compiler/GHC/Types/Basic.hs
   0.5%   899Ki   0.5%   543Ki    compiler/GHC/Builtin/Names/TH.hs
   0.5%   885Ki   0.7%   762Ki    compiler/GHC/StgToJS/Prim.hs
   0.5%   866Ki   0.5%   589Ki    compiler/GHC/Cmm/CLabel.hs
   0.5%   855Ki   0.6%   714Ki    compiler/GHC/Tc/TyCl.hs
   0.5%   847Ki   0.6%   679Ki    compiler/GHC/Iface/Recomp.hs
   0.5%   795Ki   0.6%   629Ki    compiler/GHC/Tc/Gen/HsType.hs
   0.4%   770Ki   0.4%   480Ki    compiler/GHC/Driver/Flags.hs
   0.4%   764Ki   0.6%   630Ki    compiler/GHC/Llvm/Ppr.hs
   0.4%   706Ki   0.4%   498Ki    compiler/GHC/Data/Word64Map/Internal.hs
   0.4%   666Ki   0.5%   532Ki    compiler/GHC/Driver/Main.hs
   0.4%   660Ki   0.5%   533Ki    compiler/GHC/StgToCmm/Prim.hs
   0.4%   659Ki   0.5%   569Ki    compiler/GHC/Parser/Utils.hs
   0.4%   656Ki   0.4%   446Ki    compiler/GHC/Types/Name/Reader.hs
   0.4%   644Ki   0.5%   542Ki    compiler/GHC/Hs/ImpExp.hs
   0.4%   643Ki   0.4%   412Ki    compiler/GHC/StgToJS/Types.hs
   0.4%   640Ki   0.5%   549Ki    compiler/GHC/CmmToLlvm/CodeGen.hs
   0.4%   620Ki   0.4%   446Ki    compiler/GHC/Driver/DynFlags.hs
   0.4%   613Ki   0.5%   521Ki    compiler/GHC/Tc/Module.hs
   0.4%   604Ki   0.4%   493Ki    compiler/GHC/HsToCore/Quote.hs
   0.3%   587Ki   0.4%   438Ki    compiler/GHC/Hs/Decls.hs
   0.3%   584Ki   0.4%   404Ki    compiler/GHC/Llvm/Types.hs
   0.3%   579Ki   0.3%   385Ki    compiler/GHC/Builtin/Types/Prim.hs
   0.3%   579Ki   0.4%   456Ki    compiler/GHC/CmmToAsm/Dwarf/Types.hs
   0.3%   565Ki   0.4%   424Ki    compiler/GHC/Unit/State.hs
   0.3%   564Ki   0.4%   454Ki    compiler/GHC/Tc/Gen/Splice.hs
 100.0%   167Mi 100.0%   110Mi    TOTAL

This gives the top 50 modules by contribution to binary size. I'm not sure if this gives devs any new information, but I thought I'd share just in case.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information