1/3 of heap allocation when compiling Cabal is due to `TyConApp` in generic types
In one sample I took when compiling Cabal
there were 3665735 TyConApp constructors. Here are the top 100:
Address | Total | TyCon |
---|---|---|
0x4207307f68 | 425555 | False\DEL\NUL\NUL |
0x421d3b19a8 | 425127 | PrefixI\NUL |
0x420ade0238 | 425120 | MetaCons |
0x422e3eacb8 | 419525 | M1\195\230\SO\DEL\NUL\NUL |
0x420d853d80 | 419155 | U1/\NULB\NUL\NUL\NUL |
0x420d89ae30 | 407845 | C\SI4\230\SO\DEL\NUL\NUL |
0x421d375b18 | 406836 | :+:\253\SO\DEL\NUL\NUL |
0x4203714f78 | 60933 | []\NUL\NUL\NUL\NUL\NUL\NUL |
0x7f0efc6dcba0 | 38828 | String\NUL\NUL |
0x7f0efc6d8978 | 20581 | Symbol\NUL\NUL |
0x420ade0a38 | 20574 | MetaSel\NUL |
0x420ade7220 | 20351 | NoSourceUnpackedness\SO\DEL\NUL\NUL |
0x4201860a50 | 19457 | FilePath |
0x420ade7e78 | 19166 | DecidedLazy\232\SO\DEL\NUL\NUL |
0x420ade7710 | 19166 | NoSourceStrictness1\NULB\NUL\NUL\NUL |
0x7f0efc6d8198 | 18811 | []\NUL\NUL\NUL\NUL\NUL\NUL |
0x421d364dd8 | 17172 | C1\NUL\NUL\NUL\NUL\NUL\NUL |
0x7f0efc6da378 | 15799 | BoolB\NUL\NUL\NUL |
0x420d8a1088 | 15341 | Rs=\NULB\NUL\NUL\NUL |
0x420d89f2a8 | 14663 | S\NAK\221\233\SO\DEL\NUL\NUL |
0x4225e2ce70 | 13816 | Flag\SO\DEL\NUL\NUL |
0x420d89f980 | 13765 | K1\195\230\SO\DEL\NUL\NUL |
0x420804f2a0 | 12274 | (,)\NUL\NUL\NUL\NUL\NUL |
0x4202a08ed8 | 11534 | JustB\NUL\NUL\NUL |
0x7f0efc6d9470 | 11414 | Char\SO\DEL\NUL\NUL |
0x42073f0c40 | 11117 | ()\EOT\NULB\NUL\NUL\NUL |
0x42037149b0 | 10029 | Maybe\NUL\NUL\NUL |
0x420d89a2c8 | 9215 | :*:\NULB\NUL\NUL\NUL |
0x4202a08000 | 7683 | Nothing\NUL |
0x420f14ce20 | 7334 | LiftedRep\145&1\NULB\NUL\NUL\NUL |
0x420d89eaa0 | 7271 | Rec0B\NUL\NUL\NUL |
0x7f0efc70b510 | 6651 | Addr#\DEL\NUL\NUL |
0x4208066170 | 6087 | ModuleName\180\249\SO\DEL\NUL\NUL |
0x420d89d530 | 5876 | S1\NUL\NUL\NUL\NUL\NUL\NUL |
0x4208074538 | 5595 | BuildInfo\136(\NULB\NUL\NUL\NUL |
0x7f0efc6d96e8 | 5340 | Int\NUL\NUL\NUL\NUL\NUL |
0x7f0efc70f728 | 5092 | RealWorldk\168\248\SO\DEL\NUL\NUL |
0x427587c628 | 4862 | LicenseId\164\180\249\SO\DEL\NUL\NUL |
0x7f0efc70e000 | 4744 | State#\NUL\NUL |
0x4208063c30 | 4691 | Version\NUL |
0x420d60c870 | 4455 | Builder\NUL |
0x420f194e00 | 4395 | ByteString(\NULB\NUL\NUL\NUL |
0x7f0efc70aac0 | 4254 | Int#B\NUL\NUL\NUL |
0x7f0efc70b828 | 4003 | ByteArray#Z\NULB\NUL\NUL\NUL |
0x420b159d00 | 3891 | (#,#)\NUL\NUL\NUL |
0x42759d6e10 | 3842 | Num\232\SO\DEL\NUL\NUL |
0x420806c000 | 3840 | PerCompilerFlavor\132\180\249\SO\DEL\NUL\NUL |
0x42759fce68 | 3788 | Data\SO\DEL\NUL\NUL |
0x42759d1eb8 | 3691 | Pr\r\NULB\NUL\NUL\NUL |
0x427530a5c8 | 3355 | Bits b |
0x4208067490 | 3295 | Extension\DEL9\NULB\NUL\NUL\NUL |
0x42759ef280 | 3179 | Prec\NUL\NUL\NUL\NUL |
0x42759ec1e8 | 3083 | ReadPrec |
0x420d857158 | 3007 | Ord\NUL\NUL\NUL\NUL\NUL |
0x420f167df0 | 2910 | Structure\164\180\249\SO\DEL\NUL\NUL |
0x420c0b1610 | 2870 | One\NULB\NUL\NUL\NUL |
0x420f182cc8 | 2822 | Constr\NUL\NUL |
0x420b157030 | 2776 | Identity |
0x420183fe58 | 2637 | Functor\NUL |
0x420805fa68 | 2636 | ShortText5\240\SOH\NUL\NUL\NUL\NUL |
0x420804fbd8 | 2472 | Dependency1\NULB\NUL\NUL\NUL |
0x420805f000 | 2390 | UnqualComponentName\NUL\NUL\NUL\NUL\NUL |
0x4208066af8 | 2304 | Language |
0x7f0efc6db498 | 2224 | Any\NULB\NUL\NUL\NUL |
0x7f0efc6d8578 | 2202 | RuntimeRep-\NULB\NUL\NUL\NUL |
0x423552aaf0 | 2149 | Verbosity\199U\NULB\NUL\NUL\NUL |
0x420f156a28 | 2038 | IO\195\230\SO\DEL\NUL\NUL |
0x4208056d88 | 2018 | Set\NULB\NUL\NUL\NUL |
0x420805f520 | 1999 | VersionRangef\NUL\NUL\NUL |
0x422e3e4860 | 1985 | Binary\NUL\NUL |
0x42256ddb28 | 1943 | PathTemplate\SO\DEL\NUL\NUL |
0x42758b1c00 | 1937 | Library\NUL |
0x420184a000 | 1909 | CabalSpecVersion |
0x420f1852b8 | 1861 | TyCon\NUL\NUL\NUL |
0x420f169af0 | 1854 | TrName\NUL\NUL |
0x42012f88a0 | 1800 | []\NUL\NUL\NUL\NUL\NUL\NUL |
0x42012f8848 | 1800 | TupleRep |
0x42755ddcd8 | 1780 | Map\230\SO\DEL\NUL\NUL |
0x420806a1f0 | 1759 | KnownExtensionle |
0x420184b3f0 | 1628 | Monad\NUL\NUL\NUL |
0x420f184a38 | 1568 | KindRep\NUL |
0x423582bd28 | 1558 | ListB\NUL\NUL\NUL |
0x4274ee6c00 | 1550 | ConIndex |
0x425bd3c558 | 1512 | ParseError\199\nB\NUL\NUL\NUL |
0x4208065f88 | 1502 | SymbolicPath\SO\DEL\NUL\NUL |
0x4208054f10 | 1486 | LibraryName\NULi\NUL\NUL\NUL |
0x4228dccc58 | 1427 | NubListR |
0x42758a8f40 | 1416 | CompilerFlavor\NUL\NUL |
0x42758cf460 | 1410 | CondTree |
0x420ade8c38 | 1408 | SourceStrict\NUL\NUL\NUL\NUL |
0x7f0efc70afe8 | 1375 | Word#\NUL\NUL\NUL |
0x42758bea68 | 1361 | ForeignLib\SOH\NULB\NUL\NUL\NUL |
0x42758c55f8 | 1336 | PackageDescription(\NULB\NUL\NUL\NUL |
0x42758b0318 | 1322 | ConfVar\NUL |
0x423452f018 | 1296 | Pretext\NUL |
0x4201856688 | 1295 | Applicative\NULB\NUL\NUL\NUL |
0x42758beb28 | 1270 | Executable\NUL\NUL\NUL\NUL\NUL\NUL |
0x420183c5e0 | 1259 | ShowB\NUL\NUL\NUL |
0x420d631740 | 1197 | Decoder\NUL |
0x42080505c0 | 1194 | Mixin\DEL\NUL\NUL |
The top 4 bands, of each over 400 000 contribute 2.4 million out of the 3.6 million total. When you look at a heap profile the TyConApp and lists contained within TyConApp are dominant. Reducing these numbers would go a long way to reducing compiler residency.