elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

Memory leak/excessive memory use on make #132

Closed mulander closed 7 years ago

mulander commented 7 years ago

Elm uses over 1 GB of memory to compile a small library (essentially a big Dict). Restarting the build passes (first failure is from enforced limits).

Steps to reproduce:

  1. git clone git@github.com:mulander/diceware.git
  2. cd diceware
  3. elm-make
  4. elm-make

expected output from the reproduced issue:

$ elm-make                                                                                                                             
Some new packages are needed. Here is the upgrade plan.

  Install:
    elm-lang/core 5.0.0

Do you approve of this plan? [Y/n] y
Starting downloads...

  _ elm-lang/core 5.0.0
Packages configured successfully!
[====================================              ] - 19 / 26elm-make: out of memory (requested 1048576 bytes)
$ elm-make
Success! Compiled 6 modules.
$

I stumbled on this while updating mulander/diceware for elm 0.18. I also saw a similar leak when doing elm-package diff on an unpublished package (though only after I did elm-package bump). I can't reproduce that one.

  1. elm-package bump
  2. elm-package diff - memory fail
  3. elm-package diff - passes

output from the fialure:

$ elm-package diff
Error: A system call failed.

failure when running: elm-make --yes --docs=elm-stuff/documentation.json --prepublish
elm-make: out of memory (requested 1048576 bytes)
process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

mulander commented 7 years ago

Thanks @process-bot ;)

$ elm --version
0.18.0
$ sysctl kern.version
kern.version=OpenBSD 6.0-current (GENERIC.MP) #0: Mon Nov 14 12:16:34 MST 2016
    deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
$ cabal --version
cabal-install version 1.22.6.0
using version 1.22.5.0 of the Cabal library
evancz commented 7 years ago

Is it this? https://github.com/elm-lang/elm-compiler/issues/1362

evancz commented 7 years ago

I need you to get this down to an http://sscce.org

Isolate the file that causes the problem. Strip out everything else. Then isolate the function that causes the problem. Share that function. I suspect it's related to pattern matching (probably with tuples or many of the same constructor with different values) which is way faster with some recent changes I have made.

In any case, please open a new issue if you can get it down to an SSCCE.