Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break up JSDOM.Types #5

Open
mightybyte opened this issue Jan 5, 2018 · 14 comments
Open

Break up JSDOM.Types #5

mightybyte opened this issue Jan 5, 2018 · 14 comments

Comments

@mightybyte
Copy link

mightybyte commented Jan 5, 2018

When I build jsaddle-dom I get the following error:

[  1 of 600] Compiling JSDOM.Types      ( src/JSDOM/Types.hs, dist/build/JSDOM/Types.p_o )
clang-3.7: error: unable to execute command: Killed: 9
clang-3.7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.1 (tags/RELEASE_371/final)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to  and include the crash backtrace, preprocessed source, and associated run script.
clang-3.7: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.7: note: diagnostic msg: /private/var/folders/yw/4lyc2l_n51z601wqjnyc9vvr0000gn/T/nix-build-jsaddle-dom-0.9.1.0.drv-0/ghc_14-d6f02a.c
clang-3.7: note: diagnostic msg: /private/var/folders/yw/4lyc2l_n51z601wqjnyc9vvr0000gn/T/nix-build-jsaddle-dom-0.9.1.0.drv-0/ghc_14-d6f02a.sh
clang-3.7: note: diagnostic msg:

********************

<no location info>: error:
    `cc' failed in phase `C Compiler'. (Exit code: 254)

It sits on the JSDOM.Types module for tens of minutes, possibly more than an hour before failing. I'm running macOS on a machine with 16 gigs of RAM. The fact that I can't build jsaddle-dom on a machine this big seems like a problem. Is it possible to break this module up to make it buildable on normal size systems?

@luite
Copy link
Member

luite commented Jan 22, 2018

what are the compiler version and tools/settings you use to cause this?

in a normal build on my system, GHC 8.2.2, macOS 10.13.2, latest XCode tools, JSDOM.Types takes very long to build, but GHC "only" peaks at around 2.5GB of memory.

(edit: my "normal" build meaning cabal install in a clean sandbox, with no custom options. GHC from the minimal Haskell platform)

@mightybyte
Copy link
Author

This is with GHC 8.0.2 and ghcjs-0.2.1-8.0.2 on macOS 10.11.6.

If you look closely at the above output, it says Types.p_o, so I think this on a build with profiling turned on (probably done automatically by nix I would imagine).

@mightybyte
Copy link
Author

Just to follow up, we've also tried to build this on a machine with 32 gigs of RAM and it still runs out of memory. IMO you should definitely consider breaking this module up. This is a huge problem.

@Ericson2314
Copy link
Member

Ericson2314 commented Feb 15, 2018

CC @luigy, who was running out of memory on linux-only.

@luite
Copy link
Member

luite commented Feb 17, 2018

GHC's own memory usage looks reasonable. This is caused by the C compiler compiling the temporary file declaring all cost centres. GCC 5.4.0 seems to cope, clang 3.7 doesn't. The file is around 100k lines with contents like this:

 extern CostCentreStack jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject_CAF_cc_ccs[];
 REGISTER_CCS(jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject_CAF_cc_ccs);
 extern CostCentreStack jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject1_CAF_cc_ccs[];
 REGISTER_CCS(jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject1_CAF_cc_ccs);
 extern CostCentreStack jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject2_CAF_cc_ccs[];
 REGISTER_CCS(jsaddlezmdomzm0zi9zi1zi0zm523c3ILQYauIbqrzzngOY1D_JSDOMziTypes_gTypeGObject2_CAF_cc_ccs);

This has been fixed in GHC 8.4.1. A workaround for earlier versions is removing any -fprof-auto flag from the GHC options (or appending -fno-prof-auto)

see
https://ghc.haskell.org/trac/ghc/ticket/7960
https://git.haskell.org/ghc.git/commitdiff/a8da0de27e600211f04601ac737c329d6603c700

@mightybyte
Copy link
Author

Any chance we can side step this problem easily by just breaking up the module?

@luite
Copy link
Member

luite commented Feb 17, 2018

"just" breaking up the module seems like a tad more work than adding a GHC flag. Why make major changes to the code if we already have a workaround and proper upstream fix?

Now that we know the problem, I think we should first figure out if there should be a workaround in the package itself, perhaps a GHC version dependent (with CPP) OPTIONS_GHC pragma or a few lines in the cabal file.

@luigy
Copy link

luigy commented Feb 18, 2018

This has been fixed in GHC 8.4.1. A workaround for earlier versions is removing any -fprof-auto flag from the GHC options (or appending -fno-prof-auto)

good call @luite removing -fprof-auto got rid of my out of memory issues I was hitting on linux with profiled build for jsaddle-dom

@luite
Copy link
Member

luite commented Feb 25, 2018

workaround for GHC issue implemented in pull request #6

I'm not the package maintainer. @hamishmack merge if you think this looks ok.

@eskimor
Copy link
Contributor

eskimor commented Jul 28, 2018

I am experiencing a similar issue with ghc 8.4.3 (not with 8.2.2). Even without profiling the build does not complete on my 8 GB machine. I filed a ghc issue: https://ghc.haskell.org/trac/ghc/ticket/15455#comment:1

Is anyone else experiencing this?

@FintanH
Copy link

FintanH commented Apr 10, 2019

This is still an issue for me on ghc-8.0.2 and using the -fno-prof-auto

@573
Copy link

573 commented Jul 31, 2020

@eskimor I experience a similar issue with ghc883, see link in comment here.
@mightybyte guess I will repeat my build with profiling off for jsaddle-dom then.

@Lysxia
Copy link

Lysxia commented Sep 13, 2020

I also have trouble compiling JSDOM.Types. I split the module by hand; with one hour work, the new modules build in 5 minutes with 8GB RAM. The main thing stopping me from just making a PR is that the split is sort of random, and maybe you'd rather fix whatever script is generating JSDOM.Types instead of messing with the generated file manually. Feel free to leave suggestions to put it into a reviewable state.

https://github.com/Lysxia/jsaddle-dom/tree/splittypes

@noinia
Copy link

noinia commented Dec 29, 2021

I second the request to split up JSDOM.Types. Even with current GHC's this still need a huge amount of RAM, and takes quite a while to compile. Moreover, it prevents downstream packages from easily using CI systems [1,2]. This has a cost as well, since it does not easily allow authors to make sure their package builds using the latest versions of the packages on hackage. (Indeed, reflex-dom currently no longer builds, thus causing me as yet another downstream package author to figure out why).

Are there reasons why we would particularly like to keep this single huge types module?

[1] e.g. reflex-dom's testsuite fails due to out of memory errors when compiling jsaddle-dom (see e.g. https://github.com/reflex-frp/reflex-dom/runs/4629811019?check_suite_focus=true )
[2] I can't add hgeometry-web to my CI for the same reason as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants