1
0
mirror of https://github.com/golang/go synced 2024-09-29 20:34:36 -06:00
The Go programming language
Go to file
Cherry Zhang cc5eaf9346 cmd/internal/obj: write package path at compile time if possible
Currently, when the compiler emits a symbol name in the object
file, it uses "". for the package path of the package being
compiled. This is then expanded in the linker to the actual
package path.

With CL 173938, it does not need an allocation if the symbol name
does not need expansion. In many cases, the compiler actually
knows the package path (through the -p flag), so we could just
write it out in compile time, without fixing it up in the linker.
This reduces allocations in the linker.

In case that the package path is not known (compiler's -p flag is
missing, or the object file is generated by the assembler), the
linker still does the expansion.

This reduces ~100MB allocations (~10% inuse_space) in linking
k8s.io/kubernetes/cmd/kube-apiserver on Linux/AMD64.

Also makes the linker a little faster: linking cmd/go on
Linux/AMD64:
Real  1.13 ± 1%  1.11 ± 1%  -2.13%  (p=0.000 n=10+10)
User  1.17 ± 3%  1.14 ± 5%  -3.14%  (p=0.003 n=10+10)
Sys   0.34 ±15%  0.34 ±15%    ~     (p=0.986 n=10+10)

The caveat is that the object files get slightly bigger. On
Linux/AMD64, runtime.a gets 2.1% bigger, cmd/compile/internal/ssa
(which has a longer import path) gets 2.8% bigger.

This reveals that when building an unnamed plugin (e.g.
go build -buildmode=plugin x.go), the go command passes different
package paths to the compiler and to the linker. Before this CL
there seems nothing obviously broken, but given that the compiler
already emits the package's import path in various places (e.g.
debug info), I guess it is possible that this leads to some
unexpected behavior. Now that the compiler writes the package
path in more places, this disagreement actually leads to
unresolved symbols. Adjust the go command to use the same package
path for both compiling and linking.

Change-Id: I19f08981f51db577871c906e08d9e0fd588a2dd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/174657
Reviewed-by: Austin Clements <austin@google.com>
2019-05-06 18:17:03 +00:00
.github
api net/http: add support for SameSite=None 2019-05-06 18:01:25 +00:00
doc doc/go1.13: start doc, note macOS, FreeBSD deprecations 2019-05-02 14:04:56 +00:00
lib/time time: read 64-bit data if available 2019-02-26 23:10:35 +00:00
misc misc/ios: don't refer to iostest.bash 2019-05-03 13:24:36 +00:00
src cmd/internal/obj: write package path at compile time if possible 2019-05-06 18:17:03 +00:00
test cmd/compile: add math/bits.{Add,Sub}64 intrinsics on s390x 2019-05-03 10:41:15 +00:00
.gitattributes
.gitignore
AUTHORS A: Add Maya Rashish (individual CLA) 2019-04-23 14:40:30 +00:00
CONTRIBUTING.md
CONTRIBUTORS CONTRIBUTORS: second round of updates for Go 1.12 2019-01-30 18:01:19 +00:00
favicon.ico
LICENSE
PATENTS
README.md
robots.txt

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image 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.