1
0
mirror of https://github.com/golang/go synced 2024-11-06 15:26:13 -07:00
Commit Graph

43819 Commits

Author SHA1 Message Date
Brad Fitzpatrick
f00b8b45a2 cmd,std: update golang.org/x/net to 20200501053045-e0ff5e5a1de5
For latest http2 changes.

Which then required updating golang.org/x/sys in cmd too.

Change-Id: I3fac5f3a15f4c9381baaff597873ed0c6209dbac
Reviewed-on: https://go-review.googlesource.com/c/go/+/231457
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 18:00:18 +00:00
Dan Scales
a81bc8e825 runtime: add one extra lock ranking partial edge
This adds an assistQueue -> mheapSpecial edge, which can happen via

gcFlushBgCredit [gets assistQueue lock] -> ready() -> ... ->
allocm() -> newobject -> .. mProf_Malloc() ->
setprofilebucket() [gets mheap special lock]

From https://build.golang.org/log/6f8f253f6c3a747de411cfdf78c27980146618be

Change-Id: Icdfba41b49aa704e8f6f20d25271f938afaf52ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/231463
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2020-05-01 16:39:43 +00:00
Tobias Klauser
d1b36c8d86 internal/unsafeheader: fix reference in godoc comment for type String
Refer to reflect.StringHeader in the godoc comment for type String
instead of reflect.SliceHeader.

Change-Id: I40fc016c7365510a12c41d4ca596f66d2892c3f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/231537
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-05-01 16:14:17 +00:00
Gerrit Code Review
f092be8fd8 Merge "cmd: merge branch 'dev.link' into master" 2020-05-01 15:02:37 +00:00
Michał Łowicki
e3b0e3d646 cmd/go: add 'go help buildconstraint'
Fixes #37018

Change-Id: I1d32c1cb432bc2d7a4d8d6b5c3a54fee558141ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/228017
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-05-01 15:02:30 +00:00
Cherry Zhang
bed93255ba cmd: merge branch 'dev.link' into master
In the dev.link branch we continued developing the new object
file format support and the linker improvements described in
https://golang.org/s/better-linker . Since the last merge, more
progress has been made to improve the new linker, with
improvements on both linker speed and memory usage.

This is a clean merge.

Change-Id: I38516d6c4b41021bc61c1b9886e701de5fa2b0f1
2020-05-01 10:14:00 -04:00
Cherry Zhang
1667b35740 [dev.link] cmd/link: directly use loader.ExtReloc in ELF relocation generation
Convert the part that uses relocations to use loader.ExtReloc
directly. It still uses sym.Symbols for now, but not sym.Relocs.

This reduces some memory usage: linking cmd/compile with external
linking,

name             old allocs/op  new allocs/op  delta
Loadlibfull_GC     52.2MB ± 0%    13.9MB ± 0%  -73.40%  (p=0.008 n=5+5)

name             old live-B     new live-B     delta
Loadlibfull_GC      75.5M ± 0%     61.9M ± 0%  -18.02%  (p=0.008 n=5+5)

Change-Id: I317ecbf516063c42b255b2caba310ea6281342d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/231319
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-01 14:13:16 +00:00
Cherry Zhang
7aa6e0faf2 [dev.link] cmd/link: drop fields of external symbols after LoadFull
Free some memory.

Linking cmd/compile with external linking,

name             old live-B     new live-B     delta
Loadlibfull_GC     55.3M ± 0%     52.2M ± 0%    -5.50%  (p=0.008 n=5+5)

Change-Id: Ib8de2e61f2b012efaf6bdd98f9e5c56a19910b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/231224
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-01 13:54:49 +00:00
Cherry Zhang
83db26ac4a [dev.link] cmd/link: batch allocations when converting external relocations
Change-Id: Iad81cb159e46f694a03d58892ca7dfde3ee3095a
Reviewed-on: https://go-review.googlesource.com/c/go/+/231219
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-01 13:53:45 +00:00
Tobias Klauser
c12d7020f4 cmd/dist: don't copy riscv64 specific files for bootstrap build
For now this will only avoid copying math/big/arith_riscv64.s

Change-Id: Ib236e4bf1a6a758649629268a6f512f307596e74
Reviewed-on: https://go-review.googlesource.com/c/go/+/231298
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 12:33:12 +00:00
Keith Randall
fffe622963 runtime/race: rebuild race detector .syso files
Update #37355

Change-Id: I90cc121c158a9d44df01772083a7a9301598532e
Reviewed-on: https://go-review.googlesource.com/c/go/+/231297
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2020-05-01 06:37:35 +00:00
Brad Fitzpatrick
b8fd3cab39 net/http: remove badStringError, make some unexported structs non-comparable
Reduces binary size by 4K, not counting the http2 changes (in CL
231119) that'll be bundled into this package in the future.

Updates golang/go#38782

Change-Id: Id360348707e076b8310a8f409e412d68dd2394b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/231118
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 05:30:49 +00:00
cncal
e1d16843bd runtime/race: fix comment in select_test.TestNoRaceSelect1
selectGoImpl was merged into selectGo in https://golang.org/cl/37860.

Change-Id: I39985f37223743f1ea0aba9bee0e2708398a925c
GitHub-Last-Rev: ec97b4be32
GitHub-Pull-Request: golang/go#38716
Reviewed-on: https://go-review.googlesource.com/c/go/+/230340
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 05:25:54 +00:00
Ian Lance Taylor
07cb63aae5 syscall: document exact meaning of Ctty field
The Ctty field is a child descriptor number when Setctty is set,
but a parent descriptor when Foreground is set. This is absurd
but changing either behavior breaks existing programs.

With this change we at least document how it works.

For #29458

Change-Id: If9cf0a1a1e6ed0d4a4edae5043016d5b4ee3308b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229768
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2020-05-01 04:53:11 +00:00
Robert Griesemer
45d288718d bytes: simpler and faster FieldsFunc (apply same changes as for strings)
This change applies the recent changes to the strings package
(https://golang.org/cl/229765) to this package, with relevant
local adjustments.

In contrast to the changes in strings, for the bytes package
this change leads to a nice performance improvement of >10%.

Benchmarks run on a "quiet" MacBook Pro, 3.3GHz Dual-Core Intel Core i7,
with 16GB 2133MHz LPDDR3 RAM running macOS 10.15.4.

name                        old time/op    new time/op     delta
FieldsFunc/ASCII/16-4          191ns ± 9%      163ns ± 2%  -14.66%  (p=0.008 n=5+5)
FieldsFunc/ASCII/256-4        2.08µs ± 5%     1.80µs ± 8%  -13.51%  (p=0.008 n=5+5)
FieldsFunc/ASCII/4096-4       36.1µs ± 2%     31.7µs ± 7%  -12.34%  (p=0.008 n=5+5)
FieldsFunc/ASCII/65536-4       584µs ± 3%      517µs ± 3%  -11.52%  (p=0.008 n=5+5)
FieldsFunc/ASCII/1048576-4    9.45ms ± 3%     8.11ms ± 8%  -14.19%  (p=0.008 n=5+5)
FieldsFunc/Mixed/16-4          202ns ± 2%      181ns ± 2%  -10.02%  (p=0.008 n=5+5)
FieldsFunc/Mixed/256-4        2.12µs ± 6%     1.78µs ± 3%  -16.16%  (p=0.008 n=5+5)
FieldsFunc/Mixed/4096-4       40.4µs ± 2%     36.1µs ± 1%  -10.66%  (p=0.008 n=5+5)
FieldsFunc/Mixed/65536-4       700µs ± 5%      612µs ± 1%  -12.59%  (p=0.008 n=5+5)
FieldsFunc/Mixed/1048576-4    11.2ms ± 8%     10.3ms ± 4%   -8.15%  (p=0.008 n=5+5)

name                        old speed      new speed       delta
FieldsFunc/ASCII/16-4       84.0MB/s ± 9%   98.3MB/s ± 2%  +17.04%  (p=0.008 n=5+5)
FieldsFunc/ASCII/256-4       123MB/s ± 5%    143MB/s ± 8%  +15.74%  (p=0.008 n=5+5)
FieldsFunc/ASCII/4096-4      113MB/s ± 2%    130MB/s ± 6%  +14.20%  (p=0.008 n=5+5)
FieldsFunc/ASCII/65536-4     112MB/s ± 2%    127MB/s ± 3%  +13.05%  (p=0.008 n=5+5)
FieldsFunc/ASCII/1048576-4   111MB/s ± 3%    130MB/s ± 8%  +16.66%  (p=0.008 n=5+5)
FieldsFunc/Mixed/16-4       79.3MB/s ± 2%   88.2MB/s ± 2%  +11.15%  (p=0.008 n=5+5)
FieldsFunc/Mixed/256-4       121MB/s ± 5%    144MB/s ± 3%  +19.19%  (p=0.008 n=5+5)
FieldsFunc/Mixed/4096-4      101MB/s ± 2%    113MB/s ± 1%  +11.92%  (p=0.008 n=5+5)
FieldsFunc/Mixed/65536-4    93.7MB/s ± 5%  107.1MB/s ± 1%  +14.31%  (p=0.008 n=5+5)
FieldsFunc/Mixed/1048576-4  93.6MB/s ± 8%  101.8MB/s ± 4%   +8.77%  (p=0.008 n=5+5)

name                        old alloc/op   new alloc/op    delta
FieldsFunc/ASCII/16-4          80.0B ± 0%      80.0B ± 0%     ~     (all equal)
FieldsFunc/ASCII/256-4          768B ± 0%       768B ± 0%     ~     (all equal)
FieldsFunc/ASCII/4096-4       24.8kB ± 0%     24.8kB ± 0%     ~     (all equal)
FieldsFunc/ASCII/65536-4       497kB ± 0%      497kB ± 0%     ~     (p=0.444 n=5+5)
FieldsFunc/ASCII/1048576-4    9.61MB ± 0%     9.61MB ± 0%     ~     (p=0.500 n=5+5)
FieldsFunc/Mixed/16-4          96.0B ± 0%      96.0B ± 0%     ~     (all equal)
FieldsFunc/Mixed/256-4          768B ± 0%       768B ± 0%     ~     (all equal)
FieldsFunc/Mixed/4096-4       24.8kB ± 0%     24.8kB ± 0%     ~     (all equal)
FieldsFunc/Mixed/65536-4       497kB ± 0%      497kB ± 0%     ~     (all equal)
FieldsFunc/Mixed/1048576-4    9.61MB ± 0%     9.61MB ± 0%     ~     (p=0.881 n=5+5)

name                        old allocs/op  new allocs/op   delta
FieldsFunc/ASCII/16-4           1.00 ± 0%       1.00 ± 0%     ~     (all equal)
FieldsFunc/ASCII/256-4          1.00 ± 0%       1.00 ± 0%     ~     (all equal)
FieldsFunc/ASCII/4096-4         5.00 ± 0%       5.00 ± 0%     ~     (all equal)
FieldsFunc/ASCII/65536-4        12.0 ± 0%       12.0 ± 0%     ~     (all equal)
FieldsFunc/ASCII/1048576-4      24.0 ± 0%       24.0 ± 0%     ~     (all equal)
FieldsFunc/Mixed/16-4           1.00 ± 0%       1.00 ± 0%     ~     (all equal)
FieldsFunc/Mixed/256-4          1.00 ± 0%       1.00 ± 0%     ~     (all equal)
FieldsFunc/Mixed/4096-4         5.00 ± 0%       5.00 ± 0%     ~     (all equal)
FieldsFunc/Mixed/65536-4        12.0 ± 0%       12.0 ± 0%     ~     (all equal)
FieldsFunc/Mixed/1048576-4      24.0 ± 0%       24.0 ± 0%     ~     (all equal)

Change-Id: I59a2ed52563851c693b2c8dfce7e3cde640f62a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/231120
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 03:49:21 +00:00
Brian Kessler
4209a9f65a math/cmplx: handle special cases
Implement special case handling and testing to ensure
conformance with the C99 standard annex G.6 Complex arithmetic.

Fixes #29320

Change-Id: Id72eb4c5a35d5a54b4b8690d2f7176ab11028f1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/220689
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-05-01 03:16:37 +00:00
Bryan C. Mills
da382a3978 internal/unsafeheader: consolidate stringHeader and sliceHeader declarations into an internal package
The new package "internal/unsafeheader" depends only on "unsafe", and
provides declarations equivalent to reflect.StringHeader and
reflect.SliceHeader but with Data fields of the proper unsafe.Pointer
type (instead of uintptr).

Unlike the types it replaces, the "internal/unsafeheader" package has
a regression test to ensure that its header types remain equivalent to
the declarations provided by the "reflect" package.

Since "internal/unsafeheader" has almost no dependencies, it can be
used in other low-level packages such as "syscall" and "reflect".

This change is based on the corresponding x/sys change in CL 231177.

Fixes #37805
Updates #19367

Change-Id: I7a6d93ef8dd6e235bcab94e7c47270aad047af31
Reviewed-on: https://go-review.googlesource.com/c/go/+/231223
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-01 02:31:29 +00:00
Than McIntosh
f875f8fe76 [dev.link] cmd/link: tweaks to data alignment processing
Now that the loader's internal storage mechanism for symbol alignment
is array-based and not map-based, we can go back to computing symbol
alignment in the parallel-by-section section of dodata.

With this patch plus the previous one, this produces a small
kubelet speedup:

$ benchstat out.devlink.txt out.align.txt
name                        old time/op  new time/op  delta
RelinkKubelet                13.3s ± 2%   13.1s ± 2%  -1.27%  (p=0.000 n=20+20)
RelinkKubelet-WithoutDebug   7.36s ± 5%   7.14s ± 3%  -3.00%  (p=0.000 n=20+20)

Change-Id: I9eb0e8fea6aeb12f188f499e9031d5a3a23232c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/231221
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-01 01:51:18 +00:00
Than McIntosh
2f83d68926 [dev.link] cmd/link/internal/loader: change storage mechanism for sym alignment
Switch the storage mechanism for symbol alignment away from a map and
to a slice of uint8 values per symbol, where value K indicates
alignment 2^K. Intended to help speed up alignment get/set in dodata.

Change-Id: I26416e455c808f697dd0d7f6d2582247ee5c5b40
Reviewed-on: https://go-review.googlesource.com/c/go/+/231220
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-01 01:50:58 +00:00
Anton Kuklin
4c78d54fdd cmd: disable *.go domains lookup in go get command
Using 'go get x.go' instead of 'go build x.go' or some other
go command is a common mistake. By that mistake, a user gets
a misleading error message about unsuccessful `x.go` domain lookup.
This improvement handles such cases, by validating, whether the
argument hasn't specified version, has .go suffix, and either has
no slashes or such file locally exists. Handled both GOPATH
and GOMOD modes.

Fixes #38478

Change-Id: I583a4ef7f7ca8901deb07ebc811e2b3c0e828fa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/229938
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-30 22:06:07 +00:00
Gerrit Code Review
00753d5232 Merge "cmd: merge branch 'dev.link' into master" 2020-04-30 21:47:01 +00:00
Robert Griesemer
8740bdc5af strconv: fix for parseFloatPrefix
parseFloatPrefix accepts a string if it has a valid floating-point
number as prefix. Make sure that "infi", "infin", ... etc. are
accepted as valid numbers "inf" with suffix "i", "in", etc. This
is important for parsing complex numbers such as "0+infi".

This change does not affect the correctness of ParseFloat because
ParseFloat rejects strings that contain a suffix after a valid
floating-point number.

Updates #36771.

Change-Id: Ie1693a8ca2f8edf07b57688e0b35751b7100d39d
Reviewed-on: https://go-review.googlesource.com/c/go/+/231237
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-30 21:34:51 +00:00
Cherry Zhang
cdfff4d25a [dev.link] cmd/link: use more compact representation for external relocations
Currently, for external relocations, the ExtReloc structure
contains all the fields of the relocation. In fact, many of the
fields are the same with the original relocation. So, instead, we
can just use an index to reference the original relocation and
not expand the fields.

There is one place where we modify relocation type: changing
R_DWARFSECTREF to R_ADDR. Get away with it by changing
downstreams.

It also makes it easier to retrieve the reloc variant.

This reduces some allocation. Linking cmd/compile with external
linking,

name           old alloc/op   new alloc/op   delta
Reloc_GC         34.1MB ± 0%    22.7MB ± 0%  -33.30%  (p=0.000 n=5+4)

Change-Id: Id08a89ed2aee705296886d3b95014b806a0d55cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/231217
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 21:30:02 +00:00
Cherry Zhang
d0754cfe4a cmd: merge branch 'dev.link' into master
In the dev.link branch we continued developing the new object
file format support and the linker improvements described in
https://golang.org/s/better-linker . Since the last merge, more
progress has been made to improve the new linker.

This is a clean merge.

Change-Id: Ide5ad6fcec9cede99e9b21c4548929b4ba1f4185
2020-04-30 17:08:35 -04:00
Than McIntosh
ca290169ab [dev.link] cmd/link: performance changes for relocsym
Revise the signature for "relocsym" to reflect the fact that many of
its arguments are invariant: push the invariant args into a struct and
pass the struct by reference.

Add a facility for doing batch allocation of external relocations in
relocsym, so that we don't wind up with wasted space due to the
default "append" behavior.

This produces a small speedup in linking kubelet:

$ benchstat out.devlink.txt out.dodata.txt
name                        old time/op  new time/op  delta
RelinkKubelet                14.2s ± 2%   13.8s ± 2%  -3.11%  (p=0.000 n=19+19)
RelinkKubelet-WithoutDebug   8.02s ± 3%   7.73s ± 3%  -3.67%  (p=0.000 n=20+20)

Change-Id: I8bc94c366ae792a5b0f23697b8e0108443a7a748
Reviewed-on: https://go-review.googlesource.com/c/go/+/231138
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-30 21:04:11 +00:00
Michael Anthony Knyszek
0f8fecaba7 runtime: add scavenge -> traceBuf to lock partial order
Under the scavenge lock it's possible to ready a goroutine (or now
injectglist, which has mostly the same effect) which could cause an
unpark trace event to be emitted. If there's no active trace buffer for
the P, then we might acquire the lock. The total order between the two
is correct, but there's no partial order edge between them. Add in the
edge.

Change-Id: I3fc5d86a3b6bdd0b5648181fb76b5ebc90c3d69f
Reviewed-on: https://go-review.googlesource.com/c/go/+/231197
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-04-30 20:18:38 +00:00
Michael Anthony Knyszek
2491c5fd24 runtime: wake scavenger and update address on sweep done
This change modifies the semantics of waking the scavenger: rather than
wake on any update to pacing, wake when we know we will have work to do,
that is, when the sweeper is done. The current scavenger runs over the
address space just once per GC cycle, and we want to maximize the chance
that the scavenger observes the most attractive scavengable memory in
that pass (i.e. free memory with the highest address), so the timing is
important. By having the scavenger awaken and reset its search space
when the sweeper is done, we increase the chance that the scavenger will
observe the most attractive scavengable memory, because no more memory
will be freed that GC cycle (so the highest scavengable address should
now be available).

Furthermore, in applications that go idle, this means the background
scavenger will be awoken even if another GC doesn't happen, which isn't
true today.

However, we're unable to wake the scavenger directly from within the
sweeper; waking the scavenger involves modifying timers and readying
goroutines, the latter of which may trigger an allocation today (and the
sweeper may run during allocation!). Instead, we do the following:

1. Set a flag which is checked by sysmon. sysmon will clear the flag and
   wake the scavenger.
2. Wake the scavenger unconditionally at sweep termination.

The idea behind this policy is that it gets us close enough to the state
above without having to deal with the complexity of waking the scavenger
in deep parts of the runtime. If the application goes idle and sweeping
finishes (so we don't reach sweep termination), then sysmon will wake
the scavenger. sysmon has a worst-case 20 ms delay in responding to this
signal, which is probably fine if the application is completely idle
anyway, but if the application is actively allocating, then the
proportional sweeper should help ensure that sweeping ends very close to
sweep termination, so sweep termination is a perfectly reasonable time
to wake up the scavenger.

Updates #35788.

Change-Id: I84289b37816a7d595d803c72a71b7f5c59d47e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/207998
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-30 18:12:03 +00:00
Michael Anthony Knyszek
c7915376ce runtime: make the scavenger's pacing logic more defensive
This change adds two bits of logic to the scavenger's pacing. Firstly,
it checks to make sure we scavenged at least one physical page, if we
released a non-zero amount of memory. If we try to release less than one
physical page, most systems will release the whole page, which could
lead to memory corruption down the road, and this is a signal we're in
this situation.

Secondly, the scavenger's pacing logic now checks to see if the time a
scavenging operation takes is measured to be exactly zero or negative.
The exact zero case can happen if time update granularity is too large
to effectively capture the time the scavenging operation took, like on
Windows where the OS timer frequency is generally 1ms. The negative case
should not happen, but we're being defensive (against kernel bugs, bugs
in the runtime, etc.). If either of these cases happen, we fall back to
Go 1.13 behavior: assume the scavenge operation took around 10µs per
physical page. We ignore huge pages in this case because we're in
unknown territory, so we choose to be conservative about pacing (huge
pages could only increase the rate of scavenging).

Currently, the scavenger is broken on Windows because the granularity of
time measurement is around 1 ms, which is too coarse to measure how fast
we're scavenging, so we often end up with a scavenging time of zero,
followed by NaNs and garbage values in the pacing logic, which usually
leads to the scavenger sleeping forever.

Fixes #38617.

Change-Id: Iaaa2a4cbb21338e1258d010f7362ed58b7db1af7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229997
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-30 18:00:48 +00:00
Alberto Donizetti
666c9aedd4 cmd/compile: switch to typed auxint for arm64 TBZ/TBNZ block
This CL changes the arm64 TBZ/TBNZ block from using Aux to using
a (typed) AuxInt. The corresponding rules have also been changed
to be typed.

Passes

  GOARCH=arm64 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I98d0cd2a791948f1db13259c17fb1b9b2807a043
Reviewed-on: https://go-review.googlesource.com/c/go/+/230839
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-30 17:30:54 +00:00
Keith Randall
9ed0fb42e3 cmd/compile: add indexed memory modification ops to amd64
name            old time/op  new time/op  delta
Modify-16        404ns ± 1%   365ns ± 1%  -9.73%  (p=0.000 n=10+10)
ConstModify-16   407ns ± 0%   385ns ± 2%  -5.56%  (p=0.000 n=9+10)

Seems to generally help generated code.

Binary size change is in the noise.

Change-Id: I57891bfaf0f7dfc5d143bb9f7ebafc7079d2614f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228098
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-04-30 17:21:31 +00:00
Keith Randall
882ec701d2 cmd/compile: add indexed load+op operations to amd64
name        old time/op  new time/op  delta
LoadAdd-16   545ns ± 0%   456ns ± 0%  -16.31%  (p=0.000 n=10+10)

Update #36468

Change-Id: I84f390d55490648fa1f58cdbc24fd74c4f1bc8c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/227960
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-04-30 17:19:57 +00:00
Brad Fitzpatrick
553e003414 doc/go1.15: add 32-bit darwin removal and Resolver.LookupIP
Change-Id: I3a67908de9c85bcd39fb03c1b674caa9f817606b
Reviewed-on: https://go-review.googlesource.com/c/go/+/231117
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-04-30 16:40:38 +00:00
Cherry Zhang
1419445926 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: I9a30645ca0ceb52e45bc6b301f9f15f2f42998e8
2020-04-30 12:32:09 -04:00
Than McIntosh
404f626ee5 [dev.link] cmd/link: minor performance tweaks in dodata
Tweak doDataSect to reduce symbol sorting overhead, and calculate size
ahead of allocating the ctxt.datap slice. Yields a small speedup
(2-3%) linking kubelet.

Change-Id: I82869f5276caa4bee9f6e6f41da2b240e601ce50
Reviewed-on: https://go-review.googlesource.com/c/go/+/231047
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-30 16:16:30 +00:00
Cherry Zhang
2a00c137b1 [dev.link] cmd/link: fold zero symbol check into ResolveABIAlias
We call (or will call) ResolveABIAlias in many places. Doing zero
symbol check everytime is annoying. Fold the condition into
ResolveABIAlias.

Change-Id: I10485fe83b9cce2d19b6bd17dc42176f72dae48b
Reviewed-on: https://go-review.googlesource.com/c/go/+/231046
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 15:53:49 +00:00
Cherry Zhang
516c29a79f [dev.link] cmd/link: pass reloc by value to Adddynrel2
Adddynrel2 is a function pointer. In dynrelocsym we pass &r to
it, which will cause r to escape. Pass it by value instead.

Linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Dodata_GC        15.8MB ± 0%     5.9MB ± 0%  -62.55%  (p=0.008 n=5+5)

Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/231045
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 15:53:43 +00:00
Cherry Zhang
5aa59c6a99 [dev.link] cmd/link: unescape relocs passed to Archreloc2
Archreloc2 is a function pointer. It will escape its pointer
arguments. In relocsym, as we pass &r and &rr to Archreloc2, it
causes them to escape, even if Archreloc2 is not actually called.

Instead, pass r by value. loader.Reloc2 is a small structure
which is intended to be passed by value.

For rr, as Archreloc2 will likely return true, we speculatively
add it to extRelocs slice and use that space to pass to
Archreloc2.

Linking cmd/compile,

name              old alloc/op   new alloc/op   delta
Dwarfcompress_GC     110MB ± 0%      24MB ± 0%   -78.34%  (p=0.008 n=5+5)
Reloc_GC            24.6MB ± 0%     0.0MB ± 0%  -100.00%  (p=0.029 n=4+4)

Linking cmd/compile using external linking

name              old alloc/op   new alloc/op   delta
Reloc_GC             152MB ± 0%      36MB ± 0%   -76.07%  (p=0.008 n=5+5)

Change-Id: I1415479e0c17ea9787f9a62453dce00ad9ea792f
Reviewed-on: https://go-review.googlesource.com/c/go/+/231077
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 15:53:32 +00:00
Brad Fitzpatrick
ecdbffd4ec net/http/httputil: don't append to X-Forwarded-For in ReverseProxy when nil
Fixes #38079

Change-Id: Iac02d7f9574061bb26d1d9a41bb6ee6cc38934e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230937
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-30 14:41:10 +00:00
Ruixin Bao
1d9801223e cmd/compile: adopt strong aux typing for some s390x rules
Convert the remaining lowering rules to strongly-typed versions.

Passes toolstash-check.
Change-Id: I583786806d55376f5463addab8fec32cb59fa7a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/230939
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-30 13:46:20 +00:00
Alex Brainman
c76befe0f4 cmd/go: use -buildmode=pie as default on window
This change adjusts go command to pass -buildmode=pie to cmd/link,
if -buildmode is not explicitly provided.

Fixes #35192

Change-Id: Iec020131e676eb3e9a2df9eea1929b2af2b6df04
Reviewed-on: https://go-review.googlesource.com/c/go/+/230217
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-30 08:07:47 +00:00
Tobias Klauser
5c9a8c0761 lib/time, time/tzdata: update tz data to 2020a
Updates #22487

Change-Id: I691b4c8ced7bfb368f46ade0be46b2ab3f1820dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/230360
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-30 08:07:39 +00:00
Daniel Martí
b7e54d8d07 cmd/go: make 'mod verify' use multiple CPUs
'go mod verify' checksums one module zip at a time, which is
CPU-intensive on most modern machines with fast disks. As a result, one
can see a CPU bottleneck when running the command on, for example, a
module where 'go list -m all' lists ~440 modules:

	$ /usr/bin/time go mod verify
	all modules verified
	11.47user 0.77system 0:09.41elapsed 130%CPU (0avgtext+0avgdata 24284maxresident)k
	0inputs+0outputs (0major+4156minor)pagefaults 0swaps

Instead, verify up to GOMAXPROCS zips at once, which should line up
pretty well with the amount of processors we can use on a machine. The
results below are obtained via 'benchcmd -n 5 GoModVerify go mod verify'
on the same large module.

	name         old time/op         new time/op         delta
	GoModVerify          9.35s ± 1%          3.03s ± 2%  -67.60%  (p=0.008 n=5+5)

	name         old user-time/op    new user-time/op    delta
	GoModVerify          11.2s ± 1%          16.3s ± 3%  +45.38%  (p=0.008 n=5+5)

	name         old sys-time/op     new sys-time/op     delta
	GoModVerify          841ms ± 9%          865ms ± 8%     ~     (p=0.548 n=5+5)

	name         old peak-RSS-bytes  new peak-RSS-bytes  delta
	GoModVerify         27.8MB ±13%         50.7MB ±27%  +82.01%  (p=0.008 n=5+5)

The peak memory usage nearly doubles, and there is some extra overhead,
but it seems clearly worth the tradeoff given that we see a ~3x speedup
on my laptop with 4 physical cores. The vast majority of developer
machines nowadays should have 2-4 cores at least.

No test or benchmark is included; one can benchmark 'go mod verify'
directly, as I did above. The existing tests also cover correctness,
including any data races via -race.

Fixes #38623.

Change-Id: I45d8154687a6f3a6a9fb0e2b13da4190f321246c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229817
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-04-30 07:05:55 +00:00
Keyan Pishdadian
e87b0644db cmd/go: add error for cross-compiled -race builds
Race builds require C dependencies, but cross-compiled cgo builds are
not always possible, so don't suggest enabling CGO in those cases.

Fixes #37021

Change-Id: I1fd675efc9cef958a926bd63eac8e6858bc59d0a
GitHub-Last-Rev: cbf43c1bbb
GitHub-Pull-Request: golang/go#38670
Reviewed-on: https://go-review.googlesource.com/c/go/+/230202
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-04-30 04:02:34 +00:00
Rob Pike
41f6388e70 cmd/cover: include a package name in the HTML title
A recent change added a title to the HTML coverage report but
neglected to include the package name. Add the package name here.
It's a little trickier than you'd think because there may be multiple
packages and we don't want to parse the files, so we just extract
a directory name from the path of the first file.  This will almost
always be right, and has the advantage that it gives a better result
for package main. There are rare cases it will get wrong, but that
will be no hardship.

If this turns out not to be good enough, we can refine it.

Fixes #38609

Change-Id: I2201f6caef906e0b0258b90d7de518879041fe72
Reviewed-on: https://go-review.googlesource.com/c/go/+/230517
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-30 03:58:01 +00:00
Robert Griesemer
1d31f9b1e0 strconv: implement parseFloatPrefix returning no. of bytes consumed
parseFloatPrefix will make it easier to implement ParseComplex.

Verified that there's no relevant performance impact:
Benchmarks run on a "quiet" MacBook Pro, 3.3GHz Dual-Core Intel Core i7,
with 16GB 2133MHz LPDDR3 RAM running macOS 10.15.4.

name                  old time/op  new time/op  delta
Atof64Decimal-4       38.2ns ± 4%  38.4ns ± 3%    ~     (p=0.802 n=5+5)
Atof64Float-4         41.1ns ± 3%  43.0ns ± 1%  +4.77%  (p=0.008 n=5+5)
Atof64FloatExp-4      71.9ns ± 3%  70.1ns ± 1%    ~     (p=0.063 n=5+5)
Atof64Big-4            124ns ± 5%   119ns ± 0%    ~     (p=0.143 n=5+4)
Atof64RandomBits-4    57.2ns ± 1%  55.7ns ± 2%  -2.66%  (p=0.016 n=4+5)
Atof64RandomFloats-4  56.8ns ± 1%  56.9ns ± 4%    ~     (p=0.556 n=4+5)
Atof32Decimal-4       35.4ns ± 5%  35.9ns ± 0%    ~     (p=0.127 n=5+5)
Atof32Float-4         39.6ns ± 7%  40.3ns ± 1%    ~     (p=0.135 n=5+5)
Atof32FloatExp-4      73.7ns ± 7%  71.9ns ± 0%    ~     (p=0.175 n=5+4)
Atof32Random-4         103ns ± 6%    98ns ± 2%  -5.03%  (p=0.008 n=5+5)

Updates #36771.

Change-Id: I8ff66b582ae8b468d89c9ffc35c569c735cf0341
Reviewed-on: https://go-review.googlesource.com/c/go/+/230737
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-30 03:50:03 +00:00
Ian Lance Taylor
b255c12337 syscall: on linux-arm64, prefer prlimit to {g,s}etrlimit
Reportedly some Docker images accept the prlimit64 system call,
used by syscall.prlimit, but prohibit the getrlimit and setrlimit
system calls.

Fixes #38604

Change-Id: I91ff9370450b4869098cc8e335bbb7b863060508
Reviewed-on: https://go-review.googlesource.com/c/go/+/230339
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-04-30 03:32:25 +00:00
Cherry Zhang
d23cd597aa [dev.link] cmd/link: remove sym.Symbols.Newsym
No longer needed.

Change-Id: If259a956bc8edb2eb94583b06840b52344cb84be
Reviewed-on: https://go-review.googlesource.com/c/go/+/231037
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 03:11:13 +00:00
Cherry Zhang
4048fb8780 [dev.link] cmd/link: combine decodesym.go and decodesym2.go
And remove "2" from some function names.

Change-Id: Ibf1089970d849a42f53976064ceb9ade20bf6eba
Reviewed-on: https://go-review.googlesource.com/c/go/+/231017
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-30 03:11:04 +00:00
Ian Lance Taylor
769a1cf7b6 debug/gosym: correct comments for Table.{Files,Objs}
The fields aren't too useful for Go 1.2 and later, but they aren't
actually nil.

Fixes #38754

Change-Id: Ia13a224f623697a00dea8ba0225633e1b9308c9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/230940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-30 03:07:49 +00:00
Austin Clements
eda6fe3572 Revert "cmd/compile: omit file:pos for non-existent, permission errors"
This reverts commit 4f7053c87f.

Reason for revert: Newly added test is failing on several builders.

Change-Id: I22dcbfebf2f57735b2f479886bbeb623f95b132f
Reviewed-on: https://go-review.googlesource.com/c/go/+/231043
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-30 02:29:55 +00:00