-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: takes too much cpu and fails when compiling huge go files #14082
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
Comments
Well I solved this in my tool, previously the file structure was like this package assets
// ImagesDocTXT file
var ImagesDocTXT = []byte{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x0a, 0x49,
0x2d, 0x2e, 0xc9, 0xcc, 0x4b, 0x57, 0x30, 0x54, 0x30, 0x52, 0x30, 0xe6,
0x02, 0x04, 0x00, 0x00, 0xff, 0xff, 0x23, 0xc2, 0x19, 0x35, 0x0e, 0x00,
0x00, 0x00,
} And so I thought the lexer has to read a lot of tokens for upto 300K loc and that might be clogging it up so I then rewrote all the data to this package assets
// ImagesDocTXT file
var ImagesDocTXT = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x02\xff\x0a\x49\x2d\x2e\xc9\xcc\x4b\x57\x30\x54\x30\x52\x30\xe6\x02\x04\x00\x00\xff\xff\x23\xc2\x19\x35\x0e\x00\x00\x00") And now the no of lines drop to about 50 and everything works fine. |
I'm reopening this. Even if you worked around it, the issue remains. |
iirc, there's a very old issue relating to very large slice literals causing the compiler to use lots of memory and slow down. What that ever fixed? |
If you're referring to #11612 no, it's not fixed yet. It's in the 1.7 milestone. |
@ALTree much older (known from at least around the 1.0-1.1 days). I'll try to dig it up. I suspect these are all the same issue though, and that fixing one will fix them all. |
@dominikh that's the one, thanks! |
I'm experiencing some version of this as well. Working on a Go port of HTTPS Everywhere, and the build fails if I try to embed all the HTTPS Everywhere rules here: https://github.com/getlantern/httpseverywhere/tree/too-large-for-go Cutting down the size of the
|
@myleshorton please file a new issue and cc me. |
I think the original issue here is a straightforward dup of #6643. The other conversations have either been resolved or have their own issues. Closing. |
I use this go-embed tool for embedding resources into my executable directly. It produces a file like this https://github.com/pyros2097/go-embed/blob/master/examples/assets/main_prod.go.
But When I use this to build my frontend images which approximates to 20MB into a single main.go file which is also 20MB but is 300K+ lines of code It takes forever to compile and then crashes my CPU. I guess this is a problem because I have only 4GB of memory and an core i3 processor.
But it seems to compile properly on my friends 16GB laptop core i7.
Is there anyway I can make it compile on my laptop? Maybe by splitting the single file into many files or something?
My GoENV and go version go1.5.2 linux/amd64
The text was updated successfully, but these errors were encountered: