-
Josh Bleecher Snyder authored
We generate code that calls each user init function one at a time. When there are lots of user init functions, usually due to generated code, like test/rotate* or github.com/juju/govmomi/vim25/types, we can end up with a giant function, which can be slow to compile. This CL puts in an escape valve. When there are more than 500 functions, instead of doing: init.0() init.1() // ... we construct a static array of functions: var fns = [...]func(){init.0, init.1, ... } and call them in a loop. This generates marginally bigger, marginally worse code, so we restrict it to cases in which it might start to matter. 500 was selected as a mostly arbitrary threshold for "lots". Each call uses two Progs, one for PCDATA and one for the call, so at 500 calls we use ~1000 Progs. At concurrency==8, we get a Prog cache of about 1000 Progs per worker. So a threshold of 500 should more or less avoid exhausting the Prog cache in most cases. Change-Id: I276b887173ddbf65b2164ec9f9b5eb04d8c753c2 Reviewed-on: https://go-review.googlesource.com/41500Reviewed-by: Keith Randall <khr@golang.org>
d1b544c7
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
internal | ||
doc.go | ||
fmt_test.go | ||
main.go |