Building mime-string-0.5 from Hackage takes 5 minutes and uses more than 5 GB of memory


I have developed a little project where I depend on mime-string-0.5 from Hackage. When I try compiling it on a new machine, building mime-string takes an amount of resources that puzzles me:

It takes takes 5 minutes of using 100% CPU, and GHC peaks at using more than 5 GB of memory:

$ cabal v1-update
Config file path source is default config file.
Config file /home/adsj/.cabal/config not found.
Writing default configuration to /home/adsj/.cabal/config
Downloading the latest package list from
$ time cabal v1-install mime-string
Resolving dependencies...
Downloading  base64-string-0.2
Downloaded   base64-string-0.2
Starting     base64-string-0.2
Building     base64-string-0.2
Completed    base64-string-0.2
Downloading  mime-string-0.5
Downloaded   mime-string-0.5
Starting     mime-string-0.5
Building     mime-string-0.5
Completed    mime-string-0.5

real	5m18.180s
user	5m13.453s
sys	0m5.547s
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

This on a new laptop (i7-9750H) running Debian unstable.

The library itself is not enormous, SLOCcount says:

SLOC	Directory	SLOC-by-Language (Sorted)
1484    mime-string-0.5 haskell=1484

Does anyone have some hints on how to start figuring out what is gong on?


Downloading the .tar.gz of the package, unpacking it and running cabal v1-build in it, reveals that it is the files src/Codec/MIME/String/Headers.hs and especially src/Codec/MIME/String/Date.hs that all the time, CPU and memory seems to be spent on:

~/mime-string-0.5$ time cabal v1-build
Resolving dependencies...
Configuring mime-string-0.5...
Preprocessing library for mime-string-0.5..
Building library for mime-string-0.5..
[ 1 of 12] Compiling Codec.MIME.String.EncodedWord ( src/Codec/MIME/String/EncodedWord.hs, dist/build/Codec/MIME/String/EncodedWord.o )
[ 2 of 12] Compiling Codec.MIME.String.Internal.ABNF ( src/Codec/MIME/String/Internal/ABNF.hs, dist/build/Codec/MIME/String/Internal/ABNF.o )
[ 3 of 12] Compiling Codec.MIME.String.Internal.Utils ( src/Codec/MIME/String/Internal/Utils.hs, dist/build/Codec/MIME/String/Internal/Utils.o )
[ 4 of 12] Compiling Codec.Binary.EncodingQ.String ( src/Codec/Binary/EncodingQ/String.hs, dist/build/Codec/Binary/EncodingQ/String.o )
[ 5 of 12] Compiling Codec.MIME.String.Headers ( src/Codec/MIME/String/Headers.hs, dist/build/Codec/MIME/String/Headers.o )
[ 6 of 12] Compiling Codec.MIME.String.Date ( src/Codec/MIME/String/Date.hs, dist/build/Codec/MIME/String/Date.o )
[ 7 of 12] Compiling Codec.MIME.String.ContentDisposition ( src/Codec/MIME/String/ContentDisposition.hs, dist/build/Codec/MIME/String/ContentDisposition.o )
[ 8 of 12] Compiling Codec.MIME.String.QuotedPrintable ( src/Codec/MIME/String/QuotedPrintable.hs, dist/build/Codec/MIME/String/QuotedPrintable.o )
[ 9 of 12] Compiling Codec.MIME.String.Types ( src/Codec/MIME/String/Types.hs, dist/build/Codec/MIME/String/Types.o )
[10 of 12] Compiling Codec.MIME.String.Parse ( src/Codec/MIME/String/Parse.hs, dist/build/Codec/MIME/String/Parse.o )
[11 of 12] Compiling Codec.MIME.String.Flatten ( src/Codec/MIME/String/Flatten.hs, dist/build/Codec/MIME/String/Flatten.o )
[12 of 12] Compiling Codec.MIME.String ( src/Codec/MIME/String.hs, dist/build/Codec/MIME/String.o )

real	7m46.152s
user	36m39.020s
sys	22m36.241s

This time it took 7+ minutes!

top while Date.hs is being compiled:

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  48026 asjo      20   0 1026.7g   6.1g  96456 S 734.8  39.9  35:58.05 /usr/lib/ghc/bin/ghc -B/usr/lib/ghc --m+ 

Date.hs is 242 lines long.


Wouldn’t it be worth to inform maintainer of mime-string?


Hello Aleskej,
there is an email address on the hackage page, have you tried to contact him?


@asjo, did you try to reach maintainer?


I did it yet.

To: guillaumh***
Date: 26 November 2019 at 14:35
Subject: mime-string

I’d like to inform you about build issue, which was reported on discourse[1] a few days agou. On matrix[2] build failed for some of ghc versions.

[1] Building mime-string-0.5 from Hackage takes 5 minutes and uses more than 5 GB of memory

Best, Alexei


Great catch @asjo! This seems to be a performance regression in GHC from 8.4 to 8.6. I’ve reported it in


It might very well be, but the library hasn’t changed since 2017, so I thought I would start here, to hear if I’m the only one seeing this.


Cool - I will be following that issue; thanks!