]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 months agocrypto/tls: add WrapSession and UnwrapSession
Filippo Valsorda [Mon, 22 May 2023 08:49:07 +0000 (10:49 +0200)]
crypto/tls: add WrapSession and UnwrapSession

There was a bug in TestResumption: the first ExpiredSessionTicket was
inserting a ticket far in the future, so the second ExpiredSessionTicket
wasn't actually supposed to fail. However, there was a bug in
checkForResumption->sendSessionTicket, too: if a session was not resumed
because it was too old, its createdAt was still persisted in the next
ticket. The two bugs used to cancel each other out.

For #60105
Fixes #19199

Change-Id: Ic9b2aab943dcbf0de62b8758a6195319dc286e2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496821
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
12 months agocrypto/tls: add ClientSessionState.ResumptionState and NewResumptionState
Filippo Valsorda [Sun, 21 May 2023 19:27:48 +0000 (21:27 +0200)]
crypto/tls: add ClientSessionState.ResumptionState and NewResumptionState

For #60105
Fixes #25351

Change-Id: Iffd658f2663cfc47b48157824226ed6c0260a59e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496820
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
12 months agocrypto/tls: use SessionState on the client side
Filippo Valsorda [Sun, 21 May 2023 19:17:56 +0000 (21:17 +0200)]
crypto/tls: use SessionState on the client side

Another internal change, that allows exposing the new APIs easily in
following CLs.

For #60105

Change-Id: I9c61b9f6e9d29af633f952444f514bcbbe82fe4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496819
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: add SessionState and use it on the server side
Filippo Valsorda [Sat, 20 May 2023 15:49:21 +0000 (17:49 +0200)]
crypto/tls: add SessionState and use it on the server side

This change by itself is useless, because the application has no way to
access or provide SessionStates to crypto/tls, but they will be provided
in following CLs.

For #60105

Change-Id: I8d5de79b1eda0a778420134cf6f346246a1bb296
Reviewed-on: https://go-review.googlesource.com/c/go/+/496818
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: reduce session ticket linkability
Filippo Valsorda [Fri, 19 May 2023 21:28:43 +0000 (23:28 +0200)]
crypto/tls: reduce session ticket linkability

Ever since session ticket key rotation was introduced in CL 9072, we've
been including a prefix in every ticket to identify what key it's
encrypted with. It's a small privacy gain, but the cost of trial
decryptions is also small, especially since the first key is probably
the most frequently used.

Also reissue tickets on every resumption so that the next connection
can't be linked to all the previous ones. Again the privacy gain is
small but the performance cost is small and it comes with a reduction in
complexity.

For #60105

Change-Id: I852f297162d2b79a3d9bf61f6171e8ce94b2537a
Reviewed-on: https://go-review.googlesource.com/c/go/+/496817
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocompress/flate, archive/zip: reduce memory allocations
Maksim Meshkov [Wed, 24 May 2023 21:18:15 +0000 (21:18 +0000)]
compress/flate, archive/zip: reduce memory allocations

The existing implementation allocates a new 4KB buffer each time it opens flate-encoded file in a zip archive. This commit allows the flate reader to reuse the buffer on call Reset instead of allocating a new one.

It is noticeable when a zip archive contains a huge amount of files, e.g. zip archive has 50_000 files, for each file 4KB buffer is allocated, so it is 200MB memory allocations. If files are read sequentially only one buffer is needed.

Fixes #59774

Change-Id: Ib16336b101ba58e8f0f30a45dc5fd4eeebc801a1
GitHub-Last-Rev: f3f395b2ad95b7ad7ce9df6f5e49c7b6a0627627
GitHub-Pull-Request: golang/go#59775
Reviewed-on: https://go-review.googlesource.com/c/go/+/487675
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agogo/types: set correct Pos for T in struct{p.T}
Alan Donovan [Wed, 24 May 2023 18:16:38 +0000 (14:16 -0400)]
go/types: set correct Pos for T in struct{p.T}

Previously, the field Var for T created for struct{p.T}
would use the Pos of the ast.Field, which coincides with p.
This change makes it use the Pos of T.

Errors about the field type are still reported at the
position of the ast.Field (e.g. *p.T) not the field T.

Fixes #60372

Change-Id: I06000874f2018d47159493626da3d16e6716f4c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/497882
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>

12 months agocmd/compile: Use XORL and X15 for zeroing in ggen's zerorange on AMD64
Jakub Ciolek [Sun, 27 Nov 2022 15:36:35 +0000 (16:36 +0100)]
cmd/compile: Use XORL and X15 for zeroing in ggen's zerorange on AMD64

Prefer a SSE store from X15 over XORL REG REG -> MOVQ.

Use XORL REG, REG to setup 0 for REP STOS.

Remove the nacl related block.

Intel Alder Lake 12600k (Linux):

name                      old time/op    new time/op    delta
BinaryTree17-16              1.52s ± 1%     1.52s ± 1%    ~
(p=0.932 n=12+12)
Fannkuch11-16                1.40s ± 0%     1.46s ± 0%  +4.12%
(p=0.000 n=12+11)
FmtFprintfEmpty-16          13.0ns ± 1%    13.2ns ± 1%  +1.37%
(p=0.000 n=11+12)
FmtFprintfString-16         24.0ns ± 1%    23.2ns ± 1%  -3.53%
(p=0.000 n=12+11)
FmtFprintfInt-16            27.6ns ± 1%    25.5ns ± 1%  -7.53%
(p=0.000 n=12+12)
FmtFprintfIntInt-16         43.1ns ± 1%    41.4ns ± 1%  -4.00%
(p=0.000 n=12+12)
FmtFprintfPrefixedInt-16    56.8ns ± 0%    54.8ns ± 1%  -3.49%
(p=0.000 n=11+12)
FmtFprintfFloat-16          59.0ns ± 0%    59.7ns ± 1%  +1.11%
(p=0.000 n=12+12)
FmtManyArgs-16               159ns ± 1%     160ns ± 1%    ~
(p=0.070 n=12+12)
GobDecode-16                2.37ms ± 2%    2.39ms ± 1%    ~
(p=0.059 n=12+11)
GobEncode-16                1.99ms ± 2%    2.00ms ± 2%    ~
(p=0.291 n=12+12)
Gzip-16                     98.7ms ± 1%    99.2ms ± 0%  +0.51%
(p=0.024 n=12+12)
Gunzip-16                   13.4ms ± 0%    13.5ms ± 0%  +0.20%
(p=0.001 n=11+12)
HTTPClientServer-16         27.0µs ± 6%    26.5µs ± 4%    ~
(p=0.266 n=12+12)
JSONEncode-16               3.41ms ± 5%    3.44ms ± 2%    ~
(p=0.291 n=12+12)
JSONDecode-16               16.6ms ± 1%    16.6ms ± 2%    ~
(p=0.872 n=10+12)
Mandelbrot200-16            1.78ms ± 0%    1.78ms ± 0%    ~
(p=0.514 n=12+12)
GoParse-16                  1.59ms ± 2%    1.57ms ± 2%  -0.82%
(p=0.016 n=12+11)
RegexpMatchEasy0_32-16      21.5ns ± 1%    21.3ns ± 0%  -1.10%
(p=0.000 n=12+12)
RegexpMatchEasy0_1K-16      71.0ns ± 0%    69.9ns ± 0%  -1.58%
(p=0.000 n=11+11)
RegexpMatchEasy1_32-16      18.0ns ± 1%    17.3ns ± 0%  -3.38%
(p=0.000 n=12+12)
RegexpMatchEasy1_1K-16      97.8ns ± 0%    97.2ns ± 1%  -0.56%
(p=0.001 n=10+10)
RegexpMatchMedium_32-16      269ns ± 0%     270ns ± 2%    ~
(p=0.241 n=11+12)
RegexpMatchMedium_1K-16     11.4µs ± 0%    11.3µs ± 1%  -0.69%
(p=0.000 n=11+12)
RegexpMatchHard_32-16        522ns ± 0%     522ns ± 1%    ~
(p=0.811 n=12+12)
RegexpMatchHard_1K-16       15.1µs ± 2%    14.8µs ± 0%  -2.17%
(p=0.000 n=12+12)
Revcomp-16                   194ms ± 1%     195ms ± 2%    ~
(p=0.059 n=11+12)
Template-16                 22.0ms ± 2%    21.5ms ± 2%  -2.11%
(p=0.001 n=12+12)
TimeParse-16                97.3ns ± 1%    97.2ns ± 0%    ~
(p=0.217 n=11+12)
TimeFormat-16               98.2ns ± 2%    97.1ns ± 2%    ~
(p=0.101 n=12+12)
[Geo mean]                  17.7µs         17.6µs       -0.77%

name                      old speed      new speed      delta
GobDecode-16               324MB/s ± 2%   322MB/s ± 1%    ~
(p=0.058 n=12+11)
GobEncode-16               385MB/s ± 2%   383MB/s ± 2%    ~
(p=0.291 n=12+12)
Gzip-16                    197MB/s ± 1%   196MB/s ± 0%  -0.51%
(p=0.023 n=12+12)
Gunzip-16                 1.44GB/s ± 0%  1.44GB/s ± 0%  -0.20%
(p=0.001 n=11+12)
JSONEncode-16              570MB/s ± 5%   565MB/s ± 2%    ~
(p=0.291 n=12+12)
JSONDecode-16              117MB/s ± 1%   117MB/s ± 2%    ~
(p=0.885 n=10+12)
GoParse-16                36.5MB/s ± 2%  36.8MB/s ± 2%  +0.83%
(p=0.018 n=12+11)
RegexpMatchEasy0_32-16    1.49GB/s ± 1%  1.50GB/s ± 0%  +1.12%
(p=0.000 n=12+12)
RegexpMatchEasy0_1K-16    14.4GB/s ± 0%  14.6GB/s ± 0%  +1.61%
(p=0.000 n=11+11)
RegexpMatchEasy1_32-16    1.78GB/s ± 1%  1.84GB/s ± 0%  +3.50%
(p=0.000 n=12+12)
RegexpMatchEasy1_1K-16    10.5GB/s ± 0%  10.5GB/s ± 1%  +0.57%
(p=0.001 n=10+10)
RegexpMatchMedium_32-16    119MB/s ± 0%   119MB/s ± 2%    ~
(p=0.235 n=11+12)
RegexpMatchMedium_1K-16   90.1MB/s ± 0%  90.8MB/s ± 1%  +0.69%
(p=0.000 n=11+12)
RegexpMatchHard_32-16     61.3MB/s ± 0%  61.3MB/s ± 1%    ~
(p=0.765 n=12+12)
RegexpMatchHard_1K-16     67.6MB/s ± 2%  69.1MB/s ± 0%  +2.20%
(p=0.000 n=12+12)
Revcomp-16                1.31GB/s ± 1%  1.30GB/s ± 2%    ~
(p=0.059 n=11+12)
Template-16               88.3MB/s ± 2%  90.2MB/s ± 2%  +2.16%
(p=0.001 n=12+12)
[Geo mean]                 401MB/s        403MB/s       +0.49%

file                                                        before   after    Δ       %
runtime.s                                                   512467   512447   -20     -0.004%
sync.s                                                      16219    16197    -22     -0.136%
internal/singleflight.s                                     2617     2616     -1      -0.038%
internal/testlog.s                                          2157     2152     -5      -0.232%
io.s                                                        18992    18980    -12     -0.063%
text/tabwriter.s                                            8952     8913     -39     -0.436%
syscall.s                                                   85241    85220    -21     -0.025%
go/build/constraint.s                                       12763    12741    -22     -0.172%
time.s                                                      100682   100672   -10     -0.010%
context.s                                                   12316    12305    -11     -0.089%
internal/poll.s                                             45297    45114    -183    -0.404%
io/fs.s                                                     16767    16763    -4      -0.024%
crypto/hmac.s                                               2546     2537     -9      -0.353%
os.s                                                        53983    53964    -19     -0.035%
os/exec.s                                                   25723    25710    -13     -0.051%
os/user.s                                                   12166    12133    -33     -0.271%
debug/gosym.s                                               36980    36948    -32     -0.087%
database/sql.s                                              90990    90863    -127    -0.140%
archive/zip.s                                               52485    52481    -4      -0.008%
debug/dwarf.s                                               117251   117219   -32     -0.027%
encoding/json.s                                             95637    95579    -58     -0.061%
net.s                                                       278084   278056   -28     -0.010%
log.s                                                       12153    12121    -32     -0.263%
vendor/golang.org/x/net/http2/hpack.s                       22562    22552    -10     -0.044%
mime.s                                                      32872    32851    -21     -0.064%
vendor/golang.org/x/crypto/cryptobyte.s                     32035    32024    -11     -0.034%
go/token.s                                                  13689    13645    -44     -0.321%
image/gif.s                                                 22700    22668    -32     -0.141%
text/template/parse.s                                       81696    81683    -13     -0.016%
image/png.s                                                 37704    37692    -12     -0.032%
go/ast.s                                                    63753    63751    -2      -0.003%
internal/dag.s                                              13123    13122    -1      -0.008%
crypto/x509.s                                               137641   137635   -6      -0.004%
text/template.s                                             106615   106592   -23     -0.022%
os/signal.s                                                 7658     7651     -7      -0.091%
go/printer.s                                                90393    90384    -9      -0.010%
runtime/trace.s                                             2844     2819     -25     -0.879%
go/parser.s                                                 111432   111144   -288    -0.258%
html/template.s                                             91633    91619    -14     -0.015%
log/syslog.s                                                6612     6593     -19     -0.287%
net/internal/socktest.s                                     15715    15684    -31     -0.197%
runtime/pprof.s                                             70273    70177    -96     -0.137%
crypto/tls.s                                                288762   288684   -78     -0.027%
testing.s                                                   112376   112300   -76     -0.068%
internal/fuzz.s                                             89544    89535    -9      -0.010%
net/smtp.s                                                  11357    11325    -32     -0.282%
vendor/golang.org/x/net/nettest.s                           27449    27361    -88     -0.321%
testing/internal/testdeps.s                                 6384     6369     -15     -0.235%
go/types.s                                                  484464   484324   -140    -0.029%
cmd/internal/buildid.s                                      17646    17625    -21     -0.119%
go/internal/gccgoimporter.s                                 44931    44920    -11     -0.024%
go/internal/srcimporter.s                                   9989     9983     -6      -0.060%
cmd/api.s                                                   35098    35075    -23     -0.066%
net/http.s                                                  551134   550680   -454    -0.082%
cmd/internal/obj.s                                          121795   121750   -45     -0.037%
cmd/compile/internal/syntax.s                               170092   170075   -17     -0.010%
expvar.s                                                    8959     8945     -14     -0.156%
net/http/httptest.s                                         16201    16198    -3      -0.019%
net/http/httputil.s                                         44379    44339    -40     -0.090%
net/http/fcgi.s                                             18105    18099    -6      -0.033%
cmd/compile/internal/logopt.s                               9916     9905     -11     -0.111%
cmd/vendor/golang.org/x/tools/cover.s                       9722     9720     -2      -0.021%
cmd/compile/internal/base.s                                 38986    38982    -4      -0.010%
cmd/covdata.s                                               39190    39182    -8      -0.020%
cmd/go/internal/fsys.s                                      17948    17938    -10     -0.056%
cmd/dist.s                                                  169725   169616   -109    -0.064%
cmd/compile/internal/types.s                                74666    74639    -27     -0.036%
cmd/go/internal/par.s                                       4517     4516     -1      -0.022%
cmd/go/internal/lockedfile.s                                22412    22410    -2      -0.009%
cmd/compile/internal/types2.s                               476715   476596   -119    -0.025%
cmd/go/internal/trace.s                                     4888     4877     -11     -0.225%
cmd/vendor/golang.org/x/mod/module.s                        20445    20415    -30     -0.147%
cmd/vendor/golang.org/x/mod/sumdb/dirhash.s                 3596     3587     -9      -0.250%
cmd/go/internal/cache.s                                     23871    23839    -32     -0.134%
cmd/vendor/golang.org/x/mod/zip.s                           36602    36567    -35     -0.096%
cmd/vendor/golang.org/x/mod/sumdb.s                         27669    27552    -117    -0.423%
cmd/compile/internal/ir.s                                   253597   253590   -7      -0.003%
cmd/go/internal/vcs.s                                       45027    45025    -2      -0.004%
cmd/go/internal/modfetch/codehost.s                         80672    80583    -89     -0.110%
cmd/go/internal/modindex.s                                  79273    79271    -2      -0.003%
cmd/go/internal/modconv.s                                   14793    14792    -1      -0.007%
cmd/gofmt.s                                                 29600    29587    -13     -0.044%
cmd/go/internal/modfetch.s                                  111067   111017   -50     -0.045%
cmd/go/internal/vcweb.s                                     37882    37872    -10     -0.026%
cmd/compile/internal/typecheck.s                            319852   319834   -18     -0.006%
cmd/vendor/golang.org/x/term.s                              24398    24338    -60     -0.246%
cmd/vendor/github.com/google/pprof/profile.s                149107   149103   -4      -0.003%
cmd/go/internal/modload.s                                   275078   275020   -58     -0.021%
cmd/vendor/github.com/ianlancetaylor/demangle.s             264051   264013   -38     -0.014%
cmd/compile/internal/staticdata.s                           14019    14011    -8      -0.057%
cmd/go/internal/modcmd.s                                    47591    47582    -9      -0.019%
cmd/vendor/github.com/google/pprof/internal/binutils.s      37978    37926    -52     -0.137%
cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag.s 6880     6864     -16     -0.233%
cmd/go/internal/work.s                                      287700   287637   -63     -0.022%
cmd/vendor/github.com/google/pprof/internal/symbolizer.s    10171    10138    -33     -0.324%
cmd/go/internal/modget.s                                    58314    58250    -64     -0.110%
cmd/go/internal/test.s                                      52538    52534    -4      -0.008%
cmd/trace.s                                                 100245   100242   -3      -0.003%
cmd/vendor/golang.org/x/tools/go/ast/astutil.s              50731    50724    -7      -0.014%
cmd/vendor/golang.org/x/tools/internal/facts.s              13018    13011    -7      -0.054%
cmd/link/internal/ld.s                                      562438   562377   -61     -0.011%
cmd/vendor/github.com/google/pprof/internal/driver.s        148389   148338   -51     -0.034%
cmd/compile/internal/ssa.s                                  3639799  3639727  -72     -0.002%
cmd/compile/internal/ssagen.s                               359076   359028   -48     -0.013%
cmd/compile/internal/amd64.s                                31084    30582    -502    -1.615%
cmd/compile/internal/noder.s                                407972   407949   -23     -0.006%
cmd/compile/internal/gc.s                                   20101    20069    -32     -0.159%
total                                                       20771294 20766881 -4413   -0.021%

Change-Id: I2a4b01449e94906fa1ed3fb96a790977466368d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/453536
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
12 months agocrypto/tls: support QUIC as a transport
Damien Neil [Fri, 14 Oct 2022 17:48:42 +0000 (10:48 -0700)]
crypto/tls: support QUIC as a transport

Add a QUICConn type for use by QUIC implementations.

A QUICConn provides unencrypted handshake bytes and connection
secrets to the QUIC layer, and receives handshake bytes.

For #44886

Change-Id: I859dda4cc6d466a1df2fb863a69d3a2a069110d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/493655
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
12 months agonet/http: second do not force the Content-Length header if nilled
Jorropo [Tue, 16 May 2023 07:19:58 +0000 (09:19 +0200)]
net/http: second do not force the Content-Length header if nilled

This is a second round of CL 469095 which has been fixed after
the issue discovered in the revert CL 495017.

The issue was a missing res.Body.Close() in the newly added test.

Change-Id: Ifd9d8458022e59f4486397443a2862d06383e990
Reviewed-on: https://go-review.googlesource.com/c/go/+/495115
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Jorropo <jorropo.pgm@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agoos: add dirFs.ReadDir to implement fs.ReadDirFS for DirFS
Tobias Klauser [Wed, 24 May 2023 17:49:24 +0000 (19:49 +0200)]
os: add dirFs.ReadDir to implement fs.ReadDirFS for DirFS

Follow CL 416775 which added dirFs.ReadFile.

Fixes #53761

Change-Id: Iec19a815ab7c37a3206be141518cc587a588de20
Reviewed-on: https://go-review.googlesource.com/c/go/+/498015
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

12 months agonet: root the nodata test domain to avoid search domains
Mateusz Poliwczak [Mon, 15 May 2023 09:33:40 +0000 (09:33 +0000)]
net: root the nodata test domain to avoid search domains

I came across similar issue in CL 455275.
Without rooting this, the search domains might affect
the query, so the test might not prove the right thing.
The search domain will cause a change from no data
to NXDOMAIN error.

Change-Id: I59f4de2635f03c69adf29b74e25e4ebd71e7413b
GitHub-Last-Rev: 3a086c74f1453e4d1f2e88631ac835389984da17
GitHub-Pull-Request: golang/go#60197
Reviewed-on: https://go-review.googlesource.com/c/go/+/494896
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agocrypto/rsa,crypto/internal/bigmod: optimized short exponentiations
Filippo Valsorda [Fri, 5 May 2023 09:29:39 +0000 (11:29 +0200)]
crypto/rsa,crypto/internal/bigmod: optimized short exponentiations

RSA encryption and verification performs an exponentiation by a value
usually just a few bits long. The current strategy with table
precomputation is not efficient.

Add an ExpShort bigmod method, and use it in RSA public key operations.

After this, almost all CPU time in encryption/verification is spent
preparing the constants for the modulus, because PublicKey doesn't have
a Precompute function.

This speeds up signing a bit too, because it performs a verification to
protect against faults.

name                    old time/op  new time/op  delta
DecryptPKCS1v15/2048-4  1.13ms ± 0%  1.13ms ± 0%   -0.43%  (p=0.000 n=8+9)
DecryptPKCS1v15/3072-4  3.20ms ± 0%  3.15ms ± 0%   -1.59%  (p=0.000 n=10+8)
DecryptPKCS1v15/4096-4  6.45ms ± 0%  6.42ms ± 0%   -0.49%  (p=0.000 n=10+10)
EncryptPKCS1v15/2048-4   132µs ± 0%   108µs ± 0%  -17.99%  (p=0.000 n=10+10)
DecryptOAEP/2048-4      1.13ms ± 0%  1.14ms ± 0%   +0.91%  (p=0.000 n=10+10)
EncryptOAEP/2048-4       132µs ± 0%   108µs ± 0%  -18.09%  (p=0.000 n=10+10)
SignPKCS1v15/2048-4     1.18ms ± 0%  1.14ms ± 1%   -3.30%  (p=0.000 n=10+10)
VerifyPKCS1v15/2048-4    131µs ± 0%   107µs ± 0%  -18.30%  (p=0.000 n=9+10)
SignPSS/2048-4          1.18ms ± 0%  1.15ms ± 1%   -1.87%  (p=0.000 n=10+10)
VerifyPSS/2048-4         132µs ± 0%   108µs ± 0%  -18.30%  (p=0.000 n=10+9)

Updates #57752

Change-Id: Ic89273a58002b32b1c5c3185a35262694ceef409
Reviewed-on: https://go-review.googlesource.com/c/go/+/492935
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agocrypto/internal/bigmod: switch to saturated limbs
Filippo Valsorda [Sat, 25 Feb 2023 18:09:11 +0000 (19:09 +0100)]
crypto/internal/bigmod: switch to saturated limbs

Turns out that unsaturated limbs being more performant for Montgomery
multiplication was true in portable C89, but is now a misconception.
With add-with-carry instructions, it's possible to run the carry chain
across the limbs, instead of needing the limb-by-limb product to fit in
two words.

Switch to saturated limbs, and import the same Montgomery loop as
math/big, along with its assembly for some architectures. Since here we
know the sizes we care about, we can drop most of the assembly
scaffolding. For amd64, ported to avo, too.

We recover all the Go 1.20 performance loss on private key operations on
both Intel Xeon and AMD EPYC, with even a 10% improvement over Go 1.19
(which used variable-time math/big) for some operations.

goos: linux
goarch: amd64
pkg: crypto/rsa
cpu: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
                       │ go1.19.txt  │       go1.20.txt         │         new.txt          │
                       │   sec/op    │    sec/op      vs base   │    sec/op      vs base   │
DecryptPKCS1v15/2048-4   1.175m ± 0%     1.515m ± 0%    +28.95%     1.132m ± 0%     -3.59%
DecryptPKCS1v15/3072-4   3.428m ± 1%     4.516m ± 0%    +31.75%     3.198m ± 0%     -6.69%
DecryptPKCS1v15/4096-4   7.405m ± 0%    10.092m ± 0%    +36.29%     6.446m ± 0%    -12.95%
EncryptPKCS1v15/2048-4   7.426µ ± 0%   170.829µ ± 0%  +2200.57%   131.874µ ± 0%  +1675.97%
DecryptOAEP/2048-4       1.175m ± 0%     1.524m ± 0%    +29.68%     1.137m ± 0%     -3.26%
EncryptOAEP/2048-4       9.609µ ± 0%   173.008µ ± 0%  +1700.48%   132.344µ ± 0%  +1277.29%
SignPKCS1v15/2048-4      1.181m ± 0%     1.563m ± 0%    +32.34%     1.177m ± 0%     -0.37%
VerifyPKCS1v15/2048-4    6.452µ ± 0%   170.092µ ± 0%  +2536.06%   131.225µ ± 0%  +1933.70%
SignPSS/2048-4           1.184m ± 0%     1.574m ± 0%    +32.88%     1.175m ± 0%     -0.84%
VerifyPSS/2048-4         9.151µ ± 1%   172.909µ ± 0%  +1789.50%   132.391µ ± 0%  +1346.74%

                       │  go1.19.txt   │      go1.20.txt       │       new.txt         │
                       │     B/op      │     B/op      vs base │     B/op      vs base │
DecryptPKCS1v15/2048-4    24266.5 ± 0%     640.0 ± 0%  -97.36%     640.0 ± 0%  -97.36%
DecryptPKCS1v15/3072-4   45.465Ki ± 0%   3.375Ki ± 0%  -92.58%   4.688Ki ± 0%  -89.69%
DecryptPKCS1v15/4096-4   61.080Ki ± 0%   4.625Ki ± 0%  -92.43%   6.250Ki ± 0%  -89.77%
EncryptPKCS1v15/2048-4    3.138Ki ± 0%   1.146Ki ± 0%  -63.49%   1.082Ki ± 0%  -65.52%
DecryptOAEP/2048-4        24500.0 ± 0%     872.0 ± 0%  -96.44%     872.0 ± 0%  -96.44%
EncryptOAEP/2048-4        3.610Ki ± 0%   1.371Ki ± 0%  -62.02%   1.308Ki ± 0%  -63.78%
SignPKCS1v15/2048-4       26933.0 ± 0%     896.0 ± 0%  -96.67%     896.0 ± 0%  -96.67%
VerifyPKCS1v15/2048-4      3209.0 ± 0%     912.0 ± 0%  -71.58%     848.0 ± 0%  -73.57%
SignPSS/2048-4           26.940Ki ± 0%   1.266Ki ± 0%  -95.30%   1.266Ki ± 0%  -95.30%
VerifyPSS/2048-4          3.337Ki ± 0%   1.094Ki ± 0%  -67.22%   1.031Ki ± 0%  -69.10%

                       │  go1.19.txt  │     go1.20.txt      │      new.txt          │
                       │  allocs/op   │ allocs/op   vs base │ allocs/op   vs base   │
DecryptPKCS1v15/2048-4    97.000 ± 0%   4.000 ± 0%  -95.88%     4.000 ± 0%  -95.88%
DecryptPKCS1v15/3072-4    107.00 ± 0%   10.00 ± 0%  -90.65%     12.00 ± 0%  -88.79%
DecryptPKCS1v15/4096-4    113.00 ± 0%   10.00 ± 0%  -91.15%     12.00 ± 0%  -89.38%
EncryptPKCS1v15/2048-4     7.000 ± 0%   7.000 ± 0%        ~     7.000 ± 0%        ~
DecryptOAEP/2048-4        103.00 ± 0%   10.00 ± 0%  -90.29%     10.00 ± 0%  -90.29%
EncryptOAEP/2048-4         14.00 ± 0%   13.00 ± 0%   -7.14%     13.00 ± 0%   -7.14%
SignPKCS1v15/2048-4      102.000 ± 0%   5.000 ± 0%  -95.10%     5.000 ± 0%  -95.10%
VerifyPKCS1v15/2048-4      7.000 ± 0%   6.000 ± 0%  -14.29%     6.000 ± 0%  -14.29%
SignPSS/2048-4            108.00 ± 0%   10.00 ± 0%  -90.74%     10.00 ± 0%  -90.74%
VerifyPSS/2048-4           12.00 ± 0%   11.00 ± 0%   -8.33%     11.00 ± 0%   -8.33%

goos: linux
goarch: amd64
pkg: crypto/rsa
cpu: AMD EPYC 7R13 Processor
                       │ go1.19a.txt │       go1.20a.txt        │        newa.txt          │
                       │   sec/op    │    sec/op      vs base   │    sec/op      vs base   │
DecryptPKCS1v15/2048-4   970.0µ ± 0%    1667.6µ ± 0%    +71.92%     951.6µ ± 0%     -1.90%
DecryptPKCS1v15/3072-4   2.949m ± 0%     5.124m ± 0%    +73.75%     2.675m ± 0%     -9.29%
DecryptPKCS1v15/4096-4   6.350m ± 0%    11.660m ± 0%    +83.62%     5.746m ± 0%     -9.51%
EncryptPKCS1v15/2048-4   6.605µ ± 1%   183.807µ ± 0%  +2683.05%   123.720µ ± 0%  +1773.27%
DecryptOAEP/2048-4       973.8µ ± 0%    1670.8µ ± 0%    +71.57%     951.8µ ± 0%     -2.27%
EncryptOAEP/2048-4       8.444µ ± 1%   185.889µ ± 0%  +2101.56%   124.142µ ± 0%  +1370.27%
SignPKCS1v15/2048-4      976.8µ ± 0%    1725.5µ ± 0%    +76.65%     979.6µ ± 0%     +0.28%
VerifyPKCS1v15/2048-4    5.713µ ± 0%   182.983µ ± 0%  +3103.19%   122.737µ ± 0%  +2048.56%
SignPSS/2048-4           980.3µ ± 0%    1729.5µ ± 0%    +76.42%     985.7µ ± 3%     +0.55%
VerifyPSS/2048-4         8.168µ ± 1%   185.312µ ± 0%  +2168.76%   123.772µ ± 0%  +1415.33%

Fixes #59463
Fixes #59442
Updates #57752

Change-Id: I311a9c1f4f5288e47e53ca14f615a443f3132734
Reviewed-on: https://go-review.googlesource.com/c/go/+/471259
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: use shorter version of movzx for LoweredHASCPUFeature
Jakub Ciolek [Sun, 11 Sep 2022 12:47:36 +0000 (14:47 +0200)]
cmd/compile: use shorter version of movzx for LoweredHASCPUFeature

The values loaded from memory are booleans. Upper 32 bits are not needed.
Use the 32-bit version of movzx.

compilecmp linux/amd64:

math/bits
math/bits.OnesCount 83 -> 78  (-6.02%)

math
math.ceil 109 -> 103  (-5.50%)
math.Gamma changed
math.sinPi changed

runtime
runtime.(*sweepLocked).sweep changed
runtime.(*mspan).countAlloc 182 -> 178  (-2.20%)
runtime.(*pageBits).popcntRange 552 -> 542  (-1.81%)
go:(**mspan).runtime.countAlloc 243 -> 232  (-4.53%)
runtime.sweepLocked.countAlloc 221 -> 215  (-2.71%)
runtime.(*pageCache).allocN changed

math/rand
math/rand.(*Zipf).Uint64 506 -> 499  (-1.38%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.(*CPUSet).Count 147 -> 145  (-1.36%)

cmd/internal/obj/ppc64
cmd/internal/obj/ppc64.(*ctxt9).asmout changed

cmd/cover
main.htmlGen 1170 -> 1164  (-0.51%)

cmd/compile/internal/bitvec
cmd/compile/internal/bitvec.(*BitVec).Count 221 -> 213  (-3.62%)
cmd/compile/internal/bitvec.BitVec.Count changed

cmd/link/internal/loader
cmd/link/internal/loader.(*Bitmap).Count 214 -> 212  (-0.93%)
cmd/link/internal/loader.Bitmap.Count 171 -> 169  (-1.17%)
cmd/link/internal/loader.(*Loader).NReachableSym changed
cmd/link/internal/loader.(*Loader).Stat changed

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.oldRustToString changed

cmd/vendor/github.com/google/pprof/internal/graph
cmd/vendor/github.com/google/pprof/internal/graph.(*builder).addNode changed

cmd/compile/internal/ssa
cmd/compile/internal/ssa.rewriteValuePPC64_OpPPC64FTRUNC changed
cmd/compile/internal/ssa.(*regAllocState).computeLive 10441 -> 10409  (-0.31%)
cmd/compile/internal/ssa.(*regAllocState).regalloc changed
cmd/compile/internal/ssa.rewriteValuePPC64_OpPPC64FCEIL changed
cmd/compile/internal/ssa.(*regAllocState).allocReg changed
cmd/compile/internal/ssa.rewriteValuePPC64_OpPPC64FFLOOR changed
cmd/compile/internal/ssa.countRegs 83 -> 78  (-6.02%)

cmd/compile/internal/liveness
cmd/compile/internal/liveness.ArgLiveness.func2 changed

cmd/compile/internal/amd64
cmd/compile/internal/amd64.ssaGenValue changed

file                               before   after    Δ       %
math/bits.s                        2618     2613     -5      -0.191%
math.s                             37246    37240    -6      -0.016%
runtime.s                          486910   486879   -31     -0.006%
math/rand.s                        9980     9973     -7      -0.070%
cmd/vendor/golang.org/x/sys/unix.s 119232   119230   -2      -0.002%
cmd/cover.s                        31341    31335    -6      -0.019%
cmd/compile/internal/bitvec.s      5542     5534     -8      -0.144%
cmd/link/internal/loader.s         75315    75311    -4      -0.005%
cmd/compile/internal/ssa.s         3570581  3570544  -37     -0.001%
total                              20041552 20041446 -106    -0.001%

Change-Id: I29845744c512a1f833cb1fa3bb43b6b0e0eaac68
Reviewed-on: https://go-review.googlesource.com/c/go/+/430175
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agospec: re-order built-ins sections alphabetically (more or less)
Robert Griesemer [Wed, 24 May 2023 18:42:57 +0000 (11:42 -0700)]
spec: re-order built-ins sections alphabetically (more or less)

Put the sections for the various built-ins into alphabetical order
based on the built-in name, while keeping built-ins that belong
together together.

The order is now (captialized letter determines order):

- Append
- Clear
- Close
- Complex, real, imag
- Delete
- Len, cap
- Make
- Min, max (to be inserted here)
- New
- Panic, recover
- Print, println

There are some white space adjustments but no changes to the prose
of the moved sections.

Change-Id: Iaec509918c6bc965df3f28656374de03279bdc9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/498135
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/go/internal/cache: use internal/godebug for three GODEBUGs
Brad Fitzpatrick [Sat, 22 Apr 2023 02:55:43 +0000 (19:55 -0700)]
cmd/go/internal/cache: use internal/godebug for three GODEBUGs

And register/document them.

Change-Id: If0f1cf3c09230e0f63d03c52e56e51a030468ab2
Reviewed-on: https://go-review.googlesource.com/c/go/+/487655
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

12 months agocmd/compile: prioritize non-CALL struct member comparisons
Derek Parker [Mon, 8 May 2023 21:28:43 +0000 (21:28 +0000)]
cmd/compile: prioritize non-CALL struct member comparisons

This patch optimizes reflectdata.geneq to pick apart structs in array
equality and prioritize non-CALL comparisons over those which involve
a runtime function call. This is similar to how arrays of strings
operate currently. Instead of looping over the entire array of structs
once, if there are any comparisons which involve a runtime function
call we instead loop twice. The first loop is all simple, quick
comparisons. If no inequality is found in the first loop the second loop
calls runtime functions for larger memory comparison, which is more
expensive.

For the benchmarks added in this change:

Old:

```
goos: linux
goarch: amd64
pkg: cmd/compile/internal/reflectdata
cpu: AMD Ryzen 9 3950X 16-Core Processor
BenchmarkEqArrayOfStructsEq
BenchmarkEqArrayOfStructsEq-32            797196              1497 ns/op
BenchmarkEqArrayOfStructsEq-32            758332              1581 ns/op
BenchmarkEqArrayOfStructsEq-32            764871              1599 ns/op
BenchmarkEqArrayOfStructsEq-32            760706              1558 ns/op
BenchmarkEqArrayOfStructsEq-32            763112              1476 ns/op
BenchmarkEqArrayOfStructsEq-32            747696              1547 ns/op
BenchmarkEqArrayOfStructsEq-32            756526              1562 ns/op
BenchmarkEqArrayOfStructsEq-32            768829              1486 ns/op
BenchmarkEqArrayOfStructsEq-32            764248              1477 ns/op
BenchmarkEqArrayOfStructsEq-32            752767              1545 ns/op
BenchmarkEqArrayOfStructsNotEq
BenchmarkEqArrayOfStructsNotEq-32         757194              1542 ns/op
BenchmarkEqArrayOfStructsNotEq-32         748942              1552 ns/op
BenchmarkEqArrayOfStructsNotEq-32         766687              1554 ns/op
BenchmarkEqArrayOfStructsNotEq-32         732069              1541 ns/op
BenchmarkEqArrayOfStructsNotEq-32         759163              1576 ns/op
BenchmarkEqArrayOfStructsNotEq-32         796402              1629 ns/op
BenchmarkEqArrayOfStructsNotEq-32         726610              1570 ns/op
BenchmarkEqArrayOfStructsNotEq-32         735770              1584 ns/op
BenchmarkEqArrayOfStructsNotEq-32         745255              1610 ns/op
BenchmarkEqArrayOfStructsNotEq-32         743872              1591 ns/op
PASS
ok      cmd/compile/internal/reflectdata        35.446s
```

New:

```
goos: linux
goarch: amd64
pkg: cmd/compile/internal/reflectdata
cpu: AMD Ryzen 9 3950X 16-Core Processor
BenchmarkEqArrayOfStructsEq
BenchmarkEqArrayOfStructsEq-32            618379              1827 ns/op
BenchmarkEqArrayOfStructsEq-32            619368              1922 ns/op
BenchmarkEqArrayOfStructsEq-32            616023              1910 ns/op
BenchmarkEqArrayOfStructsEq-32            617575              1905 ns/op
BenchmarkEqArrayOfStructsEq-32            610399              1889 ns/op
BenchmarkEqArrayOfStructsEq-32            615378              1823 ns/op
BenchmarkEqArrayOfStructsEq-32            613732              1883 ns/op
BenchmarkEqArrayOfStructsEq-32            613924              1894 ns/op
BenchmarkEqArrayOfStructsEq-32            657799              1876 ns/op
BenchmarkEqArrayOfStructsEq-32            665580              1873 ns/op
BenchmarkEqArrayOfStructsNotEq
BenchmarkEqArrayOfStructsNotEq-32        1834915               627.4 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1806370               660.5 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1828075               625.5 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1819741               641.6 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1813128               632.3 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1865250               643.7 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1828617               632.8 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1862748               633.6 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1825432               638.7 ns/op
BenchmarkEqArrayOfStructsNotEq-32        1804382               628.8 ns/op
PASS
ok      cmd/compile/internal/reflectdata        36.571s
```

Benchstat comparison:

```
name                      old time/op  new time/op  delta
EqArrayOfStructsEq-32     1.53µs ± 4%  1.88µs ± 3%  +22.66%  (p=0.000 n=10+10)
EqArrayOfStructsNotEq-32  1.57µs ± 3%  0.64µs ± 4%  -59.59%  (p=0.000 n=10+10)
```

So, the equal case is a bit slower (unrolling the loop helps with that),
but the non-equal case is now much faster.

Change-Id: I05d776456c79c48a3d6d74b18c45246e58ffbea6
GitHub-Last-Rev: f57ee07d053ec4269a6d7d9109c845d8c862cba1
GitHub-Pull-Request: golang/go#59409
Reviewed-on: https://go-review.googlesource.com/c/go/+/481895
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agocmd/go: quote entries in list-valued variables for go env in plan9
miller [Mon, 8 May 2023 15:56:21 +0000 (16:56 +0100)]
cmd/go: quote entries in list-valued variables for go env in plan9

When 'go env' without an argument prints environment variables as
a script which can be executed by the shell, variables with a
list value in Plan 9 (such as GOPATH) need to be printed with each
element enclosed in single quotes in case it contains characters
significant to the Plan 9 shell (such as ' ' or '=').

For #58508

Change-Id: Ia30f51307cc6d07a7e3ada6bf9d60bf9951982ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/493535
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agodoc: add release note for runtime/metrics additions
Michael Anthony Knyszek [Wed, 24 May 2023 18:41:32 +0000 (18:41 +0000)]
doc: add release note for runtime/metrics additions

For #56857.

Change-Id: I03bdba906d271d97ce29874c50d5aba55dc285b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/498075
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocrypto/tls: enforce 1.3 record version semantics
Roland Shoemaker [Tue, 18 Apr 2023 17:24:32 +0000 (10:24 -0700)]
crypto/tls: enforce 1.3 record version semantics

1.3 expects the record version is always 1.2 (0x0303), this previously
wasn't enforced.

Change-Id: I8bc88f588e76f9b862b57601336bb5c5ff08b30e
Reviewed-on: https://go-review.googlesource.com/c/go/+/485876
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agonet/http: check for nil, nil return from DialContext as well as Dial
fangguizhen [Tue, 3 Jan 2023 18:18:35 +0000 (18:18 +0000)]
net/http: check for nil, nil return from DialContext as well as Dial

Change-Id: I3b6dd9c40b3c10db2eda6a25b9d556c9c3733bbc
GitHub-Last-Rev: fd9b0c4193511a75b4a0073f37aa3116db23a46f
GitHub-Pull-Request: golang/go#57448
Reviewed-on: https://go-review.googlesource.com/c/go/+/458876
Reviewed-by: Javad Rajabzadeh <ja7ad@live.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agocrypto/tls: remove unused nonAESGCMAEADCiphers variable
Sebastiaan van Stijn [Mon, 14 Nov 2022 20:29:26 +0000 (20:29 +0000)]
crypto/tls: remove unused nonAESGCMAEADCiphers variable

It was no longer used since CL 314609

Change-Id: Id103b7490a6088a589d76442d3740f8a1453c25d
GitHub-Last-Rev: 20a7fe0778fbfcfd789a194456e87dd4a60b655e
GitHub-Pull-Request: golang/go#56608
Reviewed-on: https://go-review.googlesource.com/c/go/+/448277
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agomaps: move test funcs to maps_test.go
Tobias Klauser [Wed, 24 May 2023 10:28:25 +0000 (12:28 +0200)]
maps: move test funcs to maps_test.go

keysForBenchmarking and valuesForBenchmarking are only used in benchmark
tests.

Change-Id: Ie4fcb81e0470cc8627b395644787429b79952538
Reviewed-on: https://go-review.googlesource.com/c/go/+/497380
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

12 months agolog/slog: add link to handler-writing guide
Jonathan Amsterdam [Wed, 17 May 2023 20:12:42 +0000 (16:12 -0400)]
log/slog: add link to handler-writing guide

Add a shortlink in the doc to a guide to writing handlers, which is a work
in progress.

Change-Id: I1b01c90468382ffe53d9ad6f38253906e3f44857
Reviewed-on: https://go-review.googlesource.com/c/go/+/495920
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

12 months agonet/http/pprof: adjust URL in package doc
Joe Tsai [Tue, 21 Mar 2023 03:28:47 +0000 (20:28 -0700)]
net/http/pprof: adjust URL in package doc

The indentation makes the URL be treated as a code block,
thus preventing automatic detection of this URL.
Avoid using a code block for this.

Change-Id: Ie37ae18ec0969ef2d5a6e3b92b2512dac093dbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/478015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agonet/http: add doc details regarding Transport retries
Simon Kotwicz [Sun, 20 Feb 2022 08:24:08 +0000 (08:24 +0000)]
net/http: add doc details regarding Transport retries

Add doc details to Transport mentioning retries only occur if a connection
has been already been used successfully.

Change-Id: I37afbad50b885248e0e6cd5e799ad848bf97c86b
GitHub-Last-Rev: 7c45c32aec2bd3266c525bf28ab1879acbecf193
GitHub-Pull-Request: golang/go#51273
Reviewed-on: https://go-review.googlesource.com/c/go/+/386994
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

12 months agointernal/coverage: fix comment dupword, error typo
Oleksandr Redko [Mon, 17 Apr 2023 09:32:12 +0000 (12:32 +0300)]
internal/coverage: fix comment dupword, error typo

- Correct duplicated word in comments.
- Fix typo in error message.

Change-Id: I688d723ea3ac4d0b1981afd747e4b2df00c81448
Reviewed-on: https://go-review.googlesource.com/c/go/+/485016
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
12 months agoos: explicitly check for invalid FD in NewFile
Michael Pratt [Wed, 24 May 2023 15:25:12 +0000 (11:25 -0400)]
os: explicitly check for invalid FD in NewFile

CL 497075 refactored NewFile to unconditionally dereference the file
returned by newFile. However, newFile can return nil if passed a
negative FD, which now causes a crash.

Resolve this by moving the invalid check earlier in NewFile, which also
lets us avoid a useless fcntl syscall on a negative FD.

Since we convert to int to check sign, adjust newFile to take an int
rather than uintptr, which cleans up a lot of conversions.

Fixes #60406

Change-Id: I382a74e22f1cc01f7a2dcf1ff4efca6a79c4dd57
Reviewed-on: https://go-review.googlesource.com/c/go/+/497877
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/go: implement 'toolchain local'
Russ Cox [Tue, 23 May 2023 18:23:31 +0000 (14:23 -0400)]
cmd/go: implement 'toolchain local'

The actual selection code already worked
(except for the x/mod parser not reading the file),
so all that is necessary is a test.
For the test, move the version check up before
the module line presence check.

For #57001.

Change-Id: Iaa4f9b92d38fcfd99dc1665ec8d3eb0e52007bb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/497555
TryBot-Bypass: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agoruntime: fix alignment code in memclr_riscv64.s
Mark Ryan [Fri, 19 May 2023 12:00:10 +0000 (14:00 +0200)]
runtime: fix alignment code in memclr_riscv64.s

The existing code incorrectly determines whether the pointer passed to
memclrNoHeapPointers is 8 byte aligned (it currently checks to see whether
it's 4 byte aligned).

In addition, the code that aligns the pointer, by individually filling
the first few bytes of the buffer with zeros, is also incorrect.  It adjusts
the pointer by the wrong number of bytes, resulting in most cases, in
an unaligned pointer.

This commit fixes both of these issues by anding the pointer with 7
rather than 3 to determine its alignment, and by individually filling
the first (8 - (pointer & 7)) bytes with 0 to align the buffer, rather
than the first (pointer & 3) bytes.

We also remove an unnecessary immediate MOV instruction.

A new benchmark is added to test the performance of memclrNoHeapPointers
on non-aligned pointers.  Results of the existing and the new benchmark
on a SiFive HiFive Unmatched A00 with 16GB of RAM running Ubuntu 23.04
are presented below.

Memclr/5-4                     21.98n ± 7%   22.66n ± 9%        ~ (p=0.079 n=10)
Memclr/16-4                    20.85n ± 3%   21.09n ± 5%        ~ (p=0.796 n=10)
Memclr/64-4                    28.20n ± 4%   27.50n ± 3%        ~ (p=0.093 n=10)
Memclr/256-4                   53.66n ± 8%   53.44n ± 8%        ~ (p=0.280 n=10)
Memclr/4096-4                  522.6n ± 1%   523.4n ± 1%        ~ (p=0.240 n=10)
Memclr/65536-4                 24.17µ ± 0%   24.13µ ± 0%   -0.19% (p=0.029 n=10)
Memclr/1M-4                    446.9µ ± 0%   446.9µ ± 0%        ~ (p=0.684 n=10)
Memclr/4M-4                    12.69m ± 2%   12.79m ± 3%   +0.78% (p=0.043 n=10)
Memclr/8M-4                    29.75m ± 0%   29.76m ± 0%   +0.03% (p=0.015 n=10)
Memclr/16M-4                   60.34m ± 0%   60.32m ± 0%        ~ (p=0.247 n=10)
Memclr/64M-4                   241.2m ± 0%   241.3m ± 0%        ~ (p=0.247 n=10)
MemclrUnaligned/0_5-4          27.71n ± 0%   27.72n ± 1%        ~ (p=0.142 n=10)
MemclrUnaligned/0_16-4         26.95n ± 0%   26.04n ± 0%   -3.38% (p=0.000 n=10)
MemclrUnaligned/0_64-4         38.27n ± 4%   40.15n ± 6%   +4.89% (p=0.005 n=10)
MemclrUnaligned/0_256-4        63.95n ± 3%   64.19n ± 2%        ~ (p=0.971 n=10)
MemclrUnaligned/0_4096-4       532.6n ± 1%   530.9n ± 1%        ~ (p=0.324 n=10)
MemclrUnaligned/0_65536-4      24.30µ ± 0%   24.22µ ± 0%   -0.32% (p=0.023 n=10)
MemclrUnaligned/1_5-4          29.40n ± 0%   29.39n ± 0%        ~ (p=0.060 n=10)
MemclrUnaligned/1_16-4        632.65n ± 1%   63.80n ± 2%  -89.92% (p=0.000 n=10)
MemclrUnaligned/1_64-4       4091.00n ± 1%   73.23n ± 1%  -98.21% (p=0.000 n=10)
MemclrUnaligned/1_256-4     17803.50n ± 1%   92.03n ± 1%  -99.48% (p=0.000 n=10)
MemclrUnaligned/1_4096-4    294150.0n ± 1%   561.9n ± 1%  -99.81% (p=0.000 n=10)
MemclrUnaligned/1_65536-4    4692.80µ ± 1%   24.44µ ± 0%  -99.48% (p=0.000 n=10)
MemclrUnaligned/4_5-4          27.71n ± 0%   27.71n ± 0%        ~ (p=0.308 n=10)
MemclrUnaligned/4_16-4       1187.00n ± 1%   50.74n ± 3%  -95.72% (p=0.000 n=10)
MemclrUnaligned/4_64-4       4617.00n ± 1%   59.89n ± 2%  -98.70% (p=0.000 n=10)
MemclrUnaligned/4_256-4     18472.50n ± 1%   84.76n ± 2%  -99.54% (p=0.000 n=10)
MemclrUnaligned/4_4096-4    292904.0n ± 1%   553.7n ± 0%  -99.81% (p=0.000 n=10)
MemclrUnaligned/4_65536-4    4716.12µ ± 0%   24.38µ ± 0%  -99.48% (p=0.000 n=10)
MemclrUnaligned/7_5-4          29.39n ± 0%   29.39n ± 0%        ~ (p=1.000 n=10)
MemclrUnaligned/7_16-4        636.80n ± 1%   48.33n ± 5%  -92.41% (p=0.000 n=10)
MemclrUnaligned/7_64-4       4094.00n ± 1%   58.88n ± 3%  -98.56% (p=0.000 n=10)
MemclrUnaligned/7_256-4     17869.00n ± 2%   82.70n ± 3%  -99.54% (p=0.000 n=10)
MemclrUnaligned/7_4096-4    294110.5n ± 1%   554.6n ± 1%  -99.81% (p=0.000 n=10)
MemclrUnaligned/7_65536-4    4735.00µ ± 1%   24.28µ ± 0%  -99.49% (p=0.000 n=10)
MemclrUnaligned/0_1M-4         447.8µ ± 0%   450.0µ ± 1%   +0.51% (p=0.000 n=10)
MemclrUnaligned/0_4M-4         12.68m ± 1%   12.64m ± 2%   -0.33% (p=0.015 n=10)
MemclrUnaligned/0_8M-4         29.76m ± 0%   29.79m ± 2%        ~ (p=0.075 n=10)
MemclrUnaligned/0_16M-4        60.34m ± 1%   60.49m ± 1%        ~ (p=0.353 n=10)
MemclrUnaligned/0_64M-4        241.3m ± 0%   241.4m ± 0%        ~ (p=0.247 n=10)
MemclrUnaligned/1_1M-4       75937.3µ ± 1%   449.9µ ± 0%  -99.41% (p=0.000 n=10)
MemclrUnaligned/1_4M-4        313.96m ± 2%   12.69m ± 0%  -95.96% (p=0.000 n=10)
MemclrUnaligned/1_8M-4        630.97m ± 1%   29.76m ± 0%  -95.28% (p=0.000 n=10)
MemclrUnaligned/1_16M-4      1263.47m ± 1%   60.35m ± 2%  -95.22% (p=0.000 n=10)
MemclrUnaligned/1_64M-4       5053.5m ± 0%   241.3m ± 0%  -95.23% (p=0.000 n=10)
MemclrUnaligned/4_1M-4       75880.5µ ± 2%   446.5µ ± 0%  -99.41% (p=0.000 n=10)
MemclrUnaligned/4_4M-4        314.00m ± 1%   12.71m ± 2%  -95.95% (p=0.000 n=10)
MemclrUnaligned/4_8M-4        630.63m ± 1%   29.77m ± 2%  -95.28% (p=0.000 n=10)
MemclrUnaligned/4_16M-4      1257.80m ± 0%   60.34m ± 2%  -95.20% (p=0.000 n=10)
MemclrUnaligned/4_64M-4       5041.3m ± 1%   241.2m ± 0%  -95.21% (p=0.000 n=10)
MemclrUnaligned/7_1M-4       75866.2µ ± 1%   446.9µ ± 0%  -99.41% (p=0.000 n=10)
MemclrUnaligned/7_4M-4        309.86m ± 1%   12.70m ± 1%  -95.90% (p=0.000 n=10)
MemclrUnaligned/7_8M-4        626.67m ± 1%   29.75m ± 2%  -95.25% (p=0.000 n=10)
MemclrUnaligned/7_16M-4      1252.84m ± 1%   60.31m ± 0%  -95.19% (p=0.000 n=10)
MemclrUnaligned/7_64M-4       5015.8m ± 1%   241.4m ± 0%  -95.19% (p=0.000 n=10)
geomean                        339.1µ        35.83µ       -89.43%

Change-Id: I3b958a1d8e8f5ef205052e6b985a5ce21e92ef85
Reviewed-on: https://go-review.googlesource.com/c/go/+/496455
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agofmt: correct documentation for Formatter
Paul Jolly [Wed, 24 May 2023 04:51:09 +0000 (05:51 +0100)]
fmt: correct documentation for Formatter

Before this CL, the documentation for Formatter suggested that
implementers of Format(f State, verb rune) could use Fprint(f) or
Sprint(f) to generate output. The Sprint(f) suggestion however is
invalid.

Fix that by simply suggesting Sprint() alongside Fprint(f).

Fixes #60358

Change-Id: I024e996f6360b812968ef2cd5073cb4c223459e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/497379
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agonet/http: fix spelling issues in comments and tests
Oleksandr Redko [Thu, 18 May 2023 08:12:23 +0000 (11:12 +0300)]
net/http: fix spelling issues in comments and tests

Change-Id: I1b90619fd073a0c41188278a50ed149b763f0fa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/496135
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: ensure consistency of /gc/scan/*
Michael Anthony Knyszek [Wed, 24 May 2023 16:43:47 +0000 (16:43 +0000)]
runtime: ensure consistency of /gc/scan/*

Currently /gc/scan/total:bytes is computed as a separate sum. Compute it
using the same inputs so it's always consistent with the sum of
everything else in /gc/scan/*.

For #56857.

Change-Id: I43d9148a23b1d2eb948ae990193dca1da85df8a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/497880
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocmd/dist: copy trailing text more directly in testJSONFilter.process
Dmitri Shuralyov [Mon, 22 May 2023 16:56:28 +0000 (12:56 -0400)]
cmd/dist: copy trailing text more directly in testJSONFilter.process

Use io.Copy¹ that matches the comment more closely, avoids the
possibility of needing a bigger array, and is slightly shorter.
Its downside is that it takes two w.Write calls instead of one.

¹ Admittedly, it was temping to use io.CopyBuffer since the 'data'
  byte slice becomes a viable buffer after its contents are written.
  I resisted that temptation for two reasons.

  One, it would need the io.Reader returned by dec.Buffered() (currently
  a *bytes.Reader) to not implement the io.WriterTo interface for any
  chance of making a positive difference. This seems not very likely.

  Two, to avoid burdening anyone with determining that io.CopyBuffer
  won't panic without 'if len(data) == 0 && data != nil { data = nil }'
  because json.Marshal never returns an empty but non-nil byte slice.

Change-Id: I33c53d9d990f6ee79cd3ab90f12e3b575b9ebe72
Reviewed-on: https://go-review.googlesource.com/c/go/+/497736
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

12 months agocmd/dist: make two related panic messages more consistent
Dmitri Shuralyov [Sat, 20 May 2023 03:20:43 +0000 (23:20 -0400)]
cmd/dist: make two related panic messages more consistent

In contrast to the HasSuffix argument, there's no need or benefit in
having a ":" before the "racebench" variant mentioned in the message.
(The variant comes after the colon separator—it doesn't include it.)

Change-Id: Ie9948104de9449422037bf39245944255b98f1b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/497735
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
12 months agoRevert "testing: only report subtest races once"
Bryan Mills [Wed, 24 May 2023 17:16:33 +0000 (17:16 +0000)]
Revert "testing: only report subtest races once"

This reverts CL 494057.

Reason for revert: test is failing on -race builders.

Fixes #60393.

Change-Id: If98238a12673aec597cf69aeead7bdf4782b4524
Reviewed-on: https://go-review.googlesource.com/c/go/+/497996
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

12 months agocmd/go: fix PGO script flag matching
Michael Pratt [Wed, 24 May 2023 16:43:09 +0000 (12:43 -0400)]
cmd/go: fix PGO script flag matching

build_pgo.txt hard-coded a check for / rather than using ${/}, causing a
failure on Windows

The failure in build_pgo_auto_multi.txt is more interesting. If the
first argument to stdout starts with `-` the script engine expects it to
be a flag to grep, and thus doesn't regexp-escape `\` in the expansion
of `${/}`.

The script engine doesn't _require_ that these are flags to grep, so it
is still possible to use them for matching, but this ideally will change
in the future, so change all patterns to avoid starting with `-`.

Fixes #60408.

Change-Id: Ie4041a730d22ce40a4436abae7713f211dcb42e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/497881
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoRevert "cmd/compile: enable printing of error URLs by default"
Robert Griesemer [Wed, 24 May 2023 16:30:49 +0000 (16:30 +0000)]
Revert "cmd/compile: enable printing of error URLs by default"

This reverts commit e7a9ca0a53db4b4f357b5d3caaef65e44ce08a90.

Reason for revert: Decided to delay to Go 1.22.

Change-Id: I4635cb4c1372b54cac573041be8a43e294de5183
Reviewed-on: https://go-review.googlesource.com/c/go/+/497975
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agoruntime: cache inner pinner on P
Michael Anthony Knyszek [Fri, 19 May 2023 19:12:35 +0000 (19:12 +0000)]
runtime: cache inner pinner on P

This change caches the *pinner on the P to pool it and reduce the chance
that a new allocation is made. It also makes the *pinner no longer drop
its refs array on unpin, also to avoid reallocating.

The Pinner benchmark results before and after this CL are attached at
the bottom of the commit message.

Note that these results are biased toward the current change because of
the last two benchmark changes. Reusing the pinner in the benchmark
itself achieves similar performance before this change. The benchmark
results thus basically just confirm that this change does cache the
inner pinner in a useful way. Using the previous benchmarks there's
actually a slight regression from the extra check in the cache, however
the long pole is still setPinned itself.

name                                old time/op    new time/op    delta
PinnerPinUnpinBatch-8                 42.2µs ± 2%    41.5µs ± 1%      ~     (p=0.056 n=5+5)
PinnerPinUnpinBatchDouble-8            367µs ± 1%     350µs ± 1%    -4.67%  (p=0.008 n=5+5)
PinnerPinUnpinBatchTiny-8              108µs ± 0%     102µs ± 1%    -6.22%  (p=0.008 n=5+5)
PinnerPinUnpin-8                       592ns ± 8%      40ns ± 1%   -93.29%  (p=0.008 n=5+5)
PinnerPinUnpinTiny-8                   693ns ± 9%      39ns ± 1%   -94.31%  (p=0.008 n=5+5)
PinnerPinUnpinDouble-8                 843ns ± 5%     124ns ± 3%   -85.24%  (p=0.008 n=5+5)
PinnerPinUnpinParallel-8              1.11µs ± 5%    0.00µs ± 0%   -99.55%  (p=0.008 n=5+5)
PinnerPinUnpinParallelTiny-8          1.12µs ± 8%    0.00µs ± 1%   -99.55%  (p=0.008 n=5+5)
PinnerPinUnpinParallelDouble-8        1.79µs ± 4%    0.58µs ± 6%   -67.36%  (p=0.008 n=5+5)
PinnerIsPinnedOnPinned-8              5.78ns ± 0%    5.80ns ± 1%      ~     (p=0.548 n=5+5)
PinnerIsPinnedOnUnpinned-8            4.99ns ± 1%    4.98ns ± 0%      ~     (p=0.841 n=5+5)
PinnerIsPinnedOnPinnedParallel-8      0.71ns ± 0%    0.71ns ± 0%      ~     (p=0.175 n=5+5)
PinnerIsPinnedOnUnpinnedParallel-8    0.67ns ± 1%    0.66ns ± 0%      ~     (p=0.167 n=5+5)

name                                old alloc/op   new alloc/op   delta
PinnerPinUnpinBatch-8                 20.1kB ± 0%    20.0kB ± 0%    -0.32%  (p=0.008 n=5+5)
PinnerPinUnpinBatchDouble-8           52.7kB ± 0%    52.7kB ± 0%    -0.12%  (p=0.008 n=5+5)
PinnerPinUnpinBatchTiny-8             20.1kB ± 0%    20.0kB ± 0%    -0.32%  (p=0.008 n=5+5)
PinnerPinUnpin-8                       64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinTiny-8                   64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinDouble-8                 64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallel-8               64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallelTiny-8           64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallelDouble-8         64.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
PinnerIsPinnedOnPinned-8               0.00B          0.00B           ~     (all equal)
PinnerIsPinnedOnUnpinned-8             0.00B          0.00B           ~     (all equal)
PinnerIsPinnedOnPinnedParallel-8       0.00B          0.00B           ~     (all equal)
PinnerIsPinnedOnUnpinnedParallel-8     0.00B          0.00B           ~     (all equal)

name                                old allocs/op  new allocs/op  delta
PinnerPinUnpinBatch-8                   9.00 ± 0%      8.00 ± 0%   -11.11%  (p=0.008 n=5+5)
PinnerPinUnpinBatchDouble-8             11.0 ± 0%      10.0 ± 0%    -9.09%  (p=0.008 n=5+5)
PinnerPinUnpinBatchTiny-8               9.00 ± 0%      8.00 ± 0%   -11.11%  (p=0.008 n=5+5)
PinnerPinUnpin-8                        1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinTiny-8                    1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinDouble-8                  1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallel-8                1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallelTiny-8            1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerPinUnpinParallelDouble-8          1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
PinnerIsPinnedOnPinned-8                0.00           0.00           ~     (all equal)
PinnerIsPinnedOnUnpinned-8              0.00           0.00           ~     (all equal)
PinnerIsPinnedOnPinnedParallel-8        0.00           0.00           ~     (all equal)
PinnerIsPinnedOnUnpinnedParallel-8      0.00           0.00           ~     (all equal)

For #46787.

Change-Id: I0cdfad77b189c425868944a4faeff3d5b97417b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497615
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ansiwen <ansiwen@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoruntime: move pinned object out of inner loop for benchmarks
Michael Anthony Knyszek [Tue, 23 May 2023 21:02:36 +0000 (21:02 +0000)]
runtime: move pinned object out of inner loop for benchmarks

In theory by allocating new objects every time, the benchmark is
including the performance of allocating new pinner bits for a span. In
practice however, most of the time each span already does have pinner
bits allocated (it's still a rare operation).

We can get a better sense of the raw cost of pinning an object (minus
pinner bits allocation) by moving the object allocation out of the inner
loop.

Change-Id: I2869fa6c3f353b726fe8440d2e6b7f89902f9364
Reviewed-on: https://go-review.googlesource.com/c/go/+/497620
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

12 months agocrypto/x509: properly apply name constrains to roots and intermediates
Roland Shoemaker [Tue, 21 Mar 2023 20:45:18 +0000 (13:45 -0700)]
crypto/x509: properly apply name constrains to roots and intermediates

Name constraints are checked during path building. When a new
certificate is considered for inclusion in a chain we check if it has
name constraints, and if it does, check that they apply to the certs
already in the chain, discarding it if the current chain violates any
of the constraints the candidate introduces.

This check was not acting as intended in two ways. The first was that
we only checked that the constraints on the candidate certificate
applied to the leaf certificate, and not the rest of the certiifcates in
the chain. This was the intended behavior pre-1.19, but in 1.19 we
intended for the constraints to be applied to the entire chain (although
obviously they were not).

The second was that we checked that the candidates constraints applied
to the candidate itself. This is not conformant with RFC 5280, which
says that during path building the constraint should only be applied to
the certificates which follow the certificate which introduces the
constraint (e.g. in the chain A -> B -> C, if certificate Bcontains a
name constraint, the constraint should only apply to certificate C).

The intended behavior introduced in 1.19 was mainly intended to reject
dubious chains which the WebPKI disallows, and are relatively rare, but
don't have significant security impact. Since the constraints were
properly applied to the leaf certificate, there should be no real impact
to the majority of users.

Fixes #59171

Change-Id: Ie6def55b8ab7f14d6ed2c09351f664e148a4160d
Reviewed-on: https://go-review.googlesource.com/c/go/+/478216
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoos: implement fs.ReadFileFS for DirFS
Sean Liao [Sat, 9 Jul 2022 18:08:59 +0000 (19:08 +0100)]
os: implement fs.ReadFileFS for DirFS

Use the os.ReadFile implementation to handle
sysfs files not reporting size properly via stat.

Fixes #53761

Change-Id: I6f34515e8a211e3659f4f6c3598fae7ec0c86975
Reviewed-on: https://go-review.googlesource.com/c/go/+/416775
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agoall: fix unavailable url
cui fliter [Wed, 24 May 2023 02:45:15 +0000 (10:45 +0800)]
all: fix unavailable url

RISC-V modified the address of github and the suffix of the file.

The previous link is no longer accessible. use latest link.

Change-Id: I5e33ea8447a59b8183658248df05c79ddd380cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/497378
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agocmd/compile: optimize math.Float32bits and math.Float32frombits on mipsx
Junxian Zhu [Fri, 12 May 2023 04:28:51 +0000 (12:28 +0800)]
cmd/compile: optimize math.Float32bits and math.Float32frombits on mipsx

This CL use MFC1/MTC1 instructions to move data between GPR and FPR instead of stores and loads to move float/int values.

goos: linux
goarch: mipsle
pkg: math
                      │   oldmathf   │              newmathf              │
                      │    sec/op    │   sec/op     vs base               │
Acos-4                   282.7n ± 0%   282.1n ± 0%   -0.18% (p=0.010 n=8)
Acosh-4                  450.8n ± 0%   450.9n ± 0%        ~ (p=0.699 n=8)
Asin-4                   272.6n ± 0%   272.1n ± 0%        ~ (p=0.050 n=8)
Asinh-4                  476.8n ± 0%   475.1n ± 0%   -0.35% (p=0.018 n=8)
Atan-4                   208.1n ± 0%   207.7n ± 0%   -0.17% (p=0.009 n=8)
Atanh-4                  448.8n ± 0%   448.7n ± 0%   -0.03% (p=0.014 n=8)
Atan2-4                  310.2n ± 0%   310.1n ± 0%        ~ (p=0.133 n=8)
Cbrt-4                   357.9n ± 0%   358.4n ± 0%   +0.11% (p=0.014 n=8)
Ceil-4                   203.8n ± 0%   204.7n ± 0%   +0.42% (p=0.008 n=8)
Compare-4                21.12n ± 0%   22.09n ± 0%   +4.59% (p=0.000 n=8)
Compare32-4             19.105n ± 0%   6.022n ± 0%  -68.48% (p=0.000 n=8)
Copysign-4               33.17n ± 0%   33.15n ± 0%        ~ (p=0.795 n=8)
Cos-4                    385.2n ± 0%   384.8n ± 1%        ~ (p=0.112 n=8)
Cosh-4                   546.0n ± 0%   545.0n ± 0%   -0.17% (p=0.012 n=8)
Erf-4                    192.4n ± 0%   195.4n ± 1%   +1.59% (p=0.000 n=8)
Erfc-4                   187.8n ± 0%   192.7n ± 0%   +2.64% (p=0.000 n=8)
Erfinv-4                 221.8n ± 1%   219.8n ± 0%   -0.88% (p=0.000 n=8)
Erfcinv-4                224.1n ± 1%   219.9n ± 0%   -1.87% (p=0.000 n=8)
Exp-4                    434.7n ± 0%   435.0n ± 0%        ~ (p=0.339 n=8)
ExpGo-4                  433.7n ± 0%   434.2n ± 0%   +0.13% (p=0.005 n=8)
Expm1-4                  243.0n ± 0%   242.9n ± 0%        ~ (p=0.103 n=8)
Exp2-4                   426.6n ± 0%   426.6n ± 0%        ~ (p=0.822 n=8)
Exp2Go-4                 425.6n ± 0%   425.5n ± 0%        ~ (p=0.377 n=8)
Abs-4                    8.033n ± 0%   8.029n ± 0%        ~ (p=0.065 n=8)
Dim-4                    18.07n ± 0%   18.07n ± 0%        ~ (p=0.051 n=8)
Floor-4                  151.6n ± 0%   151.6n ± 0%        ~ (p=0.450 n=8)
Max-4                    100.9n ± 8%   103.2n ± 2%        ~ (p=0.099 n=8)
Min-4                    116.4n ± 0%   116.4n ± 0%        ~ (p=0.467 n=8)
Mod-4                    959.6n ± 1%   950.9n ± 0%   -0.91% (p=0.006 n=8)
Frexp-4                  147.6n ± 0%   147.5n ± 0%   -0.07% (p=0.026 n=8)
Gamma-4                  482.7n ± 0%   478.2n ± 2%   -0.92% (p=0.000 n=8)
Hypot-4                  139.8n ± 1%   127.1n ± 8%   -9.12% (p=0.000 n=8)
HypotGo-4                137.2n ± 7%   117.5n ± 2%  -14.39% (p=0.001 n=8)
Ilogb-4                  109.5n ± 0%   108.4n ± 1%   -1.05% (p=0.001 n=8)
J0-4                     1.304µ ± 0%   1.304µ ± 0%        ~ (p=0.853 n=8)
J1-4                     1.349µ ± 0%   1.331µ ± 0%   -1.33% (p=0.000 n=8)
Jn-4                     2.774µ ± 0%   2.750µ ± 0%   -0.87% (p=0.000 n=8)
Ldexp-4                  151.6n ± 0%   151.5n ± 0%        ~ (p=0.695 n=8)
Lgamma-4                 226.9n ± 0%   233.9n ± 0%   +3.09% (p=0.000 n=8)
Log-4                    407.6n ± 0%   407.4n ± 0%        ~ (p=0.340 n=8)
Logb-4                   121.5n ± 0%   121.5n ± 0%   -0.08% (p=0.042 n=8)
Log1p-4                  315.5n ± 0%   315.6n ± 0%        ~ (p=0.930 n=8)
Log10-4                  417.8n ± 0%   417.5n ± 0%        ~ (p=0.053 n=8)
Log2-4                   208.8n ± 0%   208.8n ± 0%        ~ (p=0.582 n=8)
Modf-4                   126.5n ± 0%   126.4n ± 0%        ~ (p=0.128 n=8)
Nextafter32-4           112.45n ± 0%   82.27n ± 0%  -26.84% (p=0.000 n=8)
Nextafter64-4            141.5n ± 0%   141.5n ± 0%        ~ (p=0.569 n=8)
PowInt-4                 754.0n ± 1%   754.6n ± 0%        ~ (p=0.279 n=8)
PowFrac-4                1.608µ ± 1%   1.596µ ± 1%        ~ (p=0.661 n=8)
Pow10Pos-4               18.07n ± 0%   18.07n ± 0%        ~ (p=0.413 n=8)
Pow10Neg-4               17.08n ± 0%   18.07n ± 0%   +5.80% (p=0.000 n=8)
Round-4                  68.30n ± 0%   69.29n ± 0%   +1.45% (p=0.000 n=8)
RoundToEven-4            78.33n ± 0%   78.34n ± 0%        ~ (p=0.975 n=8)
Remainder-4              740.6n ± 1%   736.7n ± 0%        ~ (p=0.098 n=8)
Signbit-4                18.08n ± 0%   18.07n ± 0%        ~ (p=0.546 n=8)
Sin-4                    389.4n ± 0%   389.5n ± 0%        ~ (p=0.451 n=8)
Sincos-4                 415.6n ± 0%   415.6n ± 0%        ~ (p=0.450 n=8)
Sinh-4                   607.0n ± 0%   590.8n ± 1%   -2.68% (p=0.000 n=8)
SqrtIndirect-4           8.034n ± 0%   8.030n ± 0%        ~ (p=0.487 n=8)
SqrtLatency-4            8.031n ± 0%   8.034n ± 0%        ~ (p=0.152 n=8)
SqrtIndirectLatency-4    8.032n ± 0%   8.032n ± 0%        ~ (p=0.818 n=8)
SqrtGoLatency-4          895.8n ± 0%   895.3n ± 0%        ~ (p=0.553 n=8)
SqrtPrime-4              5.405µ ± 0%   5.379µ ± 0%   -0.48% (p=0.000 n=8)
Tan-4                    405.6n ± 0%   405.7n ± 0%        ~ (p=0.980 n=8)
Tanh-4                   545.1n ± 0%   545.1n ± 0%        ~ (p=0.806 n=8)
Trunc-4                  146.5n ± 0%   146.6n ± 0%        ~ (p=0.380 n=8)
Y0-4                     1.308µ ± 0%   1.306µ ± 0%        ~ (p=0.071 n=8)
Y1-4                     1.311µ ± 0%   1.315µ ± 0%   +0.31% (p=0.000 n=8)
Yn-4                     2.737µ ± 0%   2.745µ ± 0%   +0.27% (p=0.000 n=8)
Float64bits-4            14.56n ± 0%   14.56n ± 0%        ~ (p=0.689 n=8)
Float64frombits-4        19.08n ± 0%   19.08n ± 0%        ~ (p=0.580 n=8)
Float32bits-4           13.050n ± 0%   5.019n ± 0%  -61.54% (p=0.000 n=8)
Float32frombits-4       13.060n ± 0%   4.016n ± 0%  -69.25% (p=0.000 n=8)
FMA-4                    608.5n ± 0%   586.1n ± 0%   -3.67% (p=0.000 n=8)
geomean                  185.5n        176.2n        -5.02%

Change-Id: Ibf91092ffe70104e6c5ec03bc76d51259818b9b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/494535
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
12 months agoRevert "cmd/compile: sparse conditional constant propagation"
Bryan Mills [Wed, 24 May 2023 12:14:38 +0000 (12:14 +0000)]
Revert "cmd/compile: sparse conditional constant propagation"

This reverts CL 483875.

Reason for revert: appears to cause internal compiler errors on the ssacheck builder.

Change-Id: I662418384291470c1962c417797a5890dd9aa7a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/497855
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agoruntime: skip TestCPUMetricsSleep as flaky
Michael Anthony Knyszek [Wed, 24 May 2023 13:51:33 +0000 (13:51 +0000)]
runtime: skip TestCPUMetricsSleep as flaky

This test is fundamentally flaky because of a mismatch between how
internal idle time is calculated and how the test expects it to be
calculated. It's unclear how to resolve this mismatch, given that it's
perfectly valid for a goroutine to remain asleep while background
goroutines (e.g. the scavenger) run. In practice, we might be able to
set some generous lower-bound, but until we can confirm that on the
affected platforms, skip the test as flaky unconditionally.

For #60276.
For #60376.

Change-Id: Iffd5c4be10cf8ae8a6c285b61fcc9173235fbb2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/497876
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: update build info when updating PGO file
Michael Pratt [Mon, 22 May 2023 18:14:44 +0000 (14:14 -0400)]
cmd/go: update build info when updating PGO file

setPGOProfilePath sets Package.Internal.PGOProfile very late in package
loading (because it may split/copy packages). Build info was computed
long before this, causing PGO packages to miss -pgo from their build
settings.

Adjust BuildInfo to be stored as *debug.BuildInfo rather than eagerly
converting to a string. This enables setPGOProfilePath to update the
BuildInfo at the same point that it sets PGOProfile.

Change-Id: Ic12266309bfd0f8ec440b0dc94d4df813b27cb04
Reviewed-on: https://go-review.googlesource.com/c/go/+/496958
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>

12 months agocmd/go: accept trailing text in compiler errors in tests
Bryan C. Mills [Wed, 24 May 2023 12:35:18 +0000 (08:35 -0400)]
cmd/go: accept trailing text in compiler errors in tests

This fixes tests that were broken in CL 497716.

Change-Id: I85fa8f093e04a97b7b83e2f6840f6261e08f59e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/497875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
12 months agomaps,runtime: improve maps.Values
cuiweixie [Mon, 3 Apr 2023 12:14:06 +0000 (20:14 +0800)]
maps,runtime: improve maps.Values

name       old time/op    new time/op    delta
Values-10    8.67ms ± 0%    7.19ms ± 2%  -17.05%  (p=0.000 n=9+10)

name       old alloc/op   new alloc/op   delta
Values-10    58.2kB ± 2%    48.3kB ± 2%  -17.14%  (p=0.000 n=9+10)

name       old allocs/op  new allocs/op  delta
Values-10      0.00           0.00          ~     (all equal)

Change-Id: Idd35ea37514a21d97bdd6191c8fb8a478c00e414
Reviewed-on: https://go-review.googlesource.com/c/go/+/481436
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

12 months agotesting: only report subtest races once
Ian Lance Taylor [Tue, 9 May 2023 22:10:26 +0000 (15:10 -0700)]
testing: only report subtest races once

Before this CL the code would record the number of race detector
errors seen before starting a test, and then report an error
if there were more race detector errors after the test completed.
That approach did not work well for subtests or parallel tests.
Race detector errors could be reported multiple times at each
level of subtest, and parallel tests could accidentally drop
race detector errors.

Instead, report each race detector error at most once, associated
with whatever test noticed the new error. This is still imperfect,
as it may report race detector errors for the wrong parallel test.
But it shouldn't drop any errors entirely, and it shouldn't report
any errors more than once.

Fixes #60083

Change-Id: Ic9afea5c692b6553896757766f631cd0e86192ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/494057
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodatabase/sql: make RawBytes safely usable with contexts
Brad Fitzpatrick [Tue, 23 May 2023 22:12:47 +0000 (15:12 -0700)]
database/sql: make RawBytes safely usable with contexts

sql.RawBytes was added the very first Go release, Go 1. Its docs
say:

> RawBytes is a byte slice that holds a reference to memory owned by
> the database itself. After a Scan into a RawBytes, the slice is only
> valid until the next call to Next, Scan, or Close.

That "only valid until the next call" bit was true at the time,
until contexts were added to database/sql in Go 1.8.

In the past ~dozen releases it's been unsafe to use QueryContext with
a context that might become Done to get an *sql.Rows that's scanning
into a RawBytes. The Scan can succeed, but then while the caller's
reading the memory, a database/sql-managed goroutine can see the
context becoming done and call Close on the database/sql/driver and
make the caller's view of the RawBytes memory no longer valid,
introducing races, crashes, or database corruption. See #60304
and #53970 for details.

This change does the minimal surgery on database/sql to make it safe
again: Rows.Scan was already acquiring a mutex to check whether the
rows had been closed, so this change make Rows.Scan notice whether
*RawBytes was used and, if so, doesn't release the mutex on exit
before returning. That mean it's still locked while the user code
operates on the RawBytes memory and the concurrent context-watching
goroutine to close the database still runs, but if it fires, it then
gets blocked on the mutex until the next call to a Rows method (Next,
NextResultSet, Err, Close).

Updates #60304
Updates #53970 (earlier one I'd missed)

Change-Id: Ie41c0c6f32c24887b2f53ec3686c2aab73a1bfff
Reviewed-on: https://go-review.googlesource.com/c/go/+/497675
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
12 months agocmd/compile: optimize math.Float64(32)bits and math.Float64(32)frombits on mips64x
Junxian Zhu [Tue, 9 May 2023 09:40:06 +0000 (17:40 +0800)]
cmd/compile: optimize math.Float64(32)bits and math.Float64(32)frombits on mips64x

This CL use MFC1/MTC1 instructions to move data between GPR and FPR instead of stores and loads to move float/int values.

goos: linux
goarch: mips64le
pkg: math
                      │   oldmath    │              newmath               │
                      │    sec/op    │   sec/op     vs base               │
Acos-4                   258.2n ± 0%   258.2n ± 0%        ~ (p=0.859 n=8)
Acosh-4                  378.7n ± 0%   323.9n ± 0%  -14.47% (p=0.000 n=8)
Asin-4                   255.1n ± 2%   255.5n ± 0%   +0.16% (p=0.002 n=8)
Asinh-4                  407.1n ± 0%   348.7n ± 0%  -14.35% (p=0.000 n=8)
Atan-4                   189.5n ± 0%   189.9n ± 3%        ~ (p=0.205 n=8)
Atanh-4                  355.6n ± 0%   323.4n ± 2%   -9.03% (p=0.000 n=8)
Atan2-4                  284.1n ± 7%   280.1n ± 4%        ~ (p=0.313 n=8)
Cbrt-4                   314.3n ± 0%   236.4n ± 0%  -24.79% (p=0.000 n=8)
Ceil-4                   144.3n ± 3%   139.6n ± 0%        ~ (p=0.069 n=8)
Compare-4               21.100n ± 0%   7.035n ± 0%  -66.66% (p=0.000 n=8)
Compare32-4             20.100n ± 0%   6.030n ± 0%  -70.00% (p=0.000 n=8)
Copysign-4              34.970n ± 0%   6.221n ± 0%  -82.21% (p=0.000 n=8)
Cos-4                    183.4n ± 3%   184.1n ± 5%        ~ (p=0.159 n=8)
Cosh-4                   487.9n ± 2%   419.6n ± 0%  -14.00% (p=0.000 n=8)
Erf-4                    160.6n ± 0%   157.9n ± 0%   -1.68% (p=0.009 n=8)
Erfc-4                   183.7n ± 4%   169.8n ± 0%   -7.54% (p=0.000 n=8)
Erfinv-4                 191.5n ± 4%   183.6n ± 0%   -4.13% (p=0.023 n=8)
Erfcinv-4                192.0n ± 7%   184.3n ± 0%        ~ (p=0.425 n=8)
Exp-4                    398.2n ± 0%   340.1n ± 4%  -14.58% (p=0.000 n=8)
ExpGo-4                  383.3n ± 0%   327.3n ± 0%  -14.62% (p=0.000 n=8)
Expm1-4                  248.7n ± 5%   216.0n ± 0%  -13.11% (p=0.000 n=8)
Exp2-4                   372.8n ± 0%   316.9n ± 3%  -14.98% (p=0.000 n=8)
Exp2Go-4                 374.1n ± 0%   320.5n ± 0%  -14.33% (p=0.000 n=8)
Abs-4                    3.013n ± 0%   3.016n ± 0%   +0.10% (p=0.020 n=8)
Dim-4                    5.021n ± 0%   5.022n ± 0%        ~ (p=0.270 n=8)
Floor-4                  127.5n ± 4%   126.2n ± 3%        ~ (p=0.186 n=8)
Max-4                    72.32n ± 0%   61.33n ± 0%  -15.20% (p=0.000 n=8)
Min-4                    83.33n ± 1%   61.36n ± 0%  -26.37% (p=0.000 n=8)
Mod-4                    690.7n ± 0%   454.5n ± 0%  -34.20% (p=0.000 n=8)
Frexp-4                 116.30n ± 1%   71.80n ± 1%  -38.26% (p=0.000 n=8)
Gamma-4                  389.0n ± 0%   355.9n ± 1%   -8.48% (p=0.000 n=8)
Hypot-4                 102.40n ± 0%   83.90n ± 0%  -18.07% (p=0.000 n=8)
HypotGo-4               105.45n ± 4%   84.82n ± 2%  -19.56% (p=0.000 n=8)
Ilogb-4                  99.13n ± 4%   63.71n ± 2%  -35.73% (p=0.000 n=8)
J0-4                     859.7n ± 0%   854.8n ± 0%   -0.57% (p=0.000 n=8)
J1-4                     873.9n ± 0%   875.7n ± 0%   +0.21% (p=0.007 n=8)
Jn-4                     1.855µ ± 0%   1.867µ ± 0%   +0.65% (p=0.000 n=8)
Ldexp-4                 130.50n ± 2%   64.35n ± 0%  -50.69% (p=0.000 n=8)
Lgamma-4                 208.8n ± 0%   200.9n ± 0%   -3.78% (p=0.000 n=8)
Log-4                    294.1n ± 0%   255.2n ± 3%  -13.22% (p=0.000 n=8)
Logb-4                  105.45n ± 1%   66.81n ± 1%  -36.64% (p=0.000 n=8)
Log1p-4                  268.2n ± 0%   211.3n ± 0%  -21.21% (p=0.000 n=8)
Log10-4                  295.4n ± 0%   255.2n ± 2%  -13.59% (p=0.000 n=8)
Log2-4                   152.9n ± 1%   127.5n ± 0%  -16.61% (p=0.000 n=8)
Modf-4                  103.40n ± 0%   75.36n ± 0%  -27.12% (p=0.000 n=8)
Nextafter32-4           121.20n ± 1%   78.40n ± 0%  -35.31% (p=0.000 n=8)
Nextafter64-4           110.40n ± 1%   64.91n ± 0%  -41.20% (p=0.000 n=8)
PowInt-4                 509.8n ± 1%   369.3n ± 1%  -27.56% (p=0.000 n=8)
PowFrac-4               1189.0n ± 0%   947.8n ± 0%  -20.29% (p=0.000 n=8)
Pow10Pos-4               15.07n ± 0%   15.07n ± 0%        ~ (p=0.733 n=8)
Pow10Neg-4               20.10n ± 0%   20.10n ± 0%        ~ (p=0.576 n=8)
Round-4                  44.22n ± 0%   26.12n ± 0%  -40.92% (p=0.000 n=8)
RoundToEven-4            46.22n ± 0%   27.12n ± 0%  -41.31% (p=0.000 n=8)
Remainder-4              539.0n ± 1%   417.1n ± 1%  -22.62% (p=0.000 n=8)
Signbit-4               17.985n ± 0%   5.694n ± 0%  -68.34% (p=0.000 n=8)
Sin-4                    185.7n ± 5%   172.9n ± 0%   -6.89% (p=0.001 n=8)
Sincos-4                 176.6n ± 0%   200.9n ± 0%  +13.76% (p=0.000 n=8)
Sinh-4                   495.8n ± 0%   435.9n ± 0%  -12.09% (p=0.000 n=8)
SqrtIndirect-4           5.022n ± 0%   5.024n ± 0%        ~ (p=0.083 n=8)
SqrtLatency-4            8.038n ± 0%   8.044n ± 0%        ~ (p=0.524 n=8)
SqrtIndirectLatency-4    8.035n ± 0%   8.039n ± 0%   +0.06% (p=0.017 n=8)
SqrtGoLatency-4          340.1n ± 0%   278.3n ± 0%  -18.19% (p=0.000 n=8)
SqrtPrime-4              5.381µ ± 0%   5.386µ ± 0%        ~ (p=0.662 n=8)
Tan-4                    198.6n ± 1%   183.1n ± 0%   -7.85% (p=0.000 n=8)
Tanh-4                   491.3n ± 1%   440.8n ± 1%  -10.29% (p=0.000 n=8)
Trunc-4                  121.7n ± 0%   121.7n ± 0%        ~ (p=0.769 n=8)
Y0-4                     855.1n ± 0%   859.8n ± 0%   +0.54% (p=0.007 n=8)
Y1-4                     862.3n ± 0%   865.1n ± 0%   +0.32% (p=0.007 n=8)
Yn-4                     1.830µ ± 0%   1.837µ ± 0%   +0.36% (p=0.011 n=8)
Float64bits-4           13.060n ± 0%   3.016n ± 0%  -76.91% (p=0.000 n=8)
Float64frombits-4       13.060n ± 0%   3.018n ± 0%  -76.90% (p=0.000 n=8)
Float32bits-4           13.060n ± 0%   3.016n ± 0%  -76.91% (p=0.000 n=8)
Float32frombits-4       13.070n ± 0%   3.013n ± 0%  -76.94% (p=0.000 n=8)
FMA-4                    446.0n ± 0%   413.1n ± 1%   -7.38% (p=0.000 n=8)
geomean                  143.4n        108.3n       -24.49%

Change-Id: I2067f7a5ae1126ada7ab3fb2083710e8212535e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/493815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

12 months agointernal/types/errors: generate Markdown files for compiler errors
Carlos Amedee [Wed, 17 May 2023 21:45:37 +0000 (17:45 -0400)]
internal/types/errors: generate Markdown files for compiler errors

This change adds a generator which creates a Markdown file for each
compiler error code which includes its associated documentation. The
Markdown files will be added to the x/website repository and used
to generate short error links on the Go website.

Change-Id: Ibabc3388d6ecc7f19151f3931554f72561e30b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/495858
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: sparse conditional constant propagation
Yi Yang [Thu, 18 May 2023 11:17:11 +0000 (11:17 +0000)]
cmd/compile: sparse conditional constant propagation

sparse conditional constant propagation can discover optimization opportunities that cannot be found by just combining constant folding and constant propagation and dead code elimination separately.

Updates #59399

Change-Id: Ia954e906480654a6f0cc065d75b5912f96f36b2e
GitHub-Last-Rev: 90fc02db99f817b7f0ce5c584642ab1b166e62d7
GitHub-Pull-Request: golang/go#59575
Reviewed-on: https://go-review.googlesource.com/c/go/+/483875
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

12 months agocmd/compile: enable printing of error URLs by default
Robert Griesemer [Tue, 23 May 2023 23:45:37 +0000 (16:45 -0700)]
cmd/compile: enable printing of error URLs by default

Change-Id: Ib4094c70b8aa5e818f9f017c59d464d4c178169d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497716
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/asm: refine some APIs related to Prog.RestArgs[]
ruinan [Wed, 12 Apr 2023 03:23:13 +0000 (11:23 +0800)]
cmd/asm: refine some APIs related to Prog.RestArgs[]

Before this CL, we use GetFrom3&SetFrom3 to get or set a source operand
which not fit into Prog.Reg. Those APIs operate the first element in
Prog.RestArgs without checking the type so they're fragile to break if
we have more than one different type of operands in the slice, which
will be a common case in Arm64.

This CL deprecates & renames some APIs related to Prog.RestArgs to make
those APIs more reasonable and robust than before.

Change-Id: I70d56edc1f23ccfffbcd6df34844e2cef2288432
Reviewed-on: https://go-review.googlesource.com/c/go/+/493355
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>

12 months agoruntime: pad work.full and pad.empty to avoid false sharing
Li [Mon, 22 May 2023 09:00:40 +0000 (17:00 +0800)]
runtime: pad work.full and pad.empty to avoid false sharing

With the Garbage collector (GC), we observed a false-sharing between
work.full and work.empty. (referenced most from runtime.gcDrain and
runtime.getempty)

This false-sharing becomes worse and impact performance on multi core
system. On Intel Xeon 8480+ and default GC setting(GC=100), we can
observed top HITM>4% (by perf c2c)caused by it.

After resolveed this false-sharing issue, we can get performance 8%~9.7%
improved. Verify workloads:

DeathStarBench/hotelReservation: 9.7% of RPS improved
https://github.com/delimitrou/DeathStarBench/tree/master/hotelReservation

gRPC-go/benchmark: 8% of RPS improved
https://github.com/grpc/grpc-go/tree/master/benchmark

gRPC-go/benchmark 9 iterations' data with master branch:
master         w/ fs opt.
208862.4 246390.9
221680.0 266019.3
223886.9 248789.7
212169.3 257837.8
219922.4 234331.8
197401.7 261627.7
214562.4 255429.7
214328.5 237087.8
229443.2 230591.3

max 229443.2 266019.3 116%
med 214562.4 248789.7 116%
avg 215806.3 248678.5 115%

Change-Id: Ib386de021cd2dbb802a107f487556d848ba9212d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496915
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

12 months agocmd/go: add mod edit -toolchain and work edit -toolchain
Russ Cox [Mon, 22 May 2023 16:26:15 +0000 (12:26 -0400)]
cmd/go: add mod edit -toolchain and work edit -toolchain

We have added a new toolchain directive in go.mod and go.work.
This CL adds support in mod edit and work edit for changing the toolchain line.

For #57001.

Change-Id: I36a960796630a359b8a587877cb9548c299d5c87
Reviewed-on: https://go-review.googlesource.com/c/go/+/497296
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd: go get golang.org/x/mod@fc83a8f
Russ Cox [Mon, 22 May 2023 15:14:48 +0000 (11:14 -0400)]
cmd: go get golang.org/x/mod@fc83a8f

cd src/cmd
go get golang.org/x/mod@fc83a8f  # CL 497400
go mod vendor
go mod tidy

For #57001.

Change-Id: I46b8584e493934883cc4148a16e287f667dcab7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497295
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoos: make TestProgWideChdir detect more possible failure cases
miller [Wed, 1 Mar 2023 16:55:45 +0000 (16:55 +0000)]
os: make TestProgWideChdir detect more possible failure cases

This test is meant to detect the effect of Chdir not being
observed in other concurrent goroutines, possible in Plan 9
because each M runs in a separate OS process with its own
working directory. The test depends on Getwd to report the
correct working directory, but if Chdir fails then Getwd
may fail for the same reasons. We add a consistency check
that Stat(Getwd()) and Stat(".") refer to the same file.

Also change channel usage and add a sync.WaitGroup to
ensure test goroutines are not left blocked or running
when the main test function exits.

For #58802

Change-Id: I80d554fcf3617427c28bbe16e5e396367dcfe673
Reviewed-on: https://go-review.googlesource.com/c/go/+/472555
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

12 months agocmd/compile: report an error URL with error messages
Robert Griesemer [Tue, 23 May 2023 22:50:13 +0000 (15:50 -0700)]
cmd/compile: report an error URL with error messages

In the type checkers, add Config.ErrorURL (or Config._ErrorURL for
go/types) to configure whether and how an error message should report
a URL for errors that have an error code.

In the compiler, configure types2 to report an error URL of the form
" [go.dev/e/XXX]", where XXX stands for the error code, with the URL
appended to the first line of an error.

Rename the compiler flag -url to -errorurl. At the moment this flag
is disabled by default.

Example for a one-line error message:

<pos>: undefined: f [go.dev/e/UndeclaredName]

Example for a multi-line error message:

<pos>: not enough arguments in call to min [go.dev/e/WrongArgCount]
have ()
want (P, P)

Change-Id: I26651ce2c92ad32fddd641f003db37fe12fdb1cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/497715
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agoslices: add sorting and comparison functions
Eli Bendersky [Fri, 19 May 2023 17:10:21 +0000 (10:10 -0700)]
slices: add sorting and comparison functions

Now that the `cmp` package exists, sorting and comparison functions from
`x/exp/slices` can be ported to the standard library, using the
`cmp.Ordered` type and the `cmp.Less` and `cmp.Compare` functions.

This move also includes adjustments to the discussions in #60091 w.r.t.
NaN handling and cmp vs. less functions, and adds Min/Max functions.
The final API is taken from
https://github.com/golang/go/issues/60091#issuecomment-1553850782

Updates #60091

Change-Id: Id7e6c88035b60d4ddd0c48dd82add8e8bc4e22d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496078
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Eli Bendersky‎ <eliben@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types, types2: enable interface inference
Robert Griesemer [Tue, 23 May 2023 21:32:41 +0000 (14:32 -0700)]
go/types, types2: enable interface inference

This CL sets enableInterfaceInference to true.
If problems arise due to this during the freeze, revert this CL.

Fixes #41176.
Fixes #57192.

Change-Id: I881ea6842e9c1101b24d9780323c6af365a40d3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497657
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agogo/types, types2: consider shared methods when unifying against interfaces
Robert Griesemer [Tue, 23 May 2023 21:29:12 +0000 (14:29 -0700)]
go/types, types2: consider shared methods when unifying against interfaces

When unifying two types A and B where one or both of them are
interfaces, consider the shared method signatures in unification.

1) If a defined interface (an interface with a type name) is unified
   with another (defined) interface, currently they must originate
   in the same type declaration (same origin) for unification to
   succeed. This is more restrictive than necessary for assignments:
   when interfaces are assigned to each other, corresponding methods
   must match, but the interfaces don't have to be identical.
   In unification, we don't know which direction the assignment is
   happening (or if we have an assignment in the first place), but
   in any case one interface must implement the other. Thus, we
   check that one interface has a subset of the methods of the other
   and that corresponding method signatures unify.
   The assignment or instantiation may still not be possible but that
   will be checked when instantiation and parameter passing is checked.
   If two interfaces are compared as part of another type during
   unification, the types must be equal. If they are not, unifying
   a method subset may still succeed (and possibly produce more type
   arguments), but that is ok: again, subsequent instantiation and
   assignment will fail if the types are indeed not identical.

2) In a non-interface type is unified with an interface, currently
   unification fails. If this unification is a consequence of an
   assignment (parameter passing), this is again too restrictive:
   the non-interface type must only implement the interface (possibly
   among other type set requirements). In any case, all methods of the
   interface type must be present in the non-interface type and unify
   with the corresponding interface methods. If they don't, unification
   will fail either way. If they do, we may infer additional type
   arguments. Again, the resulting types may still not be correct but
   that will be determined by the instantiation and parameter passing
   or assignment checks. If the non-interface type and the interface
   type appear as component of another type, unification may now
   produce additional type arguments. But that is again ok because the
   respective types won't pass instantiation or assignment checks since
   they are different types.

This CL introduces a new unifier flag, enableInterfaceInference, to
enable this new behavior. It is currently disabled.

For #60353.
For #41176.
For #57192.

Change-Id: I983d0ad5f043c7fe9d377dbb95f6b9342f36f45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497656
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agodebug/elf: define R_PPC64_REL24_P9NOTOC
Paul E. Murphy [Mon, 22 May 2023 15:38:12 +0000 (10:38 -0500)]
debug/elf: define R_PPC64_REL24_P9NOTOC

This relocation is not (yet?) defined in ELFv2, but has been added to
gnu gas a couple years ago. It is the same reloc as
R_PPC64_REL24_NOTOC, but hints power10 instructions should not be
emitted.

See binutils commit 7aba54da426b9999085d8f84e7896b8afdbb9ca6.

Fixes #60348

Change-Id: Ie953cd7bf1ffc621b498d4dbebb5de1231833c8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496918
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoruntime: move pinner variable into inner loop for benchmarks
Michael Anthony Knyszek [Tue, 23 May 2023 19:17:51 +0000 (19:17 +0000)]
runtime: move pinner variable into inner loop for benchmarks

Currently the pinner is created outside of the benchmarking loop.
However, this means that we get to reuse the same pinner for each loop;
in general, users are expected to create a pinner for a e.g. a cgo
call and then that variable will expire with the frame it lives in. (If
they can reuse the variable, great! However, I don't expect that to be
common.)

In essence, this benchmarks a harder case. It's not more right or wrong
than the previous version, but the fact that it's a slightly harder case
(that still mostly captures what the original version was capturing) is
useful.

Change-Id: I94987127f54d7bfecd7b8e6a5e632631ea57ad24
Reviewed-on: https://go-review.googlesource.com/c/go/+/497616
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoRevert "go/types, types2: consider shared methods when unifying against interfaces"
Robert Griesemer [Tue, 23 May 2023 21:03:28 +0000 (21:03 +0000)]
Revert "go/types, types2: consider shared methods when unifying against interfaces"

This reverts commit c4afec232cec72ce030139ae2772450fad89f188.

Reason for revert: submitted accidentally via auto-commit

Change-Id: Idbfd90a4f1c2d582d86fc8aa45e037c406adbd40
Reviewed-on: https://go-review.googlesource.com/c/go/+/497655
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

12 months agogo/types, types2: consider shared methods when unifying against interfaces
Robert Griesemer [Fri, 19 May 2023 15:28:24 +0000 (08:28 -0700)]
go/types, types2: consider shared methods when unifying against interfaces

When unifying two types A and B where one or both of them are
interfaces, consider the shared method signatures in unification.

1) If a defined interface (an interface with a type name) is unified
   with another (defined) interface, currently they must originate
   in the same type declaration (same origin) for unification to
   succeed. This is more restrictive than necessary for assignments:
   when interfaces are assigned to each other, corresponding methods
   must match, but the interfaces don't have to be identical.
   In unification, we don't know which direction the assignment is
   happening (or if we have an assignment in the first place), but
   in any case one interface must implement the other. Thus, we
   check that one interface has a subset of the methods of the other
   and that corresponding method signatures unify.
   The assignment or instantiation may still not be possible but that
   will be checked when instantiation and parameter passing is checked.
   If two interfaces are compared as part of another type during
   unification, the types must be equal. If they are not, unifying
   a method subset may still succeed (and possibly produce more type
   arguments), but that is ok: again, subsequent instantiation and
   assignment will fail if the types are indeed not identical.

2) In a non-interface type is unified with an interface, currently
   unification fails. If this unification is a consequence of an
   assignment (parameter passing), this is again too restrictive:
   the non-interface type must only implement the interface (possibly
   among other type set requirements). In any case, all methods of the
   interface type must be present in the non-interface type and unify
   with the corresponding interface methods. If they don't, unification
   will fail either way. If they do, we may infer additional type
   arguments. Again, the resulting types may still not be correct but
   that will be determined by the instantiation and parameter passing
   or assignment checks. If the non-interface type and the interface
   type appear as component of another type, unification may now
   produce additional type arguments. But that is again ok because the
   respective types won't pass instantiation or assignment checks since
   they are different types.

This CL introduces a new Config flag, EnableInterfaceInference, to
enable this new behavior. If not set, unification remains unchanged.
To be able to test the flag durign unification, a *Checker is passed
and stored with the unifier.

For #60353.
Fixes #41176.
Fixes #57192.

Change-Id: I6b167a9afa378d0682e9b101d9d86f5777308af7
Reviewed-on: https://go-review.googlesource.com/c/go/+/497015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agofmt,math/big,net/url: fixes to old Benchmarks
Egon Elbre [Mon, 22 May 2023 19:40:47 +0000 (22:40 +0300)]
fmt,math/big,net/url: fixes to old Benchmarks

b.ResetTimer used to also stop the timer, however it does not anymore.
These benchmarks hadn't been fixed and as a result ended up measuring
some additional things.

Also, make some for loops more conventional.

Change-Id: I76ca68456d85eec51722a80587e5b2c9f5d836a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/496996
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agolog/slog: JSONHandler doesn't use special source format
Sean Liao [Sun, 21 May 2023 14:34:43 +0000 (15:34 +0100)]
log/slog: JSONHandler doesn't use special source format

Fixes #60329

Change-Id: Idb19da4830fa14c459bedbf143d550ce7c1dfdbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/496815
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/internal/goobj: update builtin list
Guoqi Chen [Thu, 20 Apr 2023 04:22:27 +0000 (12:22 +0800)]
cmd/internal/goobj: update builtin list

Change-Id: I8a903b76d80f451b498b145b14c97f96191e05f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/486775
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoencoding: document when marshaling methods can be added
Sean Liao [Sun, 21 May 2023 14:16:48 +0000 (15:16 +0100)]
encoding: document when marshaling methods can be added

Fixes #10275

Change-Id: I2b3d54f3eb0f85d65324ddc3c3b2a797d42a16c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/496537
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoos: avoid second fcntl syscall in NewFile on unix
Tobias Klauser [Mon, 22 May 2023 18:37:05 +0000 (20:37 +0200)]
os: avoid second fcntl syscall in NewFile on unix

CL 494915 introduced an additional fcntl(F_GETFL) syscall to determine
whether the file is in append-only mode. The existing unix.IsNonblock
call also issues an fcntl(F_GETFL) syscall. The two can be combined and
both the append-only mode and the non-blocking flags can be determined
from that syscall's result.

Change-Id: I915589ed94e079f6abaa2fd0032ef01f78698f7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497075
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

12 months agoruntime: remove unused _F_{GET,SET}FL constants on solaris and openbsd
Tobias Klauser [Mon, 22 May 2023 18:55:07 +0000 (20:55 +0200)]
runtime: remove unused _F_{GET,SET}FL constants on solaris and openbsd

These are only needed on aix and darwin.

Change-Id: Iea67e4631197359f2bec346ef7d7b723ca23646e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497076
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types: update TestStdlib to type-check concurrently
Rob Findley [Fri, 14 Apr 2023 00:52:53 +0000 (20:52 -0400)]
go/types: update TestStdlib to type-check concurrently

In order to have some test coverage of concurrent use of the go/types
APIs, update the Stdlib test to type-check concurrently. In combination
with non-deterministic ordering, this should hopefully provide moderate
test coverage of concurrent use.

Also, remove the arbitrary 10ms timeout in short mode, in favor of
simply not running.

After this change, TestStdlib went from taking 16s on my laptop to 2s,
in part because of the parallelism and in part because we are no longer
type-checking twice (once for the import er, once for the test).

Fixes golang/go#47729

Change-Id: Ie49743947ab2d5aec051c3d09ce045acf5b94ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/484540
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>

12 months agocmd/internal/objabi: regenerate RelocType strings
Ian Lance Taylor [Tue, 23 May 2023 18:54:44 +0000 (11:54 -0700)]
cmd/internal/objabi: regenerate RelocType strings

Change-Id: I6c9a8decb5b261be4548f148739b44e8860c5f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497595
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/compile: avoid slicebytetostring call in len(string([]byte))
Cuong Manh Le [Tue, 23 May 2023 04:23:48 +0000 (11:23 +0700)]
cmd/compile: avoid slicebytetostring call in len(string([]byte))

Change-Id: Ie04503e61400a793a6a29a4b58795254deabe472
Reviewed-on: https://go-review.googlesource.com/c/go/+/497276
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoruntime/metrics: refactor CPU stats accumulation
Michael Anthony Knyszek [Thu, 18 May 2023 16:35:11 +0000 (16:35 +0000)]
runtime/metrics: refactor CPU stats accumulation

Currently the CPU stats are only updated once every mark termination,
but for writing robust tests, it's often useful to force this update.
Refactor the CPU stats accumulation out of gcMarkTermination and into
its own function. This is also a step toward real-time CPU stats.

While we're here, fix some incorrect documentation about dedicated GC
CPU time.

For #59749.
For #60276.

Change-Id: I8c1a9aca45fcce6ce7999702ae4e082853a69711
Reviewed-on: https://go-review.googlesource.com/c/go/+/487215
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoruntime: fix usage of stale "now" value for netpolling Ms
Michael Anthony Knyszek [Thu, 18 May 2023 15:51:57 +0000 (15:51 +0000)]
runtime: fix usage of stale "now" value for netpolling Ms

Currently pidleget gets passed "now" from before the M goes into
netpoll, resulting in incorrect accounting of idle CPU time.
lastpoll is also stored with a stale "now": the mistake was added in the
same CL it was added for pidleget.

Recompute "now" after returning from netpoll.

Also, start tracking idle time on js/wasm at all.

Credit to Rhys Hiltner for the test case.

Fixes #60276.

Change-Id: I5dd677471f74c915dfcf3d01621430876c3ff307
Reviewed-on: https://go-review.googlesource.com/c/go/+/496183
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agoruntime/metrics: add /gc/scan/total:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/total:bytes

For #56857

Change-Id: I10dbc5db506c95b7578c2b6baf051a351f68bb2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/497576
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoruntime/metrics: add /gc/scan/heap:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/heap:bytes

For #56857

Change-Id: If3b962f575c33b2cc29f89e33c7aafb476d98ce9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497575
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agoruntime/metrics: add /gc/scan/globals:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/globals:bytes

For #56857

Change-Id: I748fd2a33ee76d9a83ea42f2ebf6d9edda243301
Reviewed-on: https://go-review.googlesource.com/c/go/+/497320
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/metrics: add /gc/scan/stack:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:30:43 +0000 (12:30 +0200)]
runtime/metrics: add /gc/scan/stack:bytes

For #56857

Change-Id: I58187d7c4112b35951014ab14f2969bed7f4c8e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/497319
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/metrics: add /gc/gogc:percent
Felix Geisendörfer [Tue, 23 May 2023 09:26:22 +0000 (11:26 +0200)]
runtime/metrics: add /gc/gogc:percent

For #56857

Change-Id: I7e7d2ea3e6ab59291a4cd867c680605ad75bd21f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497317
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agoruntime/metrics: add /gc/gomemlimit:bytes
Felix Geisendörfer [Tue, 23 May 2023 09:16:28 +0000 (11:16 +0200)]
runtime/metrics: add /gc/gomemlimit:bytes

For #56857

Change-Id: I184d752cc615874ada3d0dbc6ed1bf72c8debd0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497316
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
12 months agoruntime: symbolize wrappers as a last resort in race tracebacks
Austin Clements [Mon, 22 May 2023 23:12:54 +0000 (19:12 -0400)]
runtime: symbolize wrappers as a last resort in race tracebacks

CL 466099 rewrote stack symbolization in race reports. Prior to this
CL, physical frames consisting entirely of wrapper logical frame would
print the wrapper, even though in other cases we try to avoid
printing wrappers. CL 466099 unintentionally changed this behavior and
now physical frames consisting entirely of wrapper frames instead fail
to symbolize and print "??()".

Fix this by taking the outermost wrapper frame if the entire logical
frame expansion consists of wrappers.

Fixes #60245.

Change-Id: I13de8857e508b757ea10d1fc7a47258d7fddbfdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/497235
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>

12 months agoruntime/metrics: add /gc/heap/live:bytes
Felix Geisendörfer [Mon, 21 Nov 2022 21:41:54 +0000 (21:41 +0000)]
runtime/metrics: add /gc/heap/live:bytes

For #56857

Change-Id: I0622af974783ab435e91b9fb3c1ba43f256ee4ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/497315
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agocmd/go: convert semver.IsValid to gover.ModIsValid
Russ Cox [Tue, 23 May 2023 14:29:47 +0000 (10:29 -0400)]
cmd/go: convert semver.IsValid to gover.ModIsValid

Change-Id: Id584c4bd6d1c12fd085414188bc7e7ca08164c04
Reviewed-on: https://go-review.googlesource.com/c/go/+/497416
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: convert semver.Compare to gover.ModCompare
Russ Cox [Tue, 23 May 2023 17:22:45 +0000 (13:22 -0400)]
cmd/go: convert semver.Compare to gover.ModCompare

This sets up for introducing the 'go' and 'toolchain' modules
but should be a no-op by itself.

For #57001.

Change-Id: I2e02b5d417f1edd4f4653b101e4975fe23093f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/497456
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: clean up old readEnvFile code
Russ Cox [Tue, 23 May 2023 17:42:22 +0000 (13:42 -0400)]
cmd/go: clean up old readEnvFile code

Now that cfg.CanGetenv does the right thing, we don't need a separate
readEnvFile in 'go env'.

Change-Id: I187c8615ad074ba132516bcf499f82877a32d5e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/497457
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: implement min/max builtins
Matthew Dempsky [Fri, 19 May 2023 00:16:03 +0000 (17:16 -0700)]
cmd/compile: implement min/max builtins

Updates #59488.

Change-Id: I254da7cca071eeb5af2f8aecdcd9461703fe8677
Reviewed-on: https://go-review.googlesource.com/c/go/+/496257
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
12 months agocmd/go: set default GOTOOLCHAIN in GOROOT/go.env
Russ Cox [Tue, 23 May 2023 16:37:01 +0000 (12:37 -0400)]
cmd/go: set default GOTOOLCHAIN in GOROOT/go.env

As part of the work for #57179 we moved configurable defaults
to GOROOT/go.env, so that packagers don't have to modify
source code to change those defaults. Since packagers may want
to modify GOTOOLCHAIN's default, move it to go.env too.

This CL modifies 'go env' to print GOTOOLCHAIN by default.
It also refines CL 496957 from yesterday to recognize any env
var in either go.env or the user go/env, not just the user go/env.
When I put GOTOOLCHAIN in go.env, but before I added it to
the default printing list, 'go env GOTOOLCHAIN' was printing
an empty string, and it was incredibly confusing.

For #57001.
Fixes #60361 while we're here.

Also includes a fix for a review comment on CL 497079 that I forgot to mail.

Change-Id: I7b904d9202f05af789aaa33aed93f903b515aa28
Reviewed-on: https://go-review.googlesource.com/c/go/+/497437
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agoruntime: add partial lock order between mspanSpecial and gcBitsArenas
Michael Anthony Knyszek [Tue, 23 May 2023 17:15:21 +0000 (17:15 +0000)]
runtime: add partial lock order between mspanSpecial and gcBitsArenas

CL 493275 started using gcBits for pinner bits. This means gcBits can be
allocated while holding the mspanSpecial lock. This is safe because
these were just parallel in the partial order, but now they need an
explicit edge between them.

For #58277.

Change-Id: I37917730e12d59cf0580f198d732198413a56424
Reviewed-on: https://go-review.googlesource.com/c/go/+/497475
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agocmd/compile: build compiler with PGO
Cherry Mui [Mon, 15 May 2023 20:42:45 +0000 (16:42 -0400)]
cmd/compile: build compiler with PGO

Reapples CL 495596, which was reverted at CL 496185. The x/tools
failure, #60263, has been resolved. The ppc64 failures, #60368, have
_not_ been resolved, but are believed to be specific to that port. This
CL will make ppc64 flaky while the issue is investigated, but give more
soak time on primary ports.

Build the compiler with PGO. As go build -pgo=auto is enabled by
default, we just need to store a profile in the compiler's
directory.

The profile is collected from building all std and cmd packages on
Linux/AMD64 machine, using profile.sh.

This improves the compiler speed. On Linux/AMD64,
name        old time/op       new time/op       delta
Template          138ms ± 5%        136ms ± 4%  -1.44%  (p=0.005 n=36+39)
Unicode           147ms ± 4%        140ms ± 4%  -4.99%  (p=0.000 n=40+39)
GoTypes           780ms ± 3%        778ms ± 4%    ~     (p=0.172 n=39+39)
Compiler          105ms ± 5%         99ms ± 7%  -5.64%  (p=0.000 n=40+40)
SSA               5.83s ± 6%        5.80s ± 6%    ~     (p=0.556 n=40+40)
Flate            89.0ms ± 5%       87.0ms ± 6%  -2.18%  (p=0.000 n=40+40)
GoParser          172ms ± 4%        167ms ± 4%  -2.72%  (p=0.000 n=39+40)
Reflect           333ms ± 4%        333ms ± 3%    ~     (p=0.426 n=40+39)
Tar               128ms ± 4%        126ms ± 4%  -1.82%  (p=0.000 n=39+39)
XML               173ms ± 4%        170ms ± 4%  -1.39%  (p=0.000 n=39+40)
[Geo mean]        253ms             248ms       -2.13%

The profile is pretty transferable. Using the same profile, we
see a bigger win on Darwin/ARM64,
name        old time/op       new time/op       delta
Template         71.0ms ± 2%       68.3ms ± 2%  -3.90%  (p=0.000 n=20+20)
Unicode          71.8ms ± 2%       66.8ms ± 2%  -6.90%  (p=0.000 n=20+20)
GoTypes           444ms ± 1%        428ms ± 1%  -3.53%  (p=0.000 n=19+20)
Compiler         48.9ms ± 3%       45.6ms ± 3%  -6.81%  (p=0.000 n=20+20)
SSA               3.25s ± 2%        3.09s ± 1%  -5.03%  (p=0.000 n=19+20)
Flate            44.0ms ± 2%       42.3ms ± 2%  -3.72%  (p=0.000 n=19+20)
GoParser         76.7ms ± 1%       73.5ms ± 1%  -4.15%  (p=0.000 n=18+19)
Reflect           172ms ± 1%        165ms ± 1%  -4.13%  (p=0.000 n=20+19)
Tar              63.1ms ± 1%       60.4ms ± 2%  -4.24%  (p=0.000 n=19+20)
XML              83.2ms ± 2%       79.2ms ± 2%  -4.79%  (p=0.000 n=20+20)
[Geo mean]        127ms             121ms       -4.73%

For #60368.

Change-Id: I2cec0fc85e21c38d57ba6f0e5e90cde5d443ebd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/497455
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agodoc: write various runtime-related release notes
Michael Anthony Knyszek [Mon, 22 May 2023 19:23:21 +0000 (19:23 +0000)]
doc: write various runtime-related release notes

This includes release notes for several small runtime changes, including
runtime/trace and runtime package changes.

For #58645.

Change-Id: I3e9c804da1bb6b385088e16a20d9576c11098021
Reviewed-on: https://go-review.googlesource.com/c/go/+/497095
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ansiwen <ansiwen@gmail.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocrypto/rsa: make DecryptPKCS1v15SessionKey warning more dire
Roland Shoemaker [Fri, 17 Feb 2023 19:14:49 +0000 (11:14 -0800)]
crypto/rsa: make DecryptPKCS1v15SessionKey warning more dire

Updates the DecryptPKCS1v15SessionKey function comment to be less cut
and dry about its protections against Bleichenbacher attacks. In
particular note that the protocol using this method must be explicitly
designed with these mitigations in mind, and call out usages which
may cause the migiations to be useless.

Change-Id: I06fd25157f12a3afb401bb08dff4faef7fb0a9b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/469235
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agosyscall: avoid serializing forks on ForkLock
Ian Lance Taylor [Sat, 6 Aug 2022 01:06:51 +0000 (18:06 -0700)]
syscall: avoid serializing forks on ForkLock

Fixes #23558
Fixes #54162

Change-Id: I3cf6efe466080cdb17e171218e9385ccb272c301
Reviewed-on: https://go-review.googlesource.com/c/go/+/421441
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agotest: remove *_unified.go variants
Cuong Manh Le [Tue, 23 May 2023 03:39:43 +0000 (10:39 +0700)]
test: remove *_unified.go variants

CL 415241 and CL 411935 break tests into unified/nounified variants, for
compatibility with old frontend while developing unified IR. Now the old
frontend was gone, so moving those tests back to the original files.

Change-Id: Iecdcd4e6ee33c723f6ac02189b0be26248e15f0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497275
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

12 months agocmd/go: refuse to run when the main module or workspace needs a newer Go
Russ Cox [Tue, 23 May 2023 16:09:09 +0000 (12:09 -0400)]
cmd/go: refuse to run when the main module or workspace needs a newer Go

We already refuse to build code in modules are too new (CL 476279).
This is a more comprehensive check: refuse to do anything at all with
modules or workspaces that are too new.

Since the module or workspace is new, it may have semantics we don't
understand and misinterpret well before we get to the actual building of code.
For example when we switched from // +build to //go:build that changed
the decision about which files go into a package, which affects the way
the overall load phase runs and which errors it reports. Waiting until the
building of code would miss earlier changes like that one.

Leaving the test from CL 476279 alone, but it's not load-bearing anymore.

For #57001.

Change-Id: I8c39943db1d7ddbcb9b5cae68d80459fddd68151
Reviewed-on: https://go-review.googlesource.com/c/go/+/497435
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>