1
0
mirror of https://github.com/golang/go synced 2024-11-17 11:04:53 -07:00
Commit Graph

58737 Commits

Author SHA1 Message Date
Alexander Yastrebov
11e9c8e6a1 internal/bytealg: use PCALIGN in memequal
goos: linux
goarch: amd64
pkg: bytes
cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
                                │    master     │                 HEAD                  │
                                │    sec/op     │    sec/op      vs base                │
Equal/0-8                         0.2800n ± 22%   0.2865n ± 26%        ~ (p=0.075 n=10)
Equal/1-8                          18.57n ±  2%    19.34n ±  6%   +4.15% (p=0.014 n=10)
Equal/6-8                          19.07n ±  1%    19.38n ±  2%   +1.63% (p=0.014 n=10)
Equal/9-8                          19.39n ±  2%    19.05n ±  1%   -1.78% (p=0.005 n=10)
Equal/15-8                         19.46n ±  1%    19.10n ±  1%   -1.85% (p=0.000 n=10)
Equal/16-8                         19.36n ±  2%    18.95n ±  1%   -2.09% (p=0.011 n=10)
Equal/20-8                         20.20n ±  1%    19.83n ±  1%   -1.86% (p=0.001 n=10)
Equal/32-8                         20.95n ±  1%    20.84n ±  1%   -0.57% (p=0.010 n=10)
Equal/4K-8                         97.40n ±  2%    81.34n ±  3%  -16.49% (p=0.000 n=10)
Equal/4M-8                         81.74µ ±  3%    71.52µ ±  4%  -12.49% (p=0.000 n=10)
Equal/64M-8                        1.319m ±  1%    1.139m ±  3%  -13.68% (p=0.000 n=10)
EqualBothUnaligned/64_0-8          8.707n ±  4%    8.588n ±  3%        ~ (p=0.353 n=10)
EqualBothUnaligned/64_1-8          8.513n ±  3%    8.614n ±  2%        ~ (p=0.481 n=10)
EqualBothUnaligned/64_4-8          8.752n ±  3%    8.637n ±  4%        ~ (p=0.148 n=10)
EqualBothUnaligned/64_7-8          8.742n ±  3%    8.514n ±  2%        ~ (p=0.052 n=10)
EqualBothUnaligned/4096_0-8        89.87n ±  3%    70.44n ±  5%  -21.63% (p=0.000 n=10)
EqualBothUnaligned/4096_1-8        91.67n ±  5%    70.89n ±  3%  -22.67% (p=0.000 n=10)
EqualBothUnaligned/4096_4-8        90.43n ±  2%    70.52n ±  3%  -22.01% (p=0.000 n=10)
EqualBothUnaligned/4096_7-8        89.53n ±  3%    72.02n ±  5%  -19.56% (p=0.000 n=10)
EqualBothUnaligned/4194304_0-8     86.43µ ±  3%    73.40µ ±  4%  -15.07% (p=0.000 n=10)
EqualBothUnaligned/4194304_1-8     85.48µ ±  2%    75.35µ ±  1%  -11.85% (p=0.000 n=10)
EqualBothUnaligned/4194304_4-8     86.51µ ±  3%    75.44µ ±  4%  -12.80% (p=0.000 n=10)
EqualBothUnaligned/4194304_7-8     86.40µ ±  3%    74.41µ ±  3%  -13.88% (p=0.000 n=10)
EqualBothUnaligned/67108864_0-8    1.374m ±  3%    1.171m ±  3%  -14.75% (p=0.000 n=10)
EqualBothUnaligned/67108864_1-8    1.401m ±  4%    1.198m ±  4%  -14.49% (p=0.000 n=10)
EqualBothUnaligned/67108864_4-8    1.393m ±  4%    1.205m ±  4%  -13.53% (p=0.000 n=10)
EqualBothUnaligned/67108864_7-8    1.396m ±  3%    1.199m ±  4%  -14.11% (p=0.000 n=10)
geomean                            735.7n          666.7n         -9.39%

                                │    master    │                 HEAD                 │
                                │     B/s      │     B/s       vs base                │
Equal/1-8                         51.36Mi ± 2%   49.32Mi ± 6%   -3.98% (p=0.015 n=10)
Equal/6-8                         300.0Mi ± 1%   295.3Mi ± 2%   -1.57% (p=0.011 n=10)
Equal/9-8                         442.5Mi ± 2%   450.6Mi ± 1%   +1.82% (p=0.005 n=10)
Equal/15-8                        734.9Mi ± 1%   748.8Mi ± 1%   +1.90% (p=0.000 n=10)
Equal/16-8                        788.4Mi ± 2%   805.2Mi ± 1%   +2.14% (p=0.011 n=10)
Equal/20-8                        944.2Mi ± 1%   961.8Mi ± 1%   +1.87% (p=0.002 n=10)
Equal/32-8                        1.422Gi ± 0%   1.430Gi ± 1%   +0.58% (p=0.011 n=10)
Equal/4K-8                        39.17Gi ± 2%   46.90Gi ± 3%  +19.74% (p=0.000 n=10)
Equal/4M-8                        47.79Gi ± 3%   54.62Gi ± 4%  +14.27% (p=0.000 n=10)
Equal/64M-8                       47.38Gi ± 1%   54.89Gi ± 3%  +15.85% (p=0.000 n=10)
EqualBothUnaligned/64_0-8         6.845Gi ± 4%   6.940Gi ± 3%        ~ (p=0.353 n=10)
EqualBothUnaligned/64_1-8         7.002Gi ± 3%   6.919Gi ± 2%        ~ (p=0.481 n=10)
EqualBothUnaligned/64_4-8         6.811Gi ± 3%   6.901Gi ± 4%        ~ (p=0.165 n=10)
EqualBothUnaligned/64_7-8         6.819Gi ± 3%   7.002Gi ± 2%        ~ (p=0.052 n=10)
EqualBothUnaligned/4096_0-8       42.45Gi ± 3%   54.16Gi ± 5%  +27.60% (p=0.000 n=10)
EqualBothUnaligned/4096_1-8       41.61Gi ± 6%   53.82Gi ± 3%  +29.33% (p=0.000 n=10)
EqualBothUnaligned/4096_4-8       42.19Gi ± 2%   54.09Gi ± 3%  +28.22% (p=0.000 n=10)
EqualBothUnaligned/4096_7-8       42.61Gi ± 3%   52.97Gi ± 5%  +24.33% (p=0.000 n=10)
EqualBothUnaligned/4194304_0-8    45.20Gi ± 3%   53.22Gi ± 4%  +17.75% (p=0.000 n=10)
EqualBothUnaligned/4194304_1-8    45.70Gi ± 2%   51.84Gi ± 1%  +13.43% (p=0.000 n=10)
EqualBothUnaligned/4194304_4-8    45.15Gi ± 3%   51.78Gi ± 4%  +14.68% (p=0.000 n=10)
EqualBothUnaligned/4194304_7-8    45.21Gi ± 3%   52.50Gi ± 4%  +16.12% (p=0.000 n=10)
EqualBothUnaligned/67108864_0-8   45.50Gi ± 3%   53.37Gi ± 3%  +17.30% (p=0.000 n=10)
EqualBothUnaligned/67108864_1-8   44.63Gi ± 4%   52.17Gi ± 4%  +16.89% (p=0.000 n=10)
EqualBothUnaligned/67108864_4-8   44.86Gi ± 4%   51.88Gi ± 4%  +15.65% (p=0.000 n=10)
EqualBothUnaligned/67108864_7-8   44.76Gi ± 3%   52.12Gi ± 4%  +16.43% (p=0.000 n=10)
geomean                           9.734Gi        10.79Gi       +10.88%

For #63678

Change-Id: I427b8756e361fd4d36984c2bdb8bc3661ac3a0b8
GitHub-Last-Rev: 981d272d17
GitHub-Pull-Request: golang/go#63757
Reviewed-on: https://go-review.googlesource.com/c/go/+/537995
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-11-17 16:34:40 +00:00
Jes Cok
7bf540012c log/slog: fix comments for *handleState.appendAttr
Change-Id: I8b9a6d177d297b9b1e890bf1d8a46a4b3311910f
GitHub-Last-Rev: 24067b8714
GitHub-Pull-Request: golang/go#64070
Reviewed-on: https://go-review.googlesource.com/c/go/+/541519
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
2023-11-17 16:28:15 +00:00
Max Riveiro
7bd08a49c2 runtime: optimize aeshashbody with PCALIGN in amd64
For #63678

goos: linux
goarch: amd64
pkg: runtime
cpu: AMD EPYC Processor
                       │  base.txt   │               16.txt                │
                       │   sec/op    │   sec/op     vs base                │
Hash5-2                  4.969n ± 1%   4.583n ± 1%  -7.75% (n=100)
Hash16-2                 4.966n ± 1%   4.536n ± 1%  -8.65% (n=100)
Hash64-2                 5.687n ± 1%   5.726n ± 1%       ~ (p=0.181 n=100)
Hash1024-2               26.73n ± 1%   25.72n ± 1%  -3.76% (n=100)
Hash65536-2              1.345µ ± 0%   1.331µ ± 0%  -1.04% (p=0.000 n=100)
HashStringSpeed-2        12.76n ± 1%   12.53n ± 1%  -1.76% (p=0.000 n=100)
HashBytesSpeed-2         20.13n ± 1%   19.96n ± 1%       ~ (p=0.176 n=100)
HashInt32Speed-2         9.065n ± 1%   9.007n ± 1%       ~ (p=0.247 n=100)
HashInt64Speed-2         9.076n ± 1%   9.027n ± 1%       ~ (p=0.179 n=100)
HashStringArraySpeed-2   33.33n ± 1%   32.94n ± 3%  -1.19% (p=0.028 n=100)
FastrandHashiter-2       16.47n ± 0%   16.54n ± 1%  +0.39% (p=0.013 n=100)
geomean                  17.85n        17.43n       -2.33%

            │   base.txt   │                16.txt                 │
            │     B/s      │      B/s       vs base                │
Hash5-2       959.7Mi ± 1%   1040.4Mi ± 1%  +8.41% (p=0.000 n=100)
Hash16-2      3.001Gi ± 1%    3.285Gi ± 1%  +9.48% (p=0.000 n=100)
Hash64-2      10.48Gi ± 1%    10.41Gi ± 1%       ~ (p=0.179 n=100)
Hash1024-2    35.68Gi ± 1%    37.08Gi ± 1%  +3.92% (p=0.000 n=100)
Hash65536-2   45.41Gi ± 0%    45.86Gi ± 0%  +1.01% (p=0.000 n=100)
geomean       8.626Gi         9.001Gi       +4.35%

Change-Id: Icf98dc935181ea5d30f7cbd5dcf284ec7aef8e9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/539976
Run-TryBot: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2023-11-17 16:27:46 +00:00
Tobias Klauser
66c22cdb84 runtime: remove unused _CTL_KERN on openbsd
This was supposed to be removed in CL 539155 already.

Change-Id: I22be1a72d5d8eb02514045609429e706c344d5fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/542915
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-17 16:19:52 +00:00
Jes Cok
c50e7ded1f log/slog: make hex a const
hex is in fact immutable, declare it as a const to avoid accidental
modification, also for consistency with other packages.

Change-Id: I88a6fed34d27ac57a0332dc7a27d3bf2ba0d6272
GitHub-Last-Rev: 08712be2d4
GitHub-Pull-Request: golang/go#64069
Reviewed-on: https://go-review.googlesource.com/c/go/+/541518
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-17 16:18:11 +00:00
Robert Griesemer
b34059032e go/types, types2: avoid type inference error if arguments are invalid
Fixes #60434.

Change-Id: I6eca4c508fa96fe81c4ee8a12b76c3de405fee7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/543176
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-17 15:47:08 +00:00
Jes Cok
8f7006a6df runtime: gofmt -w -s
Change-Id: I2eac85b502df9851df294f8d46c7845f635dde9b
GitHub-Last-Rev: 3c8382442a
GitHub-Pull-Request: golang/go#64198
Reviewed-on: https://go-review.googlesource.com/c/go/+/542697
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-11-17 15:33:38 +00:00
lotusirous
e41fb0fd1a slog: factoring out code to make the examples playable
For #61885

Change-Id: I5a0006fec2899dcbc989207174f438ecbfcc63ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/536215
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-17 14:56:30 +00:00
Cuong Manh Le
5b6d3dea87 cmd/compile: use internal/buildcfg for checking newinliner enable
internal/goexperiment reports what GOEXPERIMENT the compiler itself was
compiled with, not what experiment to use for the object code that the
compiler is compiling.

Fixes #64189

Change-Id: I892d78611f8c76376032fd7459e755380afafac6
Reviewed-on: https://go-review.googlesource.com/c/go/+/542995
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-17 12:45:41 +00:00
Bryan C. Mills
b9a08f159d cmd/go: propagate origin information for inexact module queries
Module queries for "@latest" and inexact constraints (like "@v1.3")
may consult information about tags and/or branches before finally
returning either a result or an error.

To correctly invalidate the origin information for the -reuse flag,
the reported Origin needs to reflect all of those inputs.

Fixes #61415.

Change-Id: I054acbef7d218a92a3bbb44517326385e458d907
Reviewed-on: https://go-review.googlesource.com/c/go/+/542717
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2023-11-16 22:15:45 +00:00
Rhys Hiltner
3e8000393e runtime: disable automatic GC for STW metric tests
A follow-up to https://go.dev/cl/534161 -- calls to runtime/trace.Start
and Stop synchronize with the GC, waiting for any in-progress mark phase
to complete. Disable automatic GCs to quiet the system, so we can
observe only the test's intentional pauses.

Change-Id: I6f8106c42528f9bda9afec1c151119783bbc78dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/543075
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 22:15:03 +00:00
Cherry Mui
3a9254636c runtime: print g pointer in crash stack dump
When debugging a runtime crash with a stack trace, sometimes we
have the g pointer in some places (e.g. as an argument of a
traceback function), but the g's goid in some other places (the
stack trace of that goroutine), which are usually not easy to
match up. This CL makes it print the g pointer. This is only
printed in crash mode, so it doesn't change the usual user stack
trace.

Change-Id: I19140855bf020a327ab0619b665ec1d1c70cca8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/541996
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 21:52:15 +00:00
Michael Pratt
1ab9df4849 cmd/compile: allow disable of PGO function value devirtualization with flag
Extend the pgodevirtualize debug flag to distinguish interface and
function devirtualization. Setting 1 keeps interface devirtualization
enabled but disables function value devirtualization.

For #64209.

Change-Id: I33aa7eb95ca0bdb215256d8c7cc8f9dac53ae30e
Reviewed-on: https://go-review.googlesource.com/c/go/+/543115
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 21:31:12 +00:00
Michael Pratt
3fd5c357a3 cmd/compile: don't devirtualize calls to runtime.memhash_varlen
runtime.memhash_varlen is defined as a normal function, but it is
actually a closure. All references are generated by
cmd/compile/internal/reflectdata.genhash, which creates a closure
containing the size of the type, which memhash_varlen accesses with
runtime.getclosureptr.

Since this doesn't look like a normal closure, ir.Func.OClosure is not
set, thus PGO function value devirtualization is willing to devirtualize
it, generating a call that completely ignores the closure context. This
causes memhash_varlen to either crash or generate incorrect results.

Skip this function, which is the only caller of getclosureptr.
Unfortunately there isn't a good way to detect these ineligible
functions more generally.

Fixes #64209.

Change-Id: Ibf509406667c6d4e5d431f10e5b1d1f926ecd7dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/543195
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 21:31:06 +00:00
Robert Griesemer
e62bf150cc go/types, types2: move exported predicates into separate file
This allows those functions to be generated for go/types.
Also, change the generator's renameIdent mechanism so that
it can rename multiple identifiers in one pass through the
AST instead of requiring multiple passes.

No type-checker functionality changes.

Change-Id: Ic78d899c6004b6a0692a95902fdc13f8ffb47824
Reviewed-on: https://go-review.googlesource.com/c/go/+/542757
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-11-16 20:54:25 +00:00
Davis Goodin
a95c5d37f2 cmd/link/internal/loadpe: fix xrels search "not found" detection
Fixes findHandlerInXDataAMD64 to handle the return value of sort.Search
when the search fails to find anything. Otherwise, the value may later
be used as an index, causing an out of range error.

Fixes #64200

Change-Id: I4f92e76b3f4d4d5dbe5cbc707f808298c580afe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/543076
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2023-11-16 20:37:59 +00:00
Than McIntosh
3f04f959d2 cmd/compile/internal/inline: refactor AnalyzeFunc
This patch reworks how inlheur.AnalyzeFunc is called by the top level
inliner. Up until this point the strategy was to analyze a function at
the point where CanInline is invoked on it, however it simplifies
things to instead make the call outside of CanInline (for example, so
that directly recursive functions can be analyzed).

Also as part of this patch, change things so that we no longer run
some of the more compile-time intensive analysis on functions that
haven't been marked inlinable (so as to safe compile time), and add a
teardown/cleanup hook in the inlheur package to be invoked by the
inliner when we're done inlining.

Change-Id: Id0772a285d891b0bed66dd86adaffa69d973c26a
Reviewed-on: https://go-review.googlesource.com/c/go/+/539318
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-16 20:15:25 +00:00
Than McIntosh
d21afcdf00 cmd/compile/internal/inline: refactor heuristics analyzers
This very minor refactoring changes the heuristics analysis code to
avoid running result-flag or param-flag analyzers on functions that
don't have any interesting results or parameters (so as to save a bit
of compile time). No change otherwise in heuristics functionality.

Change-Id: I7ee13f0499cc3d14d5638e2193e4bd8d7b690e5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/537976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-16 20:15:01 +00:00
Than McIntosh
322cd4e807 cmd/compile/internal/inline: refactor call site scoring
Rework the call site scoring process to relocate the code that looks
for interesting actual expressions at callsites (e.g. passing a
constant, passing a function pointer, etc) back into the original
callsite analysis phase, as opposed to trying to do the analysis at
scoring time. No changes to heuristics functionality; this doesn't
have much benefit here, but will make it easier later on (in a future
ptahc) to reduce ir.StaticValue calls.

Change-Id: I0e946f9589310a405951cb41835a819d38158e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/539317
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-16 20:07:59 +00:00
Than McIntosh
8d41d053e0 cmd/compile/internal/inline: debug flag to alter score adjustments
Add a debugging flag "-d=inlscoreadj" intended to support running
experiments in which the inliner uses different score adjustment
values for specific heuristics. The flag argument is a series of
clauses separated by the "/" char where each clause takes the form
"adjK:valK". For example, in this build

  go build -gcflags=-d=inlscoreadj=inLoopAdj:10/returnFeedsConstToIfAdj:-99

the "in loop" score adjustments would be reset to a value of 15 (effectively
penalizing calls in loops) adn the "return feeds constant to foldable if/switch"
score adjustment would be boosted from -15 to -99.

Change-Id: Ibd1ee334684af5992466556a69baa6dfefb246b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/532116
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 20:07:32 +00:00
Cherry Mui
6b43a172d8 runtime/race: update race syso files to support atomic And, Or
TSAN recently got support for Go's new atomic And and Or
operations (#61395). This CL updates the race syso files to
include the change. Also regenerate cgo dynamic imports on darwin.

OpenBSD/AMD64 is not updated, as TSAN no longer supports OpenBSD
(#52090).

Linux/PPC64 is not updated, as I'm running into some builder
issues. Still working on it.

For #61395.
For #62624.

Change-Id: Ifc90ea79284f29a356f9e8a5f144f6c690881395
Reviewed-on: https://go-review.googlesource.com/c/go/+/543035
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2023-11-16 19:29:22 +00:00
Cherry Mui
d573a8a8e8 internal/reflectlite: allow Value be stack allocated
Port CL 408826 and CL 413474 from reflect to internal/reflectlite.
It is a bit simpler as reflectlite has fewer methods.

Change-Id: I479199c8984afd35f42c3d8e764340184c17948f
Reviewed-on: https://go-review.googlesource.com/c/go/+/542976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2023-11-16 19:26:08 +00:00
Cherry Mui
0434ca9ce8 reflect: uncomment allocation test
We no longer force Value content to escape and the compiler's
escape analysis can handle it now.

Change-Id: I0628f3241e6ef37dce710c2394725e280790479a
Reviewed-on: https://go-review.googlesource.com/c/go/+/542975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2023-11-16 19:25:34 +00:00
Cherry Mui
23ca330095 reflect: remove go121noForceValueEscape
Before Go 1.21, ValueOf always escapes and a Value's content is
always heap allocated. In Go 1.21, we made it no longer always
escape, guarded by go121noForceValueEscape. This behavior has
been released for some time and there is no issue so far. We can
remove the guard now.

Change-Id: I81f5366412390f6c63b642f4c7c016da534da76a
Reviewed-on: https://go-review.googlesource.com/c/go/+/542795
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 19:25:24 +00:00
David Chase
c5e812234c cmd/compile: minor change to simplify addition of experimental CLs
Two different experimental CLs need this change, this makes them
more focused and easier to apply or combine.

Change-Id: Ic7b5536394af20d9038bf3cc0cf22891555c7fa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/542775
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-16 19:02:04 +00:00
David Chase
d411b3197c cmd/compile: add compiler debug flag to disable range func iterator checking
E.g.
`GOEXPERIMENT=rangefunc go test -v -gcflags=-d=rangefunccheck=0 rangefunc_test.go`
will turn off the checking and fail.

The benchmarks, which do not use pathological iterators, run slightly faster.

Change-Id: Ia3e175e86d67ef74bbae9bcc5d2def6a2cdf519d
Reviewed-on: https://go-review.googlesource.com/c/go/+/541995
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-16 17:32:05 +00:00
Michael Anthony Knyszek
d6ef98b8fa runtime: optimize bulkBarrierPreWrite with allocheaders
Currently bulkBarrierPreWrite follows a fairly slow path wherein it
calls typePointersOf, which ends up calling into fastForward. This does
some fairly heavy computation to move the iterator forward without any
assumptions about where it lands at all. It needs to be completely
general to support splitting at arbitrary boundaries, for example for
scanning oblets.

This means that copying objects during the GC mark phase is fairly
expensive, and is a regression from before allocheaders.

However, in almost all cases bulkBarrierPreWrite and
bulkBarrierPreWriteSrcOnly have perfect type information. We can do a
lot better in these cases because we're starting on a type-size
boundary, which is exactly what the iterator is built around.

This change adds the typePointersOfType method which produces a
typePointers iterator from a pointer and a type. This change
significantly improves the performance of these bulk write barriers,
eliminating some performance regressions that were noticed on the perf
dashboard.

There are still just a couple cases where we have to use the more
general typePointersOf calls, but they're fairly rare; most bulk
barriers have perfect type information.

This change is tested by the GCInfo tests in the runtime and the GCBits
tests in the reflect package via an additional check in getgcmask.

Results for tile38 before and after allocheaders. There was previous a
regression in the p90, now it's gone. Also, the overall win has been
boosted slightly.

tile38 $ benchstat noallocheaders.results allocheaders.results
name             old time/op            new time/op            delta
Tile38QueryLoad             481µs ± 1%             468µs ± 1%  -2.71%  (p=0.000 n=10+10)

name             old average-RSS-bytes  new average-RSS-bytes  delta
Tile38QueryLoad            6.32GB ± 1%            6.23GB ± 0%  -1.38%  (p=0.000 n=9+8)

name             old peak-RSS-bytes     new peak-RSS-bytes     delta
Tile38QueryLoad            6.49GB ± 1%            6.40GB ± 1%  -1.38%  (p=0.002 n=10+10)

name             old peak-VM-bytes      new peak-VM-bytes      delta
Tile38QueryLoad            7.72GB ± 1%            7.64GB ± 1%  -1.07%  (p=0.007 n=10+10)

name             old p50-latency-ns     new p50-latency-ns     delta
Tile38QueryLoad              212k ± 1%              205k ± 0%  -3.02%  (p=0.000 n=10+9)

name             old p90-latency-ns     new p90-latency-ns     delta
Tile38QueryLoad              622k ± 1%              616k ± 1%  -1.03%  (p=0.005 n=10+10)

name             old p99-latency-ns     new p99-latency-ns     delta
Tile38QueryLoad             4.55M ± 2%             4.39M ± 2%  -3.51%  (p=0.000 n=10+10)

name             old ops/s              new ops/s              delta
Tile38QueryLoad             12.5k ± 1%             12.8k ± 1%  +2.78%  (p=0.000 n=10+10)

Change-Id: I0a48f848eae8777d0fd6769c3a1fe449f8d9d0a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/542219
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 05:53:55 +00:00
Michael Anthony Knyszek
17eb0a2bac runtime: fix liveness issue in test-only getgcmask
getgcmask stops referencing the object passed to it sometime between
when the object is looked up and when the function returns. Notably,
this can happen while the GC mask is actively being produced, and thus
the GC might free the object.

This is easily reproducible by adding a runtime.GC call at just the
right place. Adding a KeepAlive on the heap-object path fixes it.

Fixes #64188.

Change-Id: I5ed4cae862fc780338b60d969fd7fbe896352ce4
Reviewed-on: https://go-review.googlesource.com/c/go/+/542716
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-16 05:48:17 +00:00
Michael Anthony Knyszek
0011342590 test: ignore MemProfileRecords with no live objects in finprofiled.go
This test erroneously assumes that there will always be at least one
live object accounted for in a MemProfileRecord. This is not true; all
memory allocated from a particular location could be dead.

Fixes #64153.

Change-Id: Iadb783ea9b247823439ddc74b62a4c8b2ce8e33e
Reviewed-on: https://go-review.googlesource.com/c/go/+/542736
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16 05:48:00 +00:00
Robert Griesemer
22278e3835 math/big: faster FloatPrec implementation
Based on observations by Cherry Mui (see comments in CL 539299).
Add new benchmark FloatPrecMixed.

For #50489.

name                         old time/op  new time/op  delta
FloatPrecExact/1-12           129ns ± 0%   105ns ±11%  -18.51%  (p=0.008 n=5+5)
FloatPrecExact/10-12          317ns ± 2%   283ns ± 1%  -10.65%  (p=0.008 n=5+5)
FloatPrecExact/100-12        1.80µs ±15%  1.35µs ± 0%  -25.09%  (p=0.008 n=5+5)
FloatPrecExact/1000-12       9.48µs ±14%  8.32µs ± 1%  -12.25%  (p=0.008 n=5+5)
FloatPrecExact/10000-12       195µs ± 1%   191µs ± 0%   -1.73%  (p=0.008 n=5+5)
FloatPrecExact/100000-12     7.31ms ± 1%  7.24ms ± 1%   -0.99%  (p=0.032 n=5+5)
FloatPrecExact/1000000-12     301ms ± 3%   302ms ± 2%     ~     (p=0.841 n=5+5)
FloatPrecMixed/1-12           141ns ± 0%   110ns ± 3%  -21.88%  (p=0.008 n=5+5)
FloatPrecMixed/10-12          767ns ± 0%   739ns ± 5%     ~     (p=0.151 n=5+5)
FloatPrecMixed/100-12        4.93µs ± 2%  3.73µs ± 1%  -24.33%  (p=0.008 n=5+5)
FloatPrecMixed/1000-12       90.9µs ±11%  70.3µs ± 2%  -22.66%  (p=0.008 n=5+5)
FloatPrecMixed/10000-12      2.30ms ± 0%  1.92ms ± 1%  -16.41%  (p=0.008 n=5+5)
FloatPrecMixed/100000-12     87.1ms ± 1%  68.5ms ± 1%  -21.42%  (p=0.008 n=5+5)
FloatPrecMixed/1000000-12     4.09s ± 1%   3.58s ± 1%  -12.35%  (p=0.008 n=5+5)
FloatPrecInexact/1-12        92.4ns ± 0%  66.1ns ± 5%  -28.41%  (p=0.008 n=5+5)
FloatPrecInexact/10-12        118ns ± 0%    91ns ± 1%  -23.14%  (p=0.016 n=5+4)
FloatPrecInexact/100-12       310ns ±10%   244ns ± 1%  -21.32%  (p=0.008 n=5+5)
FloatPrecInexact/1000-12      952ns ± 1%   828ns ± 1%  -12.96%  (p=0.016 n=4+5)
FloatPrecInexact/10000-12    6.71µs ± 1%  6.25µs ± 3%   -6.83%  (p=0.008 n=5+5)
FloatPrecInexact/100000-12   66.1µs ± 1%  61.2µs ± 1%   -7.45%  (p=0.008 n=5+5)
FloatPrecInexact/1000000-12   635µs ± 2%   584µs ± 1%   -7.97%  (p=0.008 n=5+5)

Change-Id: I3aa67b49a042814a3286ee8306fbed36709cbb6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/542756
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-11-15 22:16:34 +00:00
David Chase
2f5bd4e4f2 cmd/compile: extend profiling-per-package-into-directory to other profiling flags
Also allow specification of "directory" with a trailing
path separator on the name.  Updated suffix ".mprof" to ".memprof",
others are similarly disambiguated.

Change-Id: I2f3f44a436893730dbfe70b6815dff1e74885404
Reviewed-on: https://go-review.googlesource.com/c/go/+/542715
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-15 21:42:06 +00:00
David Chase
0ce94d79bc cmd/compile: modify -memprofile flag for multiple profiles in a directory
This permits collection of multiple profiles in a build
(instead of just the last compilation).  If a -memprofile
specifies an existing directory instead of a file, it will
create "<url.PathEscape(pkgpath)>.mprof" in that directory.

The PathEscaped package names are ugly, but this puts all
the files in a single directory with no risk of name clashs,
which simplies the usual case for using these files, which
is something like
```
go tool pprof profiles/*.mprof
```

Creating a directory tree mimicking the package structure
requires something along the lines of
```
go tool pprof `find profiles -name "*.mprof" -print`
```

In addition, this turns off "legacy format" because that
is only useful for a benchcompile, which does not use this
new feature (and people actually interested in memory
profiles probably prefer the new ones).

Change-Id: Ic1d9da53af22ecdda17663e0d4bce7cdbcb54527
Reviewed-on: https://go-review.googlesource.com/c/go/+/539316
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-11-15 20:36:24 +00:00
David Chase
2380862c7c cmd/compile: small inlining tweak for range-func panics
treat the panic, like a panic.  It helps with inlining,
and thus reduced closure allocation and performance, for
many examples of function range iterators.

Change-Id: Ib1a656cdfa56eb2dee400089c4c94ac14f1d2104
Reviewed-on: https://go-review.googlesource.com/c/go/+/541235
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-15 20:08:10 +00:00
David Chase
b5e31780b6 cmd/compile: check for iteration after range func loop exit
When this happens, panic.

This is a revised version of a check that used #next,
where this one instead uses a per-loop #exit flag,
and catches more problematic iterators.

Updates #56413.
Updates #61405.

Change-Id: I6574f754e475bb67b9236b4f6c25979089f9b629
Reviewed-on: https://go-review.googlesource.com/c/go/+/540263
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-15 20:07:46 +00:00
David Chase
6f5aba995f cmd/compile: replace magic numbers "2" and "1" with named constant
This was originally done for a #next-encoding-based check for
misbehaving loops, but it's a good idea anyhow because it makes
the code slightly easier to follow or change (we may decide to
check for errors the "other way" anyhow, later).

Change-Id: I2ba8f6e0f9146f0ff148a900eabdefd0fffebf8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/540261
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-15 20:06:34 +00:00
Damien Neil
fdc21f3eaf net/http: don't set length for non-range encoded content requests
Historically, serveContent has not set Content-Length
when the user provides Content-Encoding.

This causes broken responses when the user sets both Content-Length
and Content-Encoding, and the request is a range request,
because the returned data doesn't match the declared length.

CL 381956 fixed this case by changing serveContent to always set
a Content-Length header.

Unfortunately, I've discovered multiple cases in the wild of
users setting Content-Encoding: gzip and passing serveContent
a ResponseWriter wrapper that gzips the data written to it.

This breaks serveContent in a number of ways. In particular,
there's no way for it to respond to Range requests properly,
because it doesn't know the recipient's view of the content.

What the user should be doing in this case is just using
io.Copy to send the gzipped data to the response.
Or possibly setting Transfer-Encoding: gzip.
But whatever they should be doing, what they are doing has
mostly worked for non-Range requests, and setting
Content-Length makes it stop working because the length
of the file being served doesn't match the number of bytes
being sent.

So in the interests of not breaking users (even if they're
misusing serveContent in ways that are already broken),
partially revert CL 381956.

For non-Range requests, don't set Content-Length when
the user has set Content-Encoding. This matches our previous
behavior and causes minimal harm in cases where we could
have set Content-Length. (We will send using chunked
encoding rather than identity, but that's fine.)

For Range requests, set Content-Length unconditionally.
Either the user isn't mangling the data in the ResponseWriter,
in which case the length is correct, or they are, in which
case the response isn't going to contain the right bytes anyway.
(Note that a Range request for a Content-Length: gzip file
is requesting a range of *gzipped* bytes, not a range from
the uncompressed file.)

Change-Id: I5e788e6756f34cee520aa7c456826f462a59f7eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/542595
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-15 18:59:12 +00:00
Achille Roussel
8f262a2843 internal/cpu: detect support of AVX512
Extracts changes from that were submitted in other CLs to enable AVX512
detection, notably:
- https://go-review.googlesource.com/c/go/+/271521
- https://go-review.googlesource.com/c/go/+/379394
- https://go-review.googlesource.com/c/go/+/502476

This change adds properties to the cpu.X86 fields to enable runtime
detection of AVX512, and the hasAVX512F, hasAVX512BW, and hasAVX512VL
macros to support bypassing runtime checks in assembly code when
GOAMD64=v4 is set.

Change-Id: Ia7c3f22f1e66bf1de575aba522cb0d0a55ce791f
Reviewed-on: https://go-review.googlesource.com/c/go/+/536257
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Martin Möhrmann <martin@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
Commit-Queue: Martin Möhrmann <martin@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2023-11-15 18:30:03 +00:00
Michael Pratt
6ef98ac87c runtime/metrics: add STW stopping and total time metrics
This CL adds four new time histogram metrics:

/sched/pauses/stopping/gc:seconds
/sched/pauses/stopping/other:seconds
/sched/pauses/total/gc:seconds
/sched/pauses/total/other:seconds

The "stopping" metrics measure the time taken to start a stop-the-world
pause. i.e., how long it takes stopTheWorldWithSema to stop all Ps.
This can be used to detect STW struggling to preempt Ps.

The "total" metrics measure the total duration of a stop-the-world
pause, from starting to stop-the-world until the world is started again.
This includes the time spent in the "start" phase.

The "gc" metrics are used for GC-related STW pauses. The "other" metrics
are used for all other STW pauses.

All of these metrics start timing in stopTheWorldWithSema only after
successfully acquiring sched.lock, thus excluding lock contention on
sched.lock. The reasoning behind this is that while waiting on
sched.lock the world is not stopped at all (all other Ps can run), so
the impact of this contention is primarily limited to the goroutine
attempting to stop-the-world. Additionally, we already have some
visibility into sched.lock contention via contention profiles (#57071).

/sched/pauses/total/gc:seconds is conceptually equivalent to
/gc/pauses:seconds, so the latter is marked as deprecated and returns
the same histogram as the former.

In the implementation, there are a few minor differences:

* For both mark and sweep termination stops, /gc/pauses:seconds started
  timing prior to calling startTheWorldWithSema, thus including lock
  contention.

These details are minor enough, that I do not believe the slight change
in reporting will matter. For mark termination stops, moving timing stop
into startTheWorldWithSema does have the side effect of requiring moving
other GC metric calculations outside of the STW, as they depend on the
same end time.

Fixes #63340

Change-Id: Iacd0bab11bedab85d3dcfb982361413a7d9c0d05
Reviewed-on: https://go-review.googlesource.com/c/go/+/534161
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15 16:49:45 +00:00
Than McIntosh
a0df23888f cmd/compile/internal/inline: score call sites exposed by inlines
After performing an inline of function A into function B, collect up
any call sites in the inlined-body-of-A and add them to B's callsite
table, and apply scoring to those new sites.

Change-Id: I4bf563db04e33ba31fb4210f1e484a3cc83f0ee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/530579
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15 14:28:00 +00:00
Than McIntosh
15fa7a84b8 cmd/compile/internal/inline: rework call scoring for non-inlinable funcs
This patch fixes some problems with call site scoring, adds some new
tests, and moves more of the scoring-related code (for example, the
function "ScoreCalls") into "scoring.go". This also fixes some
problems with scoring of calls in non-inlinable functions (when new
inliner is turned on, scoring has to happen for all functions run
through the inliner, not just for inlinable functions). For such
functions, we build a table of inlinable call sites immediately prior
to scoring; the storage for this table is preserved between functions
so as to reduce allocations.

Change-Id: Ie6f691a3ad04fb7a03ab39f882a60aadaf957f6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/542217
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15 14:26:26 +00:00
Than McIntosh
d3d5173759 cmd/compile/internal/inline: fix buglet in panic path scoring
Fix a bug in scoring of calls appearing on panic paths. For this code
snippet:

  if x < 101 {
     foo()
     panic("bad")
  }

the function flags analyzer was correctly capturing the status of the
block corresponding to the true arm of the "if" statement, but wasn't
marking "foo()" as being on a panic path.

Change-Id: Iee13782828a1399028e2b560fed5f946850eb253
Reviewed-on: https://go-review.googlesource.com/c/go/+/542216
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15 14:23:20 +00:00
qiulaidongfeng
12051f7d95 reflect: optimize Value.IsZero for array types
For some types where the zero value is a value where all bits of this type are 0
optimize it

goos: windows
goarch: amd64
pkg: reflect
cpu: AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
                               │    std.txt    │               new.txt               │
                               │    sec/op     │   sec/op     vs base                │
IsZero/ArrayComparable-16          8.483n ± 0%   8.470n ± 2%        ~ (p=0.542 n=10)
IsZero/ArrayIncomparable-16        88.13n ± 1%   87.34n ± 2%        ~ (p=0.110 n=10)
IsZero/StructComparable-16         4.050n ± 2%   4.011n ± 1%        ~ (p=0.093 n=10)
IsZero/StructIncomparable-16       19.93n ± 1%   19.81n ± 1%        ~ (p=0.493 n=10)
IsZero/ArrayInt_4-16               4.445n ± 2%   4.478n ± 2%        ~ (p=0.306 n=10)
IsZero/ArrayInt_1024-16           3381.5n ± 3%   140.8n ± 1%  -95.84% (p=0.000 n=10)
IsZero/ArrayInt_1024_NoZero-16   1760.50n ± 3%   72.17n ± 1%  -95.90% (p=0.000 n=10)
IsZero/Struct4Int-16               4.495n ± 3%   4.478n ± 1%        ~ (p=0.579 n=10)
IsZero/ArrayStruct4Int_1024-16    1404.0n ± 3%   140.5n ± 0%  -90.00% (p=0.000 n=10)
IsZero/ArrayChanInt_1024-16       3437.0n ± 6%   140.5n ± 1%  -95.91% (p=0.000 n=10)
geomean                            89.94n        27.38n       -69.56%

Change-Id: I835231a79b9cd89686d44c5b8c2fbe629ccd98ba
GitHub-Last-Rev: 3abe118a10
GitHub-Pull-Request: golang/go#63661
Reviewed-on: https://go-review.googlesource.com/c/go/+/536855
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-11-15 04:10:05 +00:00
Park Zhou
b7cdc277e1 cmd/compile/internal/ir: fix doc
Signed-off-by: Park Zhou <ideapark@139.com>
Change-Id: I5e42ca6c714b9c1b50241c9d738db366bf1ca1fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/542175
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15 03:59:47 +00:00
Robert Griesemer
56c91c0502 go/types, types2: remove local version processing in favor of go/version
In the Checker, maintain a map of versions for each file, even if the
file doensn't specify a version. In that case, the version is the module
version.

If Info.FileVersions is set, use that map directly; otherwise allocate
a Checker-local map.

Introduce a new type, goVersion, which represents a Go language version.
This type effectively takes the role of the earlier version struct.
Replace all versions-related logic accordingly and use the go/version
package for version parsing/validation/comparison.

Added more tests.

Fixes #63974.

Change-Id: Ia05ff47a9eae0f0bb03c6b4cb65a7ce0a5857402
Reviewed-on: https://go-review.googlesource.com/c/go/+/541395
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-11-15 00:07:05 +00:00
Michael Anthony Knyszek
3073f3f941 runtime: prevent send on closed channel in wakeableSleep
Currently wakeableSleep has a race where, although stopTimer is called,
the timer could be queued already and fire *after* the wakeup channel is
closed.

Fix this by protecting wakeup with a lock used on the close and wake
paths and assigning the wakeup to nil on close. The wake path then
ignores a nil wakeup channel. This fixes the problem by ensuring that a
failure to stop the timer only results in the timer doing nothing,
rather than trying to send on a closed channel.

The addition of this lock requires some changes to the static lock
ranking system.

Thiere's also a second problem here: the timer could be delayed far
enough into the future that when it fires, it observes a non-nil wakeup
if the wakeableSleep has been re-initialized and reset.

Fix this problem too  by allocating the wakeableSleep on the heap and
creating a new one instead of reinitializing the old one. The GC will
make sure that the reference to the old one stays alive for the timer to
fire, but that timer firing won't cause a spurious wakeup in the new
one.

Change-Id: I2b979304e755c015d4466991f135396f6a271069
Reviewed-on: https://go-review.googlesource.com/c/go/+/542335
Reviewed-by: Michael Pratt <mpratt@google.com>
Commit-Queue: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2023-11-14 20:12:39 +00:00
Roland Shoemaker
67d555e089 crypto/tls: remove RSA KEX ciphers from the default list
Removes the RSA KEX based ciphers from the default list. This can be
reverted using the tlsrsakex GODEBUG.

Fixes #63413

Change-Id: Id221be3eb2f6c24b91039d380313f0c87d339f98
Reviewed-on: https://go-review.googlesource.com/c/go/+/541517
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-11-14 18:03:29 +00:00
Roland Shoemaker
362bf4fc6d crypto/tls: change default minimum version to 1.2
Updates the default from 1.0 -> 1.2 for servers, bringing it in line
with clients. Add a GODEBUG setting, tls10server, which lets users
revert this change.

Fixes #62459

Change-Id: I2b82f85b1c2d527df1f9afefae4ab30a8f0ceb41
Reviewed-on: https://go-review.googlesource.com/c/go/+/541516
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-11-14 18:03:20 +00:00
Ezzno J
e7d582b55d runtime: remove useless nil checking during init of itab
Change-Id: I8ef12221e18e163b695d88f4bb8c309763341ec3
GitHub-Last-Rev: d3d4d4cb79
GitHub-Pull-Request: golang/go#64107
Reviewed-on: https://go-review.googlesource.com/c/go/+/542116
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-11-14 17:15:12 +00:00
Deleplace
e21dc702d5 slices: zero the slice elements discarded by Delete, DeleteFunc, Compact, CompactFunc, Replace.
To avoid memory leaks in slices that contain pointers, clear the elements between the new length and the original length.

Fixes #63393

Change-Id: Ic65709726f4479d70c6bce14aa367feb753d41da
Reviewed-on: https://go-review.googlesource.com/c/go/+/541477
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-11-14 17:12:38 +00:00
Robert Griesemer
e14b96cb51 math/big: update comment in the implementation of FloatPrec
Follow-up on CL 539299: missed to incorporate the updated
comment per feedback on that CL.

For #50489.

Change-Id: Ib035400038b1d11532f62055b5cdb382ab75654c
Reviewed-on: https://go-review.googlesource.com/c/go/+/542115
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-14 16:45:59 +00:00