]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/gc: separate func-only Node fields
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 11 Mar 2015 04:37:13 +0000 (21:37 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 1 Apr 2015 18:00:20 +0000 (18:00 +0000)
commit57279ba752d6975f387b7707a99e43ec9ad6725e
treee52629a8b12d1e6fcf304bcb42aed0b4f2173d1b
parent9fd87bd5015f6e1fa75f43086e096d0f12f1ce50
cmd/internal/gc: separate func-only Node fields

Nodes dominate gc's memory usage, but many fields are only used
for a subset of kinds of nodes. This change pulls out fields
used only for func-like Nodes. This reduces the size of the
Node struct on a 64-bit machine from 504 bytes to 416 bytes (-17%).

Compiling the runtime, 1.5% of nodes have a non-nil Func.
In html/template, 2.7% of nodes have a non-nil Func.

This change introduces an extra alloc and associated GC overhead
when Func is non-nil. However, when Func is nil, as it almost
always is, it spares the garbage collector scanning some Node fields.
Empirically, this change appears to be roughly neutral with regard to GC.

To keep the diff readable, this CL uses an embedded Func field.
A subsequent CL will unembed the field.

Passes toolstash -cmp.

Change-Id: Ide86aa954b097fb8e6154f0811d3691497477004
Reviewed-on: https://go-review.googlesource.com/7360
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/internal/gc/closure.go
src/cmd/internal/gc/dcl.go
src/cmd/internal/gc/export.go
src/cmd/internal/gc/go.y
src/cmd/internal/gc/inl.go
src/cmd/internal/gc/subr.go
src/cmd/internal/gc/syntax.go
src/cmd/internal/gc/y.go