
#14928: TH eats 50 GB memory when creating ADT with multiple constructors -------------------------------------+------------------------------------- Reporter: YitzGale | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Template Haskell | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): While I don't doubt that we could (and should!) do a better job of compiling code like this, I would suggest that regular structures like this should really be encoded as a data structure, not code as is done here. Not only does compiling all of these large cases produce a great deal of work for the compiler but it's also inefficient. For instance, the Core produced by the `snoyberg-master` essentially implements an linear search over languages, doing a string comparison for every language for which localizations are available: {{{#!hs case ds_doaz of { MsgTestLocalizationMessage001 -> case == @ I18N.Lang Data.Text.$fEqText lang_a53E (Data.Text.pack (GHC.CString.unpackCString# "da"#)) of { False -> case == @ I18N.Lang Data.Text.$fEqText lang_a53E (Data.Text.pack (GHC.CString.unpackCString# "da- DK"#)) of { False -> ... True -> Data.Text.pack (GHC.CString.unpackCString# "This is test localization message number 1 in da-DK."#) }; True -> Data.Text.pack (GHC.CString.unpackCString# "This is test localization message number 1 in da."#) }; }}} Surely this would be better implemented as a hash-map or some other structure with sublinear lookup. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14928#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler