f77e7ed7e3
CL 214239 improved type printing, but introduced performance regressions:
3-5% memory increase, 1-2% CPU time increase.
There were two primary sources of the memory regression:
* allocating a bytes.Buffer for every type to print
* always printing to that buffer, even when we could return a constant string
This change addresses both of those regressions.
The sync.Pool allows buffer re-use.
String interning prevents allocation for re-used strings.
It addresses some, but not all, of the CPU time regression.
Memory performance impact vs master:
name old alloc/op new alloc/op delta
Template 37.6MB ± 0% 36.3MB ± 0% -3.30% (p=0.008 n=5+5)
Unicode 28.7MB ± 0% 28.3MB ± 0% -1.55% (p=0.008 n=5+5)
GoTypes 127MB ± 0% 122MB ± 0% -4.38% (p=0.008 n=5+5)
Compiler 584MB ± 0% 568MB ± 0% -2.72% (p=0.008 n=5+5)
SSA 1.99GB ± 0% 1.95GB ± 0% -1.97% (p=0.008 n=5+5)
Flate 23.5MB ± 0% 22.8MB ± 0% -2.84% (p=0.008 n=5+5)
GoParser 29.2MB ± 0% 28.0MB ± 0% -4.17% (p=0.008 n=5+5)
Reflect 81.9MB ± 0% 78.6MB ± 0% -4.09% (p=0.008 n=5+5)
Tar 35.3MB ± 0% 34.1MB ± 0% -3.29% (p=0.008 n=5+5)
XML 45.5MB ± 0% 44.3MB ± 0% -2.61% (p=0.008 n=5+5)
[Geo mean] 82.4MB 79.9MB -3.09%
name old allocs/op new allocs/op delta
Template 394k ± 0% 363k ± 0% -7.73% (p=0.008 n=5+5)
Unicode 340k ± 0% 329k ± 0% -3.25% (p=0.008 n=5+5)
GoTypes 1.41M ± 0% 1.28M ± 0% -9.54% (p=0.008 n=5+5)
Compiler 5.77M ± 0% 5.39M ± 0% -6.58% (p=0.008 n=5+5)
SSA 19.1M ± 0% 18.1M ± 0% -5.13% (p=0.008 n=5+5)
Flate 247k ± 0% 228k ± 0% -7.50% (p=0.008 n=5+5)
GoParser 325k ± 0% 295k ± 0% -9.24% (p=0.008 n=5+5)
Reflect 1.04M ± 0% 0.95M ± 0% -8.48% (p=0.008 n=5+5)
Tar 365k ± 0% 336k ± 0% -7.93% (p=0.008 n=5+5)
XML 449k ± 0% 417k ± 0% -7.10% (p=0.008 n=5+5)
[Geo mean] 882k 818k -7.26%
Memory performance going from
|
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
favicon.ico | ||
LICENSE | ||
PATENTS | ||
README.md | ||
robots.txt | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.