Skip to content

Memory usage when compiling unboxed explodes in 9.2.1-alpha2

Summary

I have updated the unboxed package to ghc-9.2.1-alpha2 (here on GitHub), but when compiling the benchmark suite I ran into a memory usage issue. I have been able to pinpoint it to the sub'Natural# function which I split out to an internal library called "bug".

Steps to reproduce

Run the following commands (with GHC 9.2.1-alpha2):

git clone -b ghc-9.2.1-alpha2 https://github.com/noughtmare/unboxed.git
cd unboxed
cabal update # for head.hackage
cabal build bug

Notice an explosion of memory usage. I have not been able to compile it on my 8GB machine.

Compiling the main branch with ghc 9.0.1 works fine.

Other comments

I also noticed that compilation can get stuck on the file src/Unboxed/Internal/Natural.hs. The memory doesn't explode, but the compiler just gets stuck with 0% CPU usage. Running cabal clean fixes that problem.

I have also noticed that this memory usage blowup seems to occur during renaming. Using -ddump-rn produces no output before the memory blowup and -ddump-rn-trace produces some output before the blowup, namely:

rn1 []
rn1: checking family instance consistency {
rn1: } checking family instance consistency
rn1a
rn12
getLocalNonValBinders 1 []
extendGlobalRdrEnvRn 2
  GlobalRdrEnv (locals only) {
    }
getLocalNonValBinders 2 []
extendGlobalRdrEnvRn 2
  GlobalRdrEnv (locals only) {
    }
getLocalNonValBinders 3
  []
  []
extendGlobalRdrEnvRn 2
  GlobalRdrEnv (locals only) {
    }
newTopSrcBinder
  Bug
  sub'Natural#
  bug/Bug.hs:11:1-12
rnSrcDecls [Bug.sub'Natural#]
extendGlobalRdrEnvRn 2
  GlobalRdrEnv (locals only) {
    sub'Natural# (unique iESfqu):
      Bug.sub'Natural# defined at bug/Bug.hs:11:1 }
Start rnTyClDecls []
rnTycl dependency analysis made groups []
Start rnmono
rnImplicitTvOccs
  []
  []

Environment

  • GHC version used: 9.2.1-alpha2 (from ghcup)

Optional:

  • Operating System: Debian 10
  • System Architecture: x86_64
Edited by Jaro Reinders
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information