-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: out of memory compiling cmd/compile/internal/ssa with 1GB RAM #27739
Comments
Likely a duplicate of #26523. Sorry, the CL is already merged. I didn't see that. |
Yes, I'll do that. |
That patch is part of the go1.11 release, and building go1.11 still fails. |
I'm going to try to bisect 74b5602...e0faedb and see if that produces interesting results. |
What version of Go is the bootstrap compiler? If I understand correctly, it is toolchain1 OOM'd, and toolchain1 is built with the bootstrap compiler with the bootstrap runtime. |
Ah, fair point. I was using go1.11 as my bootstrap toolchain. (Interestingly, though, building go1.10.4 with go1.11 as the bootstrap toolchain works fine...) |
My first round of bisecting blames commit e913729, but I'm going to bisect again with 1.10.4 as my bootstrap toolchain and see if that produces different results. (That commit doesn't make much sense as the source of the regression.) |
Go 1.11 compiler does more work, which of course has more code. So it is a double factor here if using Go 1.11 compiler to compile Go 1.11 compiler: it (may) use more memory (even compiling the same code), and it compiles more code. Maybe a workaround is to use an older (or newer) bootstrap compiler? |
make.bash on go1.11 using go1.10.4 as a bootstrap still fails. I'm bisecting the same commit range. |
When bootstrapping with 1.10.4, bisect blames cc09212.
That commit doesn't make much sense as the culprit either, but both bisects point to a regression introduced somewhere in or around May of this year. |
What are the stats of the vm you are using? How many cores? Is any swap configured?
From my informal testing you need ~768mb of ram per core on a 64bit machine to complete ./all.bash.
… On 19 Sep 2018, at 06:54, Phil ***@***.***> wrote:
make.bash on go1.11 using go1.10.4 as a bootstrap still fails. I'm bisecting the same commit range.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It's the cheapest Digital Ocean VM. 1 vCPU, 1GB memory, no swap:
It's less important to me how many resources one needs to build the toolchain, and more important that things are moving in the wrong direction. Shouldn't peak resource consumption by the compiler be determined by either the largest package (in the compiler front-end) or the largest function (in the back-end)? The out-of-memory condition doesn't occur in the linker, where I would expect resource consumption to grow in concert with the repo growing ~10% more code. |
Additional anecdotal evidence of a memory use regression, though only for vmsize, not rss, which would make sense. |
I think we should have a builder that has a relatively small amount of memory. Somewhat related, in #26867 I reported how We can assume that Linux is fairly common on machines with less memory (small computers, routers, VMs, etc), and that a 64-bit architecture like amd64 should stress test the memory more than a 32-bit architecture would. We already have special builders like
/cc @dmitshur |
i suggest add memory swap on/off @mvdan |
@mvdan, let's not combine two bugs into one. It's hard to label & track that way. Could you file a separate builder bug about a small config? (but perhaps we could just make an existing builder (cgo, noopt?) be the small one... you could float that in the bug, or I could reply there later) I'm going to remove the "Builders" label from this bug. |
@bradfitz you're right - see the issue above. |
I just tried building cmd/compile/internal/ssa with tip and it took just over 1G. |
#20104 is one big fix here |
@josharian I agree that #20104 would reduce memory pressure when compiling cmd/compile/internal/ssa. However, you'll notice the compiler fails in the second bootstrap phase rather than the first, which means compiling the current code with the old compiler succeeds, but compiling the same code with the current compiler fails. In other words, the regression is in the compiler's memory use, rather than the size of the code to be compiled. The regression in the compiler's performance seems higher-priority to me, since it impacts more than just folks working on the Go compiler itself. |
We've also started seeing this failure regularly on the openbsd/arm builder since around the 6th of March 2019 - a few examples: https://build.golang.org/log/6c0247ef60f5ab34aae85aee05be681c7e4383cc (although this is compiling ssa.test, rather than just ssa) |
Change https://golang.org/cl/176221 mentions this issue: |
pprof alloc_space for compiling package ssa with tip:
My reactions to this:
This is milestoned 1.13. If we want to fix it for 1.13, and the little chipping-away-at-the-edges work above doesn't do it, the only available fix I see is #20104. I'm happy to work on that, but there's a fair amount of code churn associated with that, more than I'd normally feel comfortable with during the freeze, so making that judgment call is above my pay grade. |
It's possible we can do better in scopePCs, I'd need to think about it, but I think we can avoid the huge intermediate array of PCs-with-same-XPos (including column!) |
Change https://golang.org/cl/154617 mentions this issue: |
Updates #27739: reduces package ssa's allocated space by 3.77%. maxrss is harder to measure, but using best-of-three-runs as reported by /usr/bin/time -l, I see ~2% reduction in maxrss. We still have a long way to go, though; the new maxrss is still 1.1gb. name old alloc/op new alloc/op delta Template 38.8MB ± 0% 37.7MB ± 0% -2.77% (p=0.008 n=5+5) Unicode 28.2MB ± 0% 28.1MB ± 0% -0.20% (p=0.008 n=5+5) GoTypes 131MB ± 0% 127MB ± 0% -2.94% (p=0.008 n=5+5) Compiler 606MB ± 0% 587MB ± 0% -3.21% (p=0.008 n=5+5) SSA 2.14GB ± 0% 2.06GB ± 0% -3.77% (p=0.008 n=5+5) Flate 24.0MB ± 0% 23.3MB ± 0% -3.00% (p=0.008 n=5+5) GoParser 28.8MB ± 0% 28.1MB ± 0% -2.61% (p=0.008 n=5+5) Reflect 83.8MB ± 0% 81.5MB ± 0% -2.71% (p=0.008 n=5+5) Tar 36.4MB ± 0% 35.4MB ± 0% -2.73% (p=0.008 n=5+5) XML 47.9MB ± 0% 46.7MB ± 0% -2.49% (p=0.008 n=5+5) [Geo mean] 84.6MB 82.4MB -2.65% name old allocs/op new allocs/op delta Template 379k ± 0% 379k ± 0% -0.05% (p=0.008 n=5+5) Unicode 340k ± 0% 340k ± 0% ~ (p=0.151 n=5+5) GoTypes 1.36M ± 0% 1.36M ± 0% -0.06% (p=0.008 n=5+5) Compiler 5.49M ± 0% 5.48M ± 0% -0.03% (p=0.008 n=5+5) SSA 17.5M ± 0% 17.5M ± 0% -0.03% (p=0.008 n=5+5) Flate 235k ± 0% 235k ± 0% -0.04% (p=0.008 n=5+5) GoParser 302k ± 0% 302k ± 0% -0.04% (p=0.008 n=5+5) Reflect 976k ± 0% 975k ± 0% -0.10% (p=0.008 n=5+5) Tar 352k ± 0% 352k ± 0% -0.06% (p=0.008 n=5+5) XML 436k ± 0% 436k ± 0% -0.03% (p=0.008 n=5+5) [Geo mean] 842k 841k -0.04% Change-Id: I0ab6631b5a0bb6303c291dcb0367b586a4e584fb Reviewed-on: https://go-review.googlesource.com/c/go/+/176221 Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
Change https://golang.org/cl/176577 mentions this issue: |
@4a6f656c observed in #30981 (closed as dup of this issue):
@bradfitz @ianlancetaylor unless David's two CLs (outstanding) and mine (merged) get the builder green again, we'll need to make a call about how to proceed here. See #27739 (comment). |
Three loops can be converted into one. Minor reviewer-recommended refactoring. Passes toolstash-check. Updates #27739. Change-Id: Ia87a11d88ae3ce56fcc4267fe6c5a9c13bf7f533 Reviewed-on: https://go-review.googlesource.com/c/go/+/176577 Run-TryBot: David Chase <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Josh Bleecher Snyder <[email protected]> Reviewed-by: Alessandro Arzilli <[email protected]>
David's first CL is in, and the opendsb/arm builder is currently pending, as opposed to failing quickly, so that is a good sign. Attempts to measure maxrss locally indicate that 1.12 and tip are now similar for package ssa. And compilecmp shows a nice overall memory usage reduction from 1.12 to tip:
So pending some solid green from openbsd/arm, I think we might be good enough for 1.13 here. And then I'll undertake to fix this once and for all with #20104 for 1.14. |
Attempting to compile
|
@lyda please file a new issue, and we'll investigate there. And please include a complete log and setup information. Thanks! |
This reduces allocations and also resolves some lurking inliner/inlinee line-number match problems. However, it does add about 1.5% to compile time. This fixes compiler OOMs seen compiling some large protobuf- derived inputs. For compiling the compiler itself, compilebench -pkg cmd/compile/internal/ssa -memprofile withcl.prof the numberlines-related memory consumption is reduced from 129MB to 29MB (about a 5% overall reduction in allocation). Additionally modified after going over changes with Austin to remove unused code (nobody called size()) and correct the cache-clearing code. I've attempted to speed this up by not using maps, and have not succeeded. I'd rather get correct code in now, speed it up later if I can. Updates #27739. Fixes #29279. Change-Id: I098005de4e45196a5f5b10c0886a49f88e9f8fd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/154617 Run-TryBot: David Chase <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Will when I get a chance. |
Change https://golang.org/cl/177917 mentions this issue: |
name old alloc/op new alloc/op delta Template 37.1MB ± 0% 36.8MB ± 0% -0.57% (p=0.008 n=5+5) Unicode 28.1MB ± 0% 28.1MB ± 0% -0.07% (p=0.008 n=5+5) GoTypes 125MB ± 0% 124MB ± 0% -0.61% (p=0.008 n=5+5) Compiler 571MB ± 0% 568MB ± 0% -0.60% (p=0.008 n=5+5) SSA 1.88GB ± 0% 1.86GB ± 0% -0.82% (p=0.008 n=5+5) Flate 22.9MB ± 0% 22.8MB ± 0% -0.59% (p=0.008 n=5+5) GoParser 27.5MB ± 0% 27.3MB ± 0% -0.53% (p=0.008 n=5+5) Reflect 79.8MB ± 0% 79.5MB ± 0% -0.40% (p=0.008 n=5+5) Tar 34.9MB ± 0% 34.7MB ± 0% -0.44% (p=0.008 n=5+5) XML 45.7MB ± 0% 45.4MB ± 0% -0.58% (p=0.008 n=5+5) [Geo mean] 80.3MB 79.9MB -0.52% name old allocs/op new allocs/op delta Template 380k ± 0% 378k ± 0% -0.57% (p=0.008 n=5+5) Unicode 340k ± 0% 340k ± 0% -0.08% (p=0.008 n=5+5) GoTypes 1.36M ± 0% 1.36M ± 0% -0.44% (p=0.008 n=5+5) Compiler 5.52M ± 0% 5.49M ± 0% -0.45% (p=0.008 n=5+5) SSA 17.6M ± 0% 17.5M ± 0% -0.42% (p=0.008 n=5+5) Flate 235k ± 0% 234k ± 0% -0.65% (p=0.008 n=5+5) GoParser 302k ± 0% 300k ± 0% -0.70% (p=0.008 n=5+5) Reflect 982k ± 0% 978k ± 0% -0.40% (p=0.008 n=5+5) Tar 353k ± 0% 351k ± 0% -0.53% (p=0.008 n=5+5) XML 437k ± 0% 435k ± 0% -0.48% (p=0.008 n=5+5) [Geo mean] 844k 840k -0.47% Updates #27739 Change-Id: I5d533013270cbbd7c0bad1b43da96c8499be76f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/177917 Run-TryBot: Josh Bleecher Snyder <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
FTR the openbsd/arm builder has been passing again since 6081a9f landed - thanks. |
Do we consider this closed? |
Yes, I think so. |
CL 213703 should help, if it goes in. |
Building tip on Ubuntu 18.04 on a Digital Ocean VM with one 1GB of RAM at commit 83dfc3b
I can reproduce this out-of-memory condition 100% of the time (in the prove pass in SSA):
1GB of memory has been more than enough to build the toolchain in the past.
Barring any clever ideas about how to debug this, I'll try to bisect and hope that there was only one commit that reliably introduced this regression.
The text was updated successfully, but these errors were encountered: