-
Josh Bleecher Snyder authored
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/7360Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
57279ba7