Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8244)

Issue 6345044: code review 6345044: cmd/gc: reduce memory consumption (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by atom
Modified:
10 years, 1 month ago
Reviewers:
lvd, rsc, dfc, bradfitz
CC:
golang-dev
Visibility:
Public.

Description

cmd/gc: reduce memory consumption This change introduces a new struct FuncNode and moves fields from Node to FuncNode. Node and FuncNode are logically the same object, thus for each FuncNode it holds true that (n->funcnode->node == n) and (aFuncNode->node->funcnode == aFuncNode). The fact that Node and FuncNode are logically the same object means that the semantics of the original C code remains unchanged. Reduced memory consumption is achieved because FuncNode is allocated only if it is needed. The new function funcnode() will allocate a FuncNode on demand. It is recommended to always call this function when going from a Node to to its FuncNode, unless circumstances are against this recommendation. Similarly, the new struct UncommonNode contains fields of Node which are specific to a small number of Node instances. The accessor function unode() will allocate an UncommonNode on demand. Although this patch affects y.tab.h and y.tab.c, these two files are omitted from the patch.

Patch Set 1 #

Patch Set 2 : diff -r 4f26c5344754 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 126c37a9e33c https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+488 lines, -384 lines) Patch
M src/cmd/5g/gg.h View 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/5g/ggen.c View 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/5g/reg.c View 1 3 chunks +3 lines, -3 lines 0 comments Download
M src/cmd/6g/gg.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/6g/ggen.c View 1 2 3 chunks +3 lines, -3 lines 0 comments Download
M src/cmd/6g/reg.c View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/8g/gg.h View 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/8g/ggen.c View 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/8g/reg.c View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/gc/closure.c View 1 2 8 chunks +50 lines, -43 lines 0 comments Download
M src/cmd/gc/dcl.c View 1 2 9 chunks +25 lines, -25 lines 0 comments Download
M src/cmd/gc/esc.c View 1 2 17 chunks +30 lines, -30 lines 0 comments Download
M src/cmd/gc/export.c View 1 2 4 chunks +12 lines, -8 lines 0 comments Download
M src/cmd/gc/fmt.c View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/gc/gen.c View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/gc/go.h View 1 2 16 chunks +62 lines, -35 lines 0 comments Download
M src/cmd/gc/go.y View 1 2 22 chunks +45 lines, -38 lines 0 comments Download
M src/cmd/gc/init.c View 1 3 chunks +12 lines, -9 lines 0 comments Download
M src/cmd/gc/inl.c View 1 2 15 chunks +54 lines, -53 lines 0 comments Download
M src/cmd/gc/lex.c View 1 2 6 chunks +8 lines, -8 lines 0 comments Download
M src/cmd/gc/order.c View 1 chunk +2 lines, -2 lines 0 comments Download
M src/cmd/gc/pgen.c View 1 2 7 chunks +14 lines, -14 lines 0 comments Download
M src/cmd/gc/racewalk.c View 1 2 2 chunks +7 lines, -7 lines 0 comments Download
M src/cmd/gc/sinit.c View 1 2 9 chunks +10 lines, -10 lines 0 comments Download
M src/cmd/gc/subr.c View 1 2 19 chunks +99 lines, -44 lines 0 comments Download
M src/cmd/gc/swt.c View 1 3 chunks +5 lines, -5 lines 0 comments Download
M src/cmd/gc/typecheck.c View 1 2 6 chunks +14 lines, -14 lines 0 comments Download
M src/cmd/gc/walk.c View 1 2 10 chunks +21 lines, -21 lines 0 comments Download

Messages

Total messages: 13
atom
Hello dave@cheney.net, rsc@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
11 years, 9 months ago (2012-06-26 21:23:58 UTC) #1
bradfitz
Numbers? On Tue, Jun 26, 2012 at 2:23 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > Reviewers: dfc, rsc, ...
11 years, 9 months ago (2012-06-26 21:39:31 UTC) #2
0xe2.0x9a.0x9b_gmail.com
On Tuesday, June 26, 2012 11:39:30 PM UTC+2, Brad Fitzpatrick wrote: > > Numbers? > ...
11 years, 9 months ago (2012-06-26 21:43:42 UTC) #3
lvd
is gc memory usage a problem? On Tue, Jun 26, 2012 at 11:43 PM, ⚛ ...
11 years, 9 months ago (2012-06-27 08:51:05 UTC) #4
dfc
It can be, I can't run a go builder reliably on my ARMv5 host any ...
11 years, 9 months ago (2012-06-27 09:00:12 UTC) #5
rsc
I already said that I would like to have a discussion about memory reduction strategies ...
11 years, 9 months ago (2012-06-27 13:42:09 UTC) #6
dfc
On 2012/06/27 13:42:09, rsc wrote: > I already said that I would like to have ...
11 years, 6 months ago (2012-10-11 00:33:30 UTC) #7
atom
On 2012/10/11 00:33:30, dfc wrote: > On 2012/06/27 13:42:09, rsc wrote: > > I already ...
11 years, 6 months ago (2012-10-12 17:00:10 UTC) #8
dfc
Thank you. On Sat, Oct 13, 2012 at 4:00 AM, <0xE2.0x9A.0x9B@gmail.com> wrote: > On 2012/10/11 ...
11 years, 6 months ago (2012-10-13 00:32:03 UTC) #9
atom
Hello dave@cheney.net, rsc@golang.org, bradfitz@golang.org, lvd@google.com (cc: golang-dev@googlegroups.com), Please take another look.
11 years, 6 months ago (2012-10-15 13:55:46 UTC) #10
rsc
I am still interested in this CL, but I would like to see a memory ...
11 years, 5 months ago (2012-11-01 18:44:19 UTC) #11
atom
Hello dave@cheney.net, rsc@golang.org, bradfitz@golang.org, lvd@google.com (cc: golang-dev@googlegroups.com), Please take another look.
11 years, 5 months ago (2012-11-03 09:25:48 UTC) #12
atom
11 years, 5 months ago (2012-11-03 09:44:56 UTC) #13
On 2012/11/01 18:44:19, rsc wrote:
> I am still interested in this CL, but I would like to see a memory
> profile showing what memory usage looks like before we start fixing
> things. One way to get a memory profile would be to hook it up on
> Linux to the C++ pprof (http://code.google.com/p/gperftools).

I used Valgrind. When compiling godoc with 8g, the call counts are:

nod(): 357782 calls, 357782 calls to mal()
funcnode(): 21654 calls, 17648 mal()
unode(): 4470 calls, 3690 mal()

Sizes in bytes (8g):

sizeof(Node) = 180 (old size: 216)
sizeof(FuncNode) = 40
sizeof(UncommonNode) = 20

The theoretical difference in memory usage when compiling godoc is approximately
340000*(216-180) = 12MiB. Actual difference as measured by /usr/bin/time is
10MiB (=131-121).

---

Note: A new struct UncommonNode and function unode() has been added to the
changeset. Maybe we could move additional uncommon fields from Node to
UncommonNode before the decision to merge this changeset into Go is made.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b