]> Cypherpunks repositories - gostls13.git/log
gostls13.git
13 months agocmd/go: show deprecation message on go run/install
Audi P. R. Putra [Fri, 15 Sep 2023 16:37:53 +0000 (23:37 +0700)]
cmd/go: show deprecation message on go run/install

Add check for deprecations in PackagesAndErrorsOutsideModule. This affects go run/install outside module when run in module-aware mode.

Fixes #59230

Change-Id: I106df36a856894fb1b634decfa812e31cf88fe74
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/528775
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agomime: add available godoc link
cui fliter [Fri, 3 Nov 2023 09:04:15 +0000 (17:04 +0800)]
mime: add available godoc link

Change-Id: I66ec9edc71f4c1207135e4248003a7457e456931
Reviewed-on: https://go-review.googlesource.com/c/go/+/539576
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>

13 months agocmd/internal/osinfo,runtime,syscall: use RtlGetVersion instead of RtlGetNtVersionNumbers
qmuntal [Tue, 12 Mar 2024 13:20:33 +0000 (14:20 +0100)]
cmd/internal/osinfo,runtime,syscall: use RtlGetVersion instead of RtlGetNtVersionNumbers

The RtlGetNtVersionNumbers function is not documented by Microsoft.
Use RtlGetVersion instead, which is documented and available on all
supported versions of Windows.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Ibaf0e2c28e673951476c5d863a829fd166705aea
Reviewed-on: https://go-review.googlesource.com/c/go/+/571015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agonet,internal/syscall/windows: prove that keep alive options exists
qmuntal [Fri, 8 Mar 2024 14:40:34 +0000 (15:40 +0100)]
net,internal/syscall/windows: prove that keep alive options exists

The net package currently uses windows.SupportFullTCPKeepAlive to
know if TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT are available.
This function is a wrapper over the undocumented RtlGetNtVersionNumbers
API, which tests if the Windows version is at least 10.0.16299. This
approach artificially limits the use of TCP_KEEPCNT, which is
available since Windows 10.0.15063. It also uses an undocumented API,
which is not something we want to rely on.

This CL removes windows.SupportFullTCPKeepAlive in favor of dedicated
proves for each option which are not based on the Windows version.

While here, remove some assertions in setKeepAliveCount. It is better
to let the system decide if the value is valid or not.

Updates #65817.

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64
Change-Id: I0fe70d46c8675eab06c0e4628cf68571b6e50b80
Reviewed-on: https://go-review.googlesource.com/c/go/+/570077
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
13 months agotime: fix typo in comment
WuGuangyao [Wed, 20 Mar 2024 13:27:30 +0000 (13:27 +0000)]
time: fix typo in comment

Change-Id: I3a9779e8d3d43f60c7c5183e0b84870bc8170c3f
GitHub-Last-Rev: 89736ae96372c6c89dbd7c98e69c41a61302814e
GitHub-Pull-Request: golang/go#66424
Reviewed-on: https://go-review.googlesource.com/c/go/+/572976
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agosrc/go.mod, net/http: update bundled+latest golang.org/x/net
Emmanuel T Odeke [Wed, 20 Mar 2024 01:20:09 +0000 (18:20 -0700)]
src/go.mod, net/http: update bundled+latest golang.org/x/net

Updates x/net/http2 to git rev 89f602b7bbf237abe0467031a18b42fc742ced08

    http2: validate client/outgoing trailers
    https://golang.org/cl/572655 (updates #64766)

and also updates the vendored version of golang.org/x/net per:

$ go get golang.org/x/net@89f602b7bb
$ go mod tidy
$ go mod vendor
$ go generate -run bundle std

Change-Id: Ibd0e819d9125e72665bafec53ba626e257b594a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/572676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agonet/http: add tests with zero and negative read/write timeouts
Andy Pan [Sun, 10 Mar 2024 15:08:31 +0000 (23:08 +0800)]
net/http: add tests with zero and negative read/write timeouts

Change-Id: I38ebd280c200b30692eb35640327034a5e898bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/570376
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agosync: name the Map.CompareAndSwap return value
Peter Collingbourne [Wed, 20 Mar 2024 02:27:22 +0000 (19:27 -0700)]
sync: name the Map.CompareAndSwap return value

The godoc for sync.Map.CompareAndSwap does not document the meaning
of its return value. Document it by giving it a name.

Change-Id: I50ad9c078a7885f5ce83489d66d138d491c35861
Reviewed-on: https://go-review.googlesource.com/c/go/+/572657
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agonet/http: improve error reporting in TestCancelRequestWhenSharingConnection
Damien Neil [Tue, 18 Apr 2023 21:53:02 +0000 (14:53 -0700)]
net/http: improve error reporting in TestCancelRequestWhenSharingConnection

Ensure that errors are reported if an HTTP request unexpectedly fails.

For #56587

Change-Id: I1adfb4fedc24d4177caf54e34c5033267e32caa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/486075
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
13 months agocmd/compile/internal/inline: refactor fixpoint algorithm
Matthew Dempsky [Wed, 28 Feb 2024 09:28:43 +0000 (01:28 -0800)]
cmd/compile/internal/inline: refactor fixpoint algorithm

[Re-land of CL 567695 without further changes.]

This CL refactors the interleaved fixpoint algorithm so that calls can
be inlined in any order. This has no immediate effect, but it will
allow a subsequent CL to prioritize calls by inlheur score.

Change-Id: I8fd6748f0347fd696daee815bf7c9c183572c1ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/573096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agocmd/compile/internal/typecheck: more selective OPAREN skipping
Matthew Dempsky [Wed, 20 Mar 2024 18:14:47 +0000 (11:14 -0700)]
cmd/compile/internal/typecheck: more selective OPAREN skipping

Move the OPAREN skipping logic from typecheck into typecheck1, so that
it only applies to ParenExprs with Typecheck()==0. This should allow
CL 567695 to be re-landed, which uses ParenExprs as placeholders in
the AST.

Fixes #66261.

Change-Id: I606b7bad0cf1c0447e60d6da68d1d66db00863f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/573095
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/compile/internal/noder: remove wrapName
Matthew Dempsky [Wed, 20 Mar 2024 18:25:45 +0000 (11:25 -0700)]
cmd/compile/internal/noder: remove wrapName

The OPARENs inserted here used to be necessary for better error
diagnostics, but now those are handled by types2.

Change-Id: I88d50d34d9e00cdd7d0fb32f6e460a179345a787
Reviewed-on: https://go-review.googlesource.com/c/go/+/573115
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agodoc/go1.23: document "net/http".Request.CookiesNamed method
Dmitri Shuralyov [Wed, 20 Mar 2024 16:42:11 +0000 (12:42 -0400)]
doc/go1.23: document "net/http".Request.CookiesNamed method

CL 511516 added the method but didn't include a release note for it
because it was authored and tested before the new release note flow.

For #61472.

Change-Id: I38f73e97093a2badaea658ed430e174b73e35b3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/571278
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

13 months agocmd/compile: don't assume args are always zero-extended
Keith Randall [Tue, 12 Mar 2024 19:56:03 +0000 (12:56 -0700)]
cmd/compile: don't assume args are always zero-extended

On amd64, we always zero-extend when loading arguments from the stack.
On arm64, we extend based on the type. This causes problems with
zeroUpper*Bits, which reports the top bits are zero when they aren't.

Fix it to use the type to decide if the top bits are really zero.

For tests, only f32 currently fails on arm64. Added other tests
just for future-proofing.

Update #66066

Change-Id: I2f13fb47198e139ef13c9a34eb1edc932eea3ee3
Reviewed-on: https://go-review.googlesource.com/c/go/+/571135
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agonet/http: add Request.CookiesNamed
Timo Furrer [Wed, 28 Feb 2024 06:07:16 +0000 (06:07 +0000)]
net/http: add Request.CookiesNamed

Implements a new method http.Request.CookiesName, that allows
retrieving all cookies that match the given name.

Fixes #61472

Change-Id: I405d8771b4195af9ff6b4dfde3cfcd316c23b70c
GitHub-Last-Rev: 6ad0094995b45648ebbcd18626f07bb879a3f7cf
GitHub-Pull-Request: golang/go#61473
Reviewed-on: https://go-review.googlesource.com/c/go/+/511516
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
13 months agocmd/internal/obj: support Zba, Zbb, Zbs extensions in riscv64 assembler
Wang Yaduo [Wed, 31 Jan 2024 02:37:35 +0000 (10:37 +0800)]
cmd/internal/obj: support Zba, Zbb, Zbs extensions in riscv64 assembler

Add assembler support for Zba, Zbb, Zbs extensions, which are
mandatory in the rva22u64 profile. These can be used to accelerate
address computation and bit manipulation.

Change-Id: Ie90fe6b76b1382cf69984a0e71a72d3cba0e750a
Reviewed-on: https://go-review.googlesource.com/c/go/+/559655
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agodatabase/sql: fix memory leaks in Stmt.removeClosedStmtLocked
apocelipes [Wed, 20 Mar 2024 05:33:46 +0000 (05:33 +0000)]
database/sql: fix memory leaks in Stmt.removeClosedStmtLocked

Zero out elements before shrinking the slice to avoid memory leaks.

Fixes #66410

Change-Id: I8f64c21455761f7f7c8b6fee0b6450b98f691d91
GitHub-Last-Rev: b15586e801199b9674f5bfcb12a848a55f15a80b
GitHub-Pull-Request: golang/go#66419
Reviewed-on: https://go-review.googlesource.com/c/go/+/572956
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agoencoding/gob: close output file
guoguangwu [Wed, 20 Mar 2024 03:32:14 +0000 (03:32 +0000)]
encoding/gob: close output file

Change-Id: Ia9ecb82e87fca319e89aa1779aeed0f573fa808f
GitHub-Last-Rev: 33361bcb8ae5817dcc618d67d69009001b271ffc
GitHub-Pull-Request: golang/go#66417
Reviewed-on: https://go-review.googlesource.com/c/go/+/572955
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agonet/http: validate outgoing/client request trailers
Emmanuel T Odeke [Tue, 19 Mar 2024 06:05:12 +0000 (23:05 -0700)]
net/http: validate outgoing/client request trailers

This change validates outbound client request trailers
just like we do for headers. This helps prevent header
injection or other sorts of smuggling from easily being
performed using the standard HTTP client.

Fixes #64766

Change-Id: Idb34df876a0c308b1f57e9ae2695b118ac6bcc2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/572615
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agoos/signal: avoid calling ioctl via syscall.Syscall on BSDs
Joel Sing [Mon, 6 Nov 2023 13:39:27 +0000 (00:39 +1100)]
os/signal: avoid calling ioctl via syscall.Syscall on BSDs

Provide appropriate implementations of internal/syscall/unix.Tcsetpgrp
and use this for runSessionLeader in os/signal/signal_cgo_test.go.
This avoids calling syscall.Syscall with SYS_IOCTL on BSDs.

Updates #59667
Updates #63900

Change-Id: Ifa4696bba9f1eb68e81e7103f030bc254adaf0af
Reviewed-on: https://go-review.googlesource.com/c/go/+/540020
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

13 months agoslices: add func Repeat
Jes Cok [Fri, 15 Mar 2024 05:47:53 +0000 (13:47 +0800)]
slices: add func Repeat

Fixes #65238

Change-Id: I32ae4d922788cc6fbbe80f5b558a075951e3c892
Reviewed-on: https://go-review.googlesource.com/c/go/+/571895
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/internal/obj/ppc64: don't modify runtime.elf_* symbols
Paul E. Murphy [Tue, 12 Mar 2024 20:00:08 +0000 (15:00 -0500)]
cmd/internal/obj/ppc64: don't modify runtime.elf_* symbols

The runtime.elf_* symbols are assembly functions which are used
to support the gcc/llvm -Os option when used with cgo.

When compiling Go for shared code, we attempt to strip out the
TOC regenation code added by the go assembler for these symbols.

This causes the symbol to no longer appear as an assembly
function which causes problems later on when handling other
implicit symbols.

Avoid adding a TOC regeneration prologue to these functions
to avoid this issue.

Fixes #66265

Change-Id: Icbf8e4438d177082a57bb228e39b232e7a0d7ada
Reviewed-on: https://go-review.googlesource.com/c/go/+/571835
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocrypto/rand: use arc4random(3) on macOS and iOS
Filippo Valsorda [Wed, 6 Mar 2024 23:18:02 +0000 (00:18 +0100)]
crypto/rand: use arc4random(3) on macOS and iOS

It's been good since Sierra: it never fails, it's faster, it's available
on iOS (see #47812), and it still handles forks and reseeding.

On a M2 with macOS 14.3.1:

              │   sec/op    │   sec/op     vs base                │
    Read/32-8   413.7n ± 3%   249.7n ± 3%  -39.65% (p=0.000 n=10)
    Read/4K-8   7.097µ ± 6%   1.261µ ± 2%  -82.24% (p=0.000 n=10)

              │     B/s      │      B/s       vs base                 │
    Read/32-8   73.76Mi ± 3%   122.25Mi ± 3%   +65.73% (p=0.000 n=10)
    Read/4K-8   550.5Mi ± 6%   3099.0Mi ± 2%  +462.99% (p=0.000 n=10)

arc4random(3) would be a good replacement for getentropy(2) on FreeBSD
and NetBSD as well, but we don't get as easy access to libc there.

Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64-longtest,gotip-darwin-amd64-nocgo,gotip-darwin-arm64_13,gotip-darwin-amd64_11,gotip-darwin-amd64_12,gotip-darwin-amd64_13,gotip-darwin-amd64_14
Change-Id: Ia76824853be92b4d1786e23592a1d2ef24d8907d
Reviewed-on: https://go-review.googlesource.com/c/go/+/569655
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
13 months agointernal/asan: match runtime.asan{read,write} len parameter type
Tobias Klauser [Tue, 19 Mar 2024 10:23:59 +0000 (11:23 +0100)]
internal/asan: match runtime.asan{read,write} len parameter type

The len parameter runtime.asan{read,write} is of type uintptr. Match its
type in Read and Write.

For #64611

Change-Id: I0be278c38a357e600521ced87c0e23038a11e8a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/572755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agocmd/compile: fix typo in comment
guoguangwu [Tue, 19 Mar 2024 07:04:15 +0000 (07:04 +0000)]
cmd/compile: fix typo in comment

Change-Id: I0bbc74fdab9bc295d42ae7e346d33db8df52c797
GitHub-Last-Rev: fe2b7d1efeeb8cf6ccffe5419da5a55a4cbdbb43
GitHub-Pull-Request: golang/go#66397
Reviewed-on: https://go-review.googlesource.com/c/go/+/572616
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoruntime: optimize permission changes with mprotect
Lance Yang [Tue, 19 Mar 2024 14:19:43 +0000 (14:19 +0000)]
runtime: optimize permission changes with mprotect

On Linux, both mprotect() and mmap() acquire the mmap_lock (in writer mode),
posing scalability challenges.

The mmap_lock (formerly called mmap_sem) is a reader/writer lock that controls
access to a process's address space; before making changes there (mapping in a
new range, for example), the kernel must acquire that lock.

Page-fault handling must also acquire mmap_lock (in reader mode) to ensure that
the address space doesn't change in surprising ways while a fault is being resolved.

A process can have a large address space and many threads running (and incurring
page faults) concurrently, turning mmap_lock into a significant bottleneck.

While both mmap() and mprotect() are protected by the mmap_lock, the shorter
duration of mprotect system call, due to their simpler nature, results in a reduced
locking time for the mmap_lock.

Change-Id: I7f929544904e31eab34d0d8a9e368abe4de64637
GitHub-Last-Rev: 6f27a216b4fb789181d00316561b44358a118b19
GitHub-Pull-Request: golang/go#65038
Reviewed-on: https://go-review.googlesource.com/c/go/+/554935
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
13 months agoos: kick FIFOs with O_NONBLOCK out of the kqueue on Darwin/iOS
Andy Pan [Wed, 13 Mar 2024 02:15:19 +0000 (10:15 +0800)]
os: kick FIFOs with O_NONBLOCK out of the kqueue on Darwin/iOS

Fixes #66239

Change-Id: I8210682c0cf4285b950e9fabe687b7ad2369835c
Reviewed-on: https://go-review.googlesource.com/c/go/+/570397
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agoos: use ignoringEINTR in openFileNolog and openDirNolog
Andy Pan [Thu, 14 Mar 2024 05:03:00 +0000 (13:03 +0800)]
os: use ignoringEINTR in openFileNolog and openDirNolog

Change-Id: Ie8fa25d5e326efd7d3c9b72203783110d9e22ce8
Reviewed-on: https://go-review.googlesource.com/c/go/+/572215
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agonet/mail: enhance address parser to include support for domain literals
Nuno Gonçalves [Mon, 18 Mar 2024 20:06:17 +0000 (20:06 +0000)]
net/mail: enhance address parser to include support for domain literals

The existing implementation of the mail package conforms to RFC 5322
for parsing mail messages, but it lacks support for domain literals. This
patch addresses this limitation by adding support for domain literals in
the address parser.

The Addr-Spec Specification, defined in RFC 5322 Section 3.4.1,
outlines the format for email addresses:
https://datatracker.ietf.org/doc/html/rfc5322\#section-3.4.1

Fixes #60206

Change-Id: Ic901418325bd1da69e70800d70b87d658b953738
GitHub-Last-Rev: bdda66f3fe098df3a62d803b1f69e63fef6281e3
GitHub-Pull-Request: golang/go#66075
Reviewed-on: https://go-review.googlesource.com/c/go/+/567777
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agoregexp/syntax: use standard generated code header
Oleksandr Redko [Sun, 17 Mar 2024 15:04:14 +0000 (17:04 +0200)]
regexp/syntax: use standard generated code header

Updates doc by running these commands:
  - mksyntaxgo from the google/re2 repo, which changes comment according
    to https://golang.org/s/generatedcode
  - gofmt -w regexp/syntax/doc.go

Change-Id: I66a9dd9fa841cbce899ab3aa32d7face798d2920
Reviewed-on: https://go-review.googlesource.com/c/go/+/572275
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agoall: use "unix" build tag where appropriate
Tobias Klauser [Mon, 18 Mar 2024 20:22:27 +0000 (21:22 +0100)]
all: use "unix" build tag where appropriate

For #51572

Change-Id: I23bb25b8cf1ecb9be25eb6ab9e89cd397b58b3c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/572535
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agodatabase/sql: close rows in test
guoguangwu [Mon, 18 Mar 2024 05:20:00 +0000 (05:20 +0000)]
database/sql: close rows in test

This change invokes defer rows.Close() in TestQuery to properly close the rows.

Change-Id: I1ab0d172ad2130e9caab7dbda93d671550c33c6b
GitHub-Last-Rev: 76883a3bceefb80873e57150356a4acc001ee1a3
GitHub-Pull-Request: golang/go#66371
Reviewed-on: https://go-review.googlesource.com/c/go/+/572197
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

13 months agonet/http: update bundled x/net/http2
Andy Pan [Fri, 8 Mar 2024 20:00:28 +0000 (20:00 +0000)]
net/http: update bundled x/net/http2

For #65785 #65927

Change-Id: I21791d4e22ae3039144f6b105ac439877f8b01bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/569819
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
13 months agoindex/suffixarray: use built-in clear to simplify code
apocelipes [Mon, 18 Mar 2024 08:56:03 +0000 (08:56 +0000)]
index/suffixarray: use built-in clear to simplify code

"sais2.go" is regenerated by the command "go generate ./...".

Change-Id: I4307e9fa1f20ea59e3a0d4841dbb22e9cffefa5a
GitHub-Last-Rev: d285183e654fe412a3470e475fa1ea29e5973b78
GitHub-Pull-Request: golang/go#66376
Reviewed-on: https://go-review.googlesource.com/c/go/+/572198
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>

13 months agodatabase/sql: optimize connection request pool
Brad Fitzpatrick [Sun, 17 Mar 2024 01:29:06 +0000 (18:29 -0700)]
database/sql: optimize connection request pool

This replaces a map used as a set with a slice.

We were using a surprising amount of CPU in this code, making mapiters
to pull out a random element of the map. Instead, just rand.IntN to pick
a random element of the slice.

It also adds a benchmark:

                     │    before    │                after                │
                     │    sec/op    │   sec/op     vs base                │
    ConnRequestSet-8   1818.0n ± 0%   452.4n ± 0%  -75.12% (p=0.000 n=10)

(whether random is a good policy is a bigger question, but this
 optimizes the current policy without changing behavior)

Updates #66361

Change-Id: I3d456a819cc720c2d18e1befffd2657e5f50f1e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/572119
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>

13 months agotext/template: simplify unwrapping reflect.Interface value
Joe Taber [Mon, 18 Mar 2024 05:52:30 +0000 (05:52 +0000)]
text/template: simplify unwrapping reflect.Interface value

When text/template is evaluating a pipeline command and encounters an
`interface{}`, it "digs down one level to the thing inside". Currently it
does this with `value = reflect.ValueOf(value.Interface())`, which is
unnecessary since it could just use `value = value.Elem()`. This commit
changes it to use the latter.

Why it was written that way is mysterious because the proposed change
appears to be strictly better, but given the blame date (13 years ago)
it may have been written while reflect was still in development before
`Elem()` was added.

Change-Id: I6c4f6283e78de07732c4120ce11f26f113fa46e4
GitHub-Last-Rev: bdfc6973ab227f951f244fda4d803da55fb49e71
GitHub-Pull-Request: golang/go#66373
Reviewed-on: https://go-review.googlesource.com/c/go/+/572355
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
13 months agocmd/go: fix long test
Robert Griesemer [Mon, 18 Mar 2024 20:43:04 +0000 (13:43 -0700)]
cmd/go: fix long test

CL 571396 introduced quotes around user-provided names in error
messages. Update a test case to match the changed error message.

Change-Id: I3de0ea32f363ac83dcecae164ceab74e28dea086
Reviewed-on: https://go-review.googlesource.com/c/go/+/572555
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

13 months agostrings: optimize Repeat for common substrings
Joe Tsai [Sun, 1 Oct 2023 19:15:14 +0000 (12:15 -0700)]
strings: optimize Repeat for common substrings

According to static analysis of Go source code known by the module proxy,
spaces, dashes, zeros, and tabs are the most commonly repeated string literals.

Out of ~69k total calls to Repeat:
* ~25k calls are repeats of " "
* ~7k calls are repeats of "-"
* ~4k calls are repeats of "0"
* ~2k calls are repeats of "="
* ~2k calls are repeats of "\t"

After this optimization, ~60% of Repeat calls will go through the fast path.

These are often used in padding of fixed-width terminal UI or
in the presentation of humanly readable text
(e.g., indentation made of spaces or tabs).

Optimize for this case by handling short repeated sequences of common literals.

Performance:

name             old time/op    new time/op    delta
RepeatSpaces-24    19.3ns ± 1%     5.0ns ± 1%   -74.27%  (p=0.000 n=8+9)

name             old alloc/op   new alloc/op   delta
RepeatSpaces-24     2.00B ± 0%     0.00B       -100.00%  (p=0.000 n=10+10)

name             old allocs/op  new allocs/op  delta
RepeatSpaces-24      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Change-Id: Id1cafd0cc509e835c8241a626489eb206e0adc3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/536615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agonet/http: fix request canceler leak on connection close
Alexander Yastrebov [Tue, 12 Mar 2024 15:41:01 +0000 (15:41 +0000)]
net/http: fix request canceler leak on connection close

writeLoop goroutine closes persistConn closech in case of request body
write error which in turn finishes readLoop without removing request canceler.

Fixes #61708

Change-Id: Ib7c832a91b49bc7888a35a4fd2bd692236c04f86
GitHub-Last-Rev: b74b9055e87121d4dc5d97a3f3ef1afe545bc92d
GitHub-Pull-Request: golang/go#62305
Reviewed-on: https://go-review.googlesource.com/c/go/+/523296
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
13 months agogo/types, types2: quote user-supplied names in error messages
Robert Griesemer [Wed, 13 Mar 2024 20:57:08 +0000 (13:57 -0700)]
go/types, types2: quote user-supplied names in error messages

Use `' quotes (as in `foo') to differentiate from Go quotes.
Quoting prevents confusion when user-supplied names alter
the meaning of the error message.

For instance, report

        duplicate method `wanted'

rather than

        duplicate method wanted

Exceptions:
- don't quote _:
        `_' is ugly and not necessary
- don't quote after a ":":
        undefined name: foo
- don't quote if the name is used correctly in a statement:
        goto L jumps over variable declaration

Quoting is done with a helper function and can be centrally adjusted
and fine-tuned as needed.

Adjusted some test cases to explicitly include the quoted names.

Fixes #65790.

Change-Id: Icce667215f303ab8685d3e5cb00d540a2fd372ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/571396
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>

13 months agoos: support UNC paths and .. segments in fixLongPath
qmuntal [Tue, 12 Mar 2024 11:26:53 +0000 (12:26 +0100)]
os: support UNC paths and .. segments in fixLongPath

This CL reimplements fixLongPath using syscall.GetFullPathName instead
of a custom implementation that was not handling UNC paths and ..
segments correctly. It also fixes a bug here multiple trailing \
were removed instead of replaced by a single one.

The new implementation is slower than the previous one, as it does a
syscall and needs to convert UTF-8 to UTF-16 (and back), but it is
correct and should be fast enough for most use cases.

goos: windows
goarch: amd64
pkg: os
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
            │   old.txt    │                new.txt                 │
            │    sec/op    │    sec/op      vs base                 │
LongPath-12   1.007µ ± 53%   4.093µ ± 109%  +306.41% (p=0.000 n=10)

            │  old.txt   │               new.txt                │
            │    B/op    │    B/op      vs base                 │
LongPath-12   576.0 ± 0%   1376.0 ± 0%  +138.89% (p=0.000 n=10)

            │  old.txt   │              new.txt               │
            │ allocs/op  │ allocs/op   vs base                │
LongPath-12   2.000 ± 0%   3.000 ± 0%  +50.00% (p=0.000 n=10)

Fixes #41734.

Change-Id: Iced5cf47f56f6ab0ca74a6e2374c31a75100902d
Reviewed-on: https://go-review.googlesource.com/c/go/+/570995
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/compile: compute ptrBytes during CalcSize instead of on demand
Keith Randall [Fri, 15 Mar 2024 21:30:34 +0000 (14:30 -0700)]
cmd/compile: compute ptrBytes during CalcSize instead of on demand

Compute ptrBytes while computing the size of a type.
Requires an extra field on the type, but means that we don't
have potentially exponential behavior in the PtrDataSize computation.

For #65540.

Change-Id: Ia23c72bbd996730baddd32d9ed46cfc00c3472ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/571543
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
13 months agoruntime: remove nosplit directives from several Windows syscall helpers
qmuntal [Mon, 18 Mar 2024 14:38:20 +0000 (15:38 +0100)]
runtime: remove nosplit directives from several Windows syscall helpers

Some of the Windows syscall helpers don't need to be nosplit. Removing
this directive will allow to add instrumentation to these functions
without having to worry about the stack size.

Change-Id: I3885621f23733af48563803c704563474010b8d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/572415
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocompress/bzip2,lzw: use built-in clear to simplify code
apocelipes [Mon, 18 Mar 2024 08:56:12 +0000 (08:56 +0000)]
compress/bzip2,lzw: use built-in clear to simplify code

Change-Id: I16c17e322c757c8c657364065948d7cec66a8346
GitHub-Last-Rev: 9a5104fe9874dd7c604c526be3f082487f2aaf01
GitHub-Pull-Request: golang/go#66377
Reviewed-on: https://go-review.googlesource.com/c/go/+/572199
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
13 months agonet/http/httptest: close res.Body in test
guoguangwu [Tue, 12 Mar 2024 08:35:52 +0000 (08:35 +0000)]
net/http/httptest: close res.Body in test

Change-Id: Ieec952ebc407ecb1aa20aa03105323505121981c
GitHub-Last-Rev: d19724c16dff3ec9c1f23d21054ff8a6ccc3770c
GitHub-Pull-Request: golang/go#66263
Reviewed-on: https://go-review.googlesource.com/c/go/+/570915
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Damien Neil <dneil@google.com>
13 months agonet/http: do not set a deadline when Server.IdleTimeout is negative
Andy Pan [Sun, 10 Mar 2024 15:12:56 +0000 (23:12 +0800)]
net/http: do not set a deadline when Server.IdleTimeout is negative

Change-Id: I0d6336e6a21aef14e7229594a335899083fa98b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/570396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agocmd/compile: compute type eq/hash algorithm in CalcSize instead of on demand
Keith Randall [Fri, 15 Mar 2024 00:39:01 +0000 (17:39 -0700)]
cmd/compile: compute type eq/hash algorithm in CalcSize instead of on demand

For #65540

Actually more correct in some very weird, and probably impossible to
trigger currently, cases. For instance, a struct with a NOEQ
and a NOALG field (the old code would not report the noalg bit).

Change-Id: I36c473b59aa5775d8a520ac746b114d16a22699d
Reviewed-on: https://go-review.googlesource.com/c/go/+/571542
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/compile: simplify algorithm kinds
Keith Randall [Thu, 14 Mar 2024 17:25:18 +0000 (10:25 -0700)]
cmd/compile: simplify algorithm kinds

Add a ANOALG kind which is "ANOEQ, plus has a part that is marked Noalg".
That way, AlgType can return just a kind.
The field we used to return was used only to get this bit of information.

Change-Id: Iaa409742825cc1f19ab414b1f5b74c1f112ed5f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/572075
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
13 months agosyscall: use internal/asan and internal/msan
Mauri de Souza Meneguzzo [Sun, 25 Feb 2024 21:21:31 +0000 (21:21 +0000)]
syscall: use internal/asan and internal/msan

Now with internal/asan and internal/msan available we can cleanup
syscall's duplicated definitions.

For #64611

Change-Id: If714d04ed2d32a4ed27305b3e3dc64ba8cdd1b61
GitHub-Last-Rev: e52fff1513bf74305d7abd142f71a60215bb93fc
GitHub-Pull-Request: golang/go#65935
Reviewed-on: https://go-review.googlesource.com/c/go/+/566755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocmd/dist,cmd/link: enable PIE buildmode on openbsd/arm64
Joel Sing [Sat, 2 Mar 2024 08:53:20 +0000 (19:53 +1100)]
cmd/dist,cmd/link: enable PIE buildmode on openbsd/arm64

The PIE buildmode works correctly on openbsd/arm64, hence enable it.

Updates #59866

Change-Id: I2f3c2839893659391539fafa12891d64f867e189
Reviewed-on: https://go-review.googlesource.com/c/go/+/570375
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

13 months agoos: don't try to make the directory FD non-blocking in os.ReadDir
Peter Collingbourne [Tue, 12 Mar 2024 03:10:48 +0000 (20:10 -0700)]
os: don't try to make the directory FD non-blocking in os.ReadDir

This will fail because epoll_ctl() fails on directory FDs, so we
end up issuing unnecessary syscalls. My test program that calls
filepath.WalkDir on a large directory tree runs 1.23 ± 0.04 times
faster than with the original implementation.

Change-Id: Ie33d798c48057a7b2d0bacac80fcdde5b5a8bb1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/570877
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agocmd/internal/obj: replace bytes.Index call with bytes.Contains
guoguangwu [Fri, 15 Mar 2024 07:33:32 +0000 (07:33 +0000)]
cmd/internal/obj: replace bytes.Index call with bytes.Contains

Change-Id: I6b30ac3e9d15c29197426fb16dc4031056f6bb10
GitHub-Last-Rev: e2dda286f26587726870a5779d6caa0c5abd6750
GitHub-Pull-Request: golang/go#66331
Reviewed-on: https://go-review.googlesource.com/c/go/+/571915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocmd/go/internal/modload: follow dependencies of unpruned roots in dqTracker.path
Bryan C. Mills [Thu, 14 Mar 2024 20:57:22 +0000 (16:57 -0400)]
cmd/go/internal/modload: follow dependencies of unpruned roots in dqTracker.path

For #65363.

Change-Id: I82ae1098b00c8772ef8d3aa92197e7d8c66d1b37
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/571800
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/compile: fix typo in comment
guoguangwu [Fri, 15 Mar 2024 08:12:33 +0000 (08:12 +0000)]
cmd/compile: fix typo in comment

Change-Id: Iec9ed110c4d5a417bd9de0434147665fd3633899
GitHub-Last-Rev: d2154f9ea12bc1fbb8f7c4feae2060e2534fa5d2
GitHub-Pull-Request: golang/go#66332
Reviewed-on: https://go-review.googlesource.com/c/go/+/571876
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

13 months agocmd: vendor in golang.org/x/telemetry@abedc37
Michael Matloob [Thu, 14 Mar 2024 21:14:31 +0000 (17:14 -0400)]
cmd: vendor in golang.org/x/telemetry@abedc37

This pulls in the changes to remove 1.18 support in counter and
countertest, to add counter.CountCommandLineFlags, and to add
countertest.SupportedPlatform

Commands run:
go get golang.org/x/telemetry@abedc37
go mod tidy
go mod vendor

Change-Id: I5c17c5b3ca38df14883ba43316d59437a737b28b
Reviewed-on: https://go-review.googlesource.com/c/go/+/571801
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
13 months agocmd/compile/internal: generate ADDZE on PPC64
Paul E. Murphy [Thu, 7 Mar 2024 21:37:14 +0000 (15:37 -0600)]
cmd/compile/internal: generate ADDZE on PPC64

This usage shows up in quite a few places, and helps reduce
register pressure in several complex cryto functions by
removing a MOVD $0,... instruction.

Change-Id: I9444ea8f9d19bfd68fb71ea8dc34e109681b3802
Reviewed-on: https://go-review.googlesource.com/c/go/+/571055
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>

13 months agonet: #define _GNU_SOURCE to 1
Ian Lance Taylor [Fri, 15 Mar 2024 04:22:31 +0000 (21:22 -0700)]
net: #define _GNU_SOURCE to 1

Makes the build work with CGO_CPPFLAGS=-D_GNU_SOURCE,
as reportedly used by TinyGo.

Fixes #66325

Change-Id: I794f1cd89814638fdb6c3066d13bbd7da88c9d93
Reviewed-on: https://go-review.googlesource.com/c/go/+/571875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agonet/http: revert header changes in Error
Russ Cox [Fri, 15 Mar 2024 16:56:05 +0000 (12:56 -0400)]
net/http: revert header changes in Error

This reverts CL 544019 and CL 569815, because they break a variety
of tests inside Google that do not expect the Cache-Control header
to be set to no-cache.

A followup CL will add this functionality back after a proposal.

For #50905.

Change-Id: Ie377bfb72ce2c77d11bf31f9617ab6db342a408a
Reviewed-on: https://go-review.googlesource.com/c/go/+/571975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
13 months agoruntime: fixes to traceback_system_test.go
Russ Cox [Thu, 14 Mar 2024 20:40:34 +0000 (16:40 -0400)]
runtime: fixes to traceback_system_test.go

Minor cleanups to CL 561635's test for better debuggability
when it crashes. In a separate CL so that it's clear this CL is
not changing the code under test.

Change-Id: I12b72ae538f8454b5c382127eafd766c22c69b67
Reviewed-on: https://go-review.googlesource.com/c/go/+/571799
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoruntime: allow omitting virtual PCs from runtime.CallersFrames input
Russ Cox [Thu, 14 Mar 2024 19:32:00 +0000 (15:32 -0400)]
runtime: allow omitting virtual PCs from runtime.CallersFrames input

This makes CL 561635's test pass without any changes to the
traceback textual format.

The test in this CL is copied identically from CL 561635.

Change-Id: I5130abdfefd9940f98f20c283cca6cd159e37617
Reviewed-on: https://go-review.googlesource.com/c/go/+/571798
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocmd/link: support -bindnow option and permit use of "-Wl,-z,now"
Than McIntosh [Wed, 13 Mar 2024 17:49:32 +0000 (17:49 +0000)]
cmd/link: support -bindnow option and permit use of "-Wl,-z,now"

This is a partial roll-forward of CL 473495, which was subsequently
reverted. The second half of CL 473495 will appear in a future CL.

In this patch we introduce a new Go linker "-bindnow" command line
flag, and update the Go command to permit the use of the -Wl,-z,now
option, to allow users to produce binaries that have immediate
binding.

Updates #45681.

Change-Id: Idd61b0d6597bcd37b16c343714c55a4ef6dfb534
Reviewed-on: https://go-review.googlesource.com/c/go/+/571416
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoarchive/tar: add FileInfoNames interface
qiulaidongfeng [Fri, 15 Mar 2024 10:40:23 +0000 (10:40 +0000)]
archive/tar: add FileInfoNames interface

An optional interface FileInfoNames has been added.

If the parameter fi of FileInfoHeader implements the interface
the Gname/Uname of the return value Header
are provided by the method of the interface.

Also added testing.

Fixes #50102

Change-Id: I47976e238eb20ed43113b060e4f83a14ae49493e
GitHub-Last-Rev: a213613c79e150d52a2f5c84dca7a49fe123fa40
GitHub-Pull-Request: golang/go#65273
Reviewed-on: https://go-review.googlesource.com/c/go/+/558355
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agointernal/bisect: replace atomicPointerDedup to simplify the code
apocelipes [Thu, 14 Mar 2024 12:55:10 +0000 (12:55 +0000)]
internal/bisect: replace atomicPointerDedup to simplify the code

"atomicPointerDedup" is a redundancy of "atomic.Pointer".

Since Go 1.22 now requires the final point release of Go 1.20  or
later for bootstrap, Go 1.19's atomic.Pointer can be used
without problems.

atomicPointerDedup is unnecessary and we can remove it now.

Change-Id: I0a65ad0b6649cecb73d58dc39c5fd736390d5fa5
GitHub-Last-Rev: 6c6e9421fbdf34c2d4b3ea21359f847ccf9a34cd
GitHub-Pull-Request: golang/go#65987
Reviewed-on: https://go-review.googlesource.com/c/go/+/567656
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoruntime: add crash stack support for 386
Mauri de Souza Meneguzzo [Sun, 25 Feb 2024 14:22:52 +0000 (14:22 +0000)]
runtime: add crash stack support for 386

Change-Id: Ib787b27670ad0f10bcc94b3ce76e86746997af00
GitHub-Last-Rev: e5abb9a556ae709d30d6ffb5a13805923c215254
GitHub-Pull-Request: golang/go#65934
Reviewed-on: https://go-review.googlesource.com/c/go/+/566715
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agogo/types, types2: do not overwrite nest entries in Checker.validType
Robert Griesemer [Thu, 14 Mar 2024 22:45:30 +0000 (15:45 -0700)]
go/types, types2: do not overwrite nest entries in Checker.validType

In Checker.validType, when we encounter a type parameter, we evaluate
the validity of the respective type argument in the "type nest" of the
enclosing type (at the nesting depth at which the type argument was
passed) (*). Specifically, we call validType recursively, with the slice
representing the type nest shortened by 1. This recursive call continues
to use the nest slice and in the process may overwrite the (previously)
last entry. Upon return of that recursive call, validType proceeds with
the old length, possibly using an incorrect last nest entry.

In the concrete example for this issue we have the type S

type S[T any] struct {
a T
b time.Time
}

instantiated with time.Time. When validType encounters the type parameter
T inside the struct (S is in the type nest) it evaluates the type argument
(time.Time) in the empty type nest (outside of S). In the process of
evaluating the time.Time struct, the time.Time type is appended to the
(shortened) nest slice and overwrites the previous last nest entry (S).
Once processing of T is done, validType continues with struct field b,
using the original-length nest slice, which now has time.Time rather
than S as a last element. The type of b has type time.Time, which now
appears to be nested in time.Time (rather than S), which (incorrectly)
means that there's a type cycle. validType proceeds with reporting the
error. But time.Time is an imported type, imported types are correct
(otherwise they could not be imported in the first place), and the
assertion checking that package of time.Time is local fails.

The fix is trivial: restore the last entry of the nest slice when it
may have been overwriten.

(*) In hindsight we may be able to sigificantly simplify validType by
    evaluating type arguments when they are passed instead of when
    the respective type parameters are encountered. For another CL.

Fixes #66323.

Change-Id: I3bf23acb8ed14d349db342ca5c886323a6c7af58
Reviewed-on: https://go-review.googlesource.com/c/go/+/571836
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>

13 months agonet: fixes to dnsReadConfig in dnsconfig_windows.go
Quentin McGaw [Wed, 29 Nov 2023 21:44:34 +0000 (21:44 +0000)]
net: fixes to dnsReadConfig in dnsconfig_windows.go

- Only search DNS servers for network interfaces with at least one gateway
- Clarify comment on deprecated site local anycast fec0/10 DNS IPv6 addresses
- Minor maintenance: skip not "up" interfaces earlier in outer loop

Change-Id: I98ca7b81d3d51e6aa6bfa4a10dcd651305a843df
GitHub-Last-Rev: 3b358c7e3f89971d069286f997dc19e092ec8f08
GitHub-Pull-Request: golang/go#64441
Reviewed-on: https://go-review.googlesource.com/c/go/+/545775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
13 months agodebug/elf: avoid using binary.Read() in NewFile()
Peter Collingbourne [Wed, 13 Mar 2024 03:01:40 +0000 (20:01 -0700)]
debug/elf: avoid using binary.Read() in NewFile()

With this change my test program that reads a tree of ELF files runs
1.71 ± 0.12 times faster without parallelism or 1.39 ± 0.06 times
faster using 8 goroutines.

Change-Id: I443d1a02736f16f5532ef28e1447c97aa87c7126
Reviewed-on: https://go-review.googlesource.com/c/go/+/571436
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agotime: fix longtest flake
Russ Cox [Fri, 15 Mar 2024 01:42:50 +0000 (21:42 -0400)]
time: fix longtest flake

Should fix longtest build dashboard flake:
https://ci.chromium.org/ui/p/golang/builders/ci/gotip-linux-amd64-longtest/b8753459332096992401/overview

Change-Id: I613bd4337aa65180389674e136d215135fde3196
Reviewed-on: https://go-review.googlesource.com/c/go/+/571803
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agodoc: document new timer behavior
Russ Cox [Thu, 14 Mar 2024 18:43:05 +0000 (14:43 -0400)]
doc: document new timer behavior

Change-Id: Ifa5894c67a36eb2c101b23b85775a3702512ca79
Reviewed-on: https://go-review.googlesource.com/c/go/+/571796
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agodoc: fix various release notes mistakes
Russ Cox [Thu, 14 Mar 2024 18:42:53 +0000 (14:42 -0400)]
doc: fix various release notes mistakes

Change-Id: Ib7666b3df1d7190772748129c349d4dc7046ca5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/571795
TryBot-Bypass: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agogo/types, types2: consistently report "duplicate method" error in go1.13
Robert Griesemer [Wed, 13 Mar 2024 15:56:06 +0000 (08:56 -0700)]
go/types, types2: consistently report "duplicate method" error in go1.13

Go 1.13 is not supported anymore, but this CL removes an unnecessary
check and in turn fixes an old bug.

Fixes #66285.

Change-Id: I15ee1712b31f8ac8c915f18410d99cbf44334d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/571058
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>

13 months agogo/types, types2: don't do version checks for embedded types of imported interfaces
Robert Griesemer [Tue, 12 Mar 2024 16:31:06 +0000 (09:31 -0700)]
go/types, types2: don't do version checks for embedded types of imported interfaces

This is a cherry-pick of CL 571075 combined with adjustments for 1.23:

Imported interfaces don't have position information for embedded types.
When computing the type set of such interfaces, doing a version check
may fail because it will rely on the Go version of the current package.

We must not do a version check for features of types from imported
packages - those types have already been typechecked and are "correct".
The version check code does look at packages to avoid such incorrect
version checks, but we don't have the package information available
in an interface type (divorced from its object).

Instead, rely on the fact that imported interfaces don't have position
information for embedded types: if the position is unknown, don't do a
version check.

In Checker.allowVersion, still allow for unknown positions and resort
to the module version in that case (source code may be generated by
tools and not contain position information). Also, remove the *Package
argument as it was always check.pkg except in one case, and that case
may in fact be incorrect; treat that case separately for now.

Fixes #66064.

Change-Id: I773d57e5410c3d4a911ab3e018b3233c2972b3c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/571075
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/571137

13 months agotest/fixedbugs: add regress test for inlining failure
Matthew Dempsky [Thu, 14 Mar 2024 21:24:22 +0000 (14:24 -0700)]
test/fixedbugs: add regress test for inlining failure

Still investigating, but adding the minimized reproducer as a regress
test case for now.

Updates #66261.

Change-Id: I20715b731f8c5b95616513d4a13e3ae083709031
Reviewed-on: https://go-review.googlesource.com/c/go/+/571815
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/internal/telemetry: add a shim package around telemetry
Michael Matloob [Wed, 13 Mar 2024 17:27:03 +0000 (13:27 -0400)]
cmd/internal/telemetry: add a shim package around telemetry

The purpose of this package is to have a build tagged variant so that
when we're building the bootstrap go command it does not depend on the
net package. (net is a dependency of golang.org/x/telemetry/counter on
Windows).

The TESTGO_TELEMETRY_DIR environment variable used by the go tests to
change the telemetry directory is renamed to TEST_TELEMETRY_DIR to
make it more general to other commands that might want to set it for
the purpose of tests. The test telemetry directory is now set using
telemetry.Start instead of countertest.Open. This also means that the
logic that decides whether to upload counter files is now going to run
from the cmd/go tests (but that's okay because it's aleady been
running when cmd/go has been invoked outside of its tests.

Change-Id: Ic4272e5083facde010482d8b8fc3c95c03564bc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/571096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
13 months agonet/netip: use built-in clear to simplify code
apocelipes [Thu, 14 Mar 2024 10:41:08 +0000 (10:41 +0000)]
net/netip: use built-in clear to simplify code

Change-Id: Ic7b390935df107c5b7f53f9347a52031eac8a897
GitHub-Last-Rev: a7194571e1c2f90537f1caa8a3b5bcd60cea60be
GitHub-Pull-Request: golang/go#66310
Reviewed-on: https://go-review.googlesource.com/c/go/+/571635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoruntime: revert "traceback: include pc=0x%x for inline frames"
Russ Cox [Thu, 14 Mar 2024 19:30:13 +0000 (15:30 -0400)]
runtime: revert "traceback: include pc=0x%x for inline frames"

This reverts commit 643d816c8b43 (CL 561635).

Reason for revert: This works for telemetry but broke various other
properties of the tracebacks as well as some programs that read
tracebacks. We should figure out a solution that works for all uses,
and in the interim we should not be making telemetry work at the
cost of breaking other, existing valid uses.

See #65761 for details.

Change-Id: I467993ae778887e5bd3cca4c0fb54e9d44802ee1
Reviewed-on: https://go-review.googlesource.com/c/go/+/571797
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agotime: avoid stale receives after Timer/Ticker Stop/Reset return
Russ Cox [Fri, 1 Mar 2024 03:39:49 +0000 (22:39 -0500)]
time: avoid stale receives after Timer/Ticker Stop/Reset return

A proposal discussion in mid-2020 on #37196 decided to change
time.Timer and time.Ticker so that their Stop and Reset methods
guarantee that no old value (corresponding to the previous configuration
of the Timer or Ticker) will be received after the method returns.

The trivial way to do this is to make the Timer/Ticker channels
unbuffered, create a goroutine per Timer/Ticker feeding the channel,
and then coordinate with that goroutine during Stop/Reset.
Since Stop/Reset coordinate with the goroutine and the channel
is unbuffered, there is no possibility of a stale value being sent
after Stop/Reset returns.

Of course, we do not want an extra goroutine per Timer/Ticker,
but that's still a good semantic model: behave like the channels
are unbuffered and fed by a coordinating goroutine.

The actual implementation is more effort but behaves like the model.
Specifically, the timer channel has a 1-element buffer like it always has,
but len(t.C) and cap(t.C) are special-cased to return 0 anyway, so user
code cannot see what's in the buffer except with a receive.
Stop/Reset lock out any stale sends and then clear any pending send
from the buffer.

Some programs will change behavior. For example:

package main

import "time"

func main() {
t := time.NewTimer(2 * time.Second)
time.Sleep(3 * time.Second)
if t.Reset(2*time.Second) != false {
panic("expected timer to have fired")
}
<-t.C
<-t.C
}

This program (from #11513) sleeps 3s after setting a 2s timer,
resets the timer, and expects Reset to return false: the Reset is too
late and the send has already occurred. It then expects to receive
two values: the one from before the Reset, and the one from after
the Reset.

With an unbuffered timer channel, it should be clear that no value
can be sent during the time.Sleep, so the time.Reset returns true,
indicating that the Reset stopped the timer from going off.
Then there is only one value to receive from t.C: the one from after the Reset.

In 2015, I used the above example as an argument against this change.

Note that a correct version of the program would be:

func main() {
t := time.NewTimer(2 * time.Second)
time.Sleep(3 * time.Second)
if !t.Reset(2*time.Second) {
<-t.C
}
<-t.C
}

This works with either semantics, by heeding t.Reset's result.
The change should not affect correct programs.

However, one way that the change would be visible is when programs
use len(t.C) (instead of a non-blocking receive) to poll whether the timer
has triggered already. We might legitimately worry about breaking such
programs.

In 2020, discussing #37196, Bryan Mills and I surveyed programs using
len on timer channels. These are exceedingly rare to start with; nearly all
the uses are buggy; and all the buggy programs would be fixed by the new
semantics. The details are at [1].

To further reduce the impact of this change, this CL adds a temporary
GODEBUG setting, which we didn't know about yet in 2015 and 2020.
Specifically, asynctimerchan=1 disables the change and is the default
for main programs in modules that use a Go version before 1.23.
We hope to be able to retire this setting after the minimum 2-year window.
Setting asynctimerchan=1 also disables the garbage collection change
from CL 568341, although users shouldn't need to know that since
it is not a semantically visible change (unless we have bugs!).

As an undocumented bonus that we do not officially support,
asynctimerchan=2 disables the channel buffer change but keeps
the garbage collection change. This may help while we are
shaking out bugs in either of them.

Fixes #37196.

[1] https://github.com/golang/go/issues/37196#issuecomment-641698749

Change-Id: I8925d3fb2b86b2ae87fd2acd055011cbf7bd5916
Reviewed-on: https://go-review.googlesource.com/c/go/+/568341
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/go: update docs for go test -benchmem
Kévin Dunglas [Tue, 12 Mar 2024 21:33:55 +0000 (21:33 +0000)]
cmd/go: update docs for go test -benchmem

Mention that the allocation counter doesn't count allocations made using
C.malloc (cgo) or in C.

Change-Id: I03c23b6d8cfde68c04a75732a0d3c05eedae2276
GitHub-Last-Rev: 2d805b3322327b73076a197628987ac874311664
GitHub-Pull-Request: golang/go#65430
Reviewed-on: https://go-review.googlesource.com/c/go/+/560397
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agomath/big: use built-in clear to simplify code
apocelipes [Thu, 14 Mar 2024 12:06:36 +0000 (12:06 +0000)]
math/big: use built-in clear to simplify code

Change-Id: I07c3a498ce1e462c3d1703d77e7d7824e9334651
GitHub-Last-Rev: 2ba8c4c705eaeb0772109ece7296978b62467eb3
GitHub-Pull-Request: golang/go#66312
Reviewed-on: https://go-review.googlesource.com/c/go/+/571636
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoRevert "cmd/go/internal/test: add 'tests' vet check to 'go test' suite"
Michael Knyszek [Thu, 14 Mar 2024 16:06:41 +0000 (16:06 +0000)]
Revert "cmd/go/internal/test: add 'tests' vet check to 'go test' suite"

This reverts commit f1d60500bcc48f06c8d322dac1e48dd4c22f5863.

Reason for revert: Broke the longtest builders.

Change-Id: I5f3510c8ffc24fae5e71fac0a2dbda01ecfe5d5c
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/571695
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agotime: replace time.Now().Sub call with time.Since in test
guoguangwu [Wed, 13 Mar 2024 01:52:03 +0000 (01:52 +0000)]
time: replace time.Now().Sub call with time.Since in test

Change-Id: I56ca2d11637d60c6b0656fdc1d900a2384aba141
GitHub-Last-Rev: 686e02db77797fd81aafcde8ae40c85cee8dd817
GitHub-Pull-Request: golang/go#66264
Reviewed-on: https://go-review.googlesource.com/c/go/+/570916
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/compile/internal/syntax: replace bytes.Compare call with bytes.Equal
guoguangwu [Thu, 14 Mar 2024 03:16:12 +0000 (03:16 +0000)]
cmd/compile/internal/syntax: replace bytes.Compare call with bytes.Equal

Change-Id: I783e02e215efaebf4936146c6aaa032634fdfa64
GitHub-Last-Rev: 24680a73ee22fe03d7e33c122c95ed1372a2b406
GitHub-Pull-Request: golang/go#66304
Reviewed-on: https://go-review.googlesource.com/c/go/+/571595
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoencoding/gob: make x509.Certificate marshalable again
Russ Cox [Tue, 12 Mar 2024 16:51:44 +0000 (12:51 -0400)]
encoding/gob: make x509.Certificate marshalable again

The OID type is not exported data like most of the other x509 structs.
Using it in x509.Certificate made Certificate not gob-compatible anymore,
which breaks real-world code. As a temporary fix, make gob ignore
that field, making it work as well as it did in Go 1.21.

For Go 1.23, we anticipate adding a proper fix and removing the gob
workaround. See #65633 and #66249 for more details.

For #66249.
Fixes #65633.

Change-Id: Idd1431d15063b3009e15d0565cd3120b9fa13f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/571095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
13 months agoRevert "net/url: consider an empty base Path as equivalent to / in JoinPath"
Russ Cox [Thu, 14 Mar 2024 13:50:37 +0000 (13:50 +0000)]
Revert "net/url: consider an empty base Path as equivalent to / in JoinPath"

This reverts commit a46285f8c2389b92952c1484daacfccf70a17047 (CL 469935).

Reason for revert: This breaks a variety of code inside Google
that seem representative of possible external real-world usage.

If we roll this forward again we should include a GODEBUG like
urljoinpathslash=0 to go back to the old behavior.

Change-Id: I6cd8e9888a0c088669dc5634418372252289e074
Reviewed-on: https://go-review.googlesource.com/c/go/+/571655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

13 months agoRevert: "cmd/link: add option to enable full RELRO for ELF"
Than McIntosh [Wed, 13 Mar 2024 17:46:29 +0000 (17:46 +0000)]
Revert: "cmd/link: add option to enable full RELRO for ELF"

This reverts https://go.dev/cl/c/go/+/473495.

Reason for revert: breaks some Google-internal tests.

This revert will be temporary until we can gather more info on the
nature of the failures and hopefully develop an upstream test case,
etc.

Updates #45681.

Change-Id: Ib628ddc53bc5489e4f76c0f4ad809b75e899102c
Reviewed-on: https://go-review.googlesource.com/c/go/+/571415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocmd/go/internal/modcmd: fix typo in comment
guoguangwu [Thu, 14 Mar 2024 03:16:23 +0000 (03:16 +0000)]
cmd/go/internal/modcmd: fix typo in comment

Change-Id: I331c46083e9608227615183ba7e25f6299669341
GitHub-Last-Rev: 0cb78ae1c1e7554b0ef54c5e82fab0901a178494
GitHub-Pull-Request: golang/go#66305
Reviewed-on: https://go-review.googlesource.com/c/go/+/571536
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
13 months agoRevert "net/http: remove superfluous newline on redirects"
Russ Cox [Thu, 14 Mar 2024 13:55:01 +0000 (13:55 +0000)]
Revert "net/http: remove superfluous newline on redirects"

This reverts commit 2b58355ef624239dbe32185dc8dfc9d1074615c6.

Reason for revert: This breaks tons of tests for no real reason.

Change-Id: I89773f48cf983c0b6346e46c37a0ebbe2620e3b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/571675
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoruntime: fix lost sleep causing TestZeroTimer flakes
Russ Cox [Wed, 13 Mar 2024 23:48:58 +0000 (19:48 -0400)]
runtime: fix lost sleep causing TestZeroTimer flakes

Classic operating system kernel mistake: if you start using
per-CPU data without disabling interrupts on the CPU,
and then an interrupt reschedules the process onto a different
CPU, now you're using the wrong CPU's per-CPU data.
The same thing happens in Go if you use per-M or per-P
data structures while not holding a lock nor using acquirem.

In the original timer.modify before CL 564977, I had been
very careful about this during the "unlock t; lock ts" dance,
only calling releasem after ts was locked. That made sure
we used the right ts. The refactoring of that code into its
own helper function in CL 564977 missed that nuance.

The code

    ts := &getg().m.p.p.ptr().timers
    ts.lock()

was now executing without holding any locks nor acquirem.
If the goroutine changed its M or P between deciding which
ts to use and actually locking that ts, the code would proceed
to add the timer t to some other P's timers. If the P was idle
by then, the scheduler could have already checked it for timers
and not notice the newly added timer when deciding when the
next timer should trigger.

The solution is to do what the old code correctly did, namely
acquirem before deciding which ts to use, rather than assume
getg().m.p won't change before ts.lock can complete.
This CL does that.

Before CL 564977,

stress ./time.test -test.run='ZeroTimer/impl=(func|cache)' -test.timeout=3m -test.count=20

ran without failure for over an hour on my laptop.
Starting in CL 564977, it consistently failed within a few minutes.
After this CL, it now runs without failure for over an hour again.

Fixes #66006.

Change-Id: Ib9e7ccaa0f22a326ce3fdef2b9a92f7f0bdafcbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/571196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoRevert "cmd/compile/internal/inline: refactor fixpoint algorithm"
Matthew Dempsky [Thu, 14 Mar 2024 02:03:29 +0000 (02:03 +0000)]
Revert "cmd/compile/internal/inline: refactor fixpoint algorithm"

This reverts commit 28e0052ee7f3623c28aa08afc41416b29cbddebc.

Reason for revert: #66261

Change-Id: I9dfc8946c41e504c97ecad752971d760ae7a7416
Reviewed-on: https://go-review.googlesource.com/c/go/+/571555
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agocmd/go/internal/test: add 'tests' vet check to 'go test' suite
Alan Donovan [Wed, 20 Sep 2023 18:13:35 +0000 (14:13 -0400)]
cmd/go/internal/test: add 'tests' vet check to 'go test' suite

The tests analyser reports structural problems in test
declarations. Presumably most of these would be caught by
go test itself, which compiles and runs (some subset of) the
tests, but Benchmark and Fuzz functions are executed less
frequently and may benefit more from static checks.

Also, reflect the change in go test help message.

+ release note

Fixes golang/go#44251

Change-Id: If5b9dee6d18fa0bc4de7f5f5f549eddeae953fc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/529816
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

13 months agointernal/trace/v2: support old trace format
Dominik Honnef [Sat, 20 Jan 2024 16:37:50 +0000 (17:37 +0100)]
internal/trace/v2: support old trace format

Add support for traces from Go 1.11–1.19 by converting old traces to the
Go 1.22 format on the fly.

We import Gotraceui's trace parser, which is an optimized parser based
on Go 1.19's internal/trace package, and further modify it for the needs
of the conversion process.

With the optimized parser, loading old traces using the new API is twice
as fast and uses less total memory than 'go tool trace' did in older
versions.

The new parser does not, however, support traces from versions older
than 1.11.

This commit does not update cmd/trace to use the new API for old traces.

Change-Id: If9380aa515e29445ff624274d1760ee945ca4816
Reviewed-on: https://go-review.googlesource.com/c/go/+/557356
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agotime: garbage collect unstopped Tickers and Timers
Russ Cox [Thu, 15 Feb 2024 01:36:47 +0000 (20:36 -0500)]
time: garbage collect unstopped Tickers and Timers

From the beginning of Go, the time package has had a gotcha:
if you use a select on <-time.After(1*time.Minute), even if the select
finishes immediately because some other case is ready, the underlying
timer from time.After keeps running until the minute is over. This
pins the timer in the timer heap, which keeps it from being garbage
collected and in extreme cases also slows down timer operations.
The lack of garbage collection is the more important problem.

The docs for After warn against this scenario and suggest using
NewTimer with a call to Stop after the select instead, purely to work
around this garbage collection problem.

Oddly, the docs for NewTimer and NewTicker do not mention this
problem, but they have the same issue: they cannot be collected until
either they are Stopped or, in the case of Timer, the timer expires.
(Tickers repeat, so they never expire.) People have built up a shared
knowledge that timers and tickers need to defer t.Stop even though the
docs do not mention this (it is somewhat implied by the After docs).

This CL fixes the garbage collection problem, so that a timer that is
unreferenced can be GC'ed immediately, even if it is still running.
The approach is to only insert the timer into the heap when some
channel operation is blocked on it; the last channel operation to stop
using the timer takes it back out of the heap. When a timer's channel
is no longer referenced, there are no channel operations blocked on
it, so it's not in the heap, so it can be GC'ed immediately.

This CL adds an undocumented GODEBUG asynctimerchan=1
that will disable the change. The documentation happens in
the CL 568341.

Fixes #8898.
Fixes #61542.

Change-Id: Ieb303b6de1fb3527d3256135151a9e983f3c27e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/512355
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>

13 months agotime: clean up benchmarks
Russ Cox [Mon, 11 Mar 2024 03:41:33 +0000 (23:41 -0400)]
time: clean up benchmarks

Comparing BenchmarkStop against very old commits like
CL 13094043, I was very confused about how timers had
gotten almost 10X slower since 2013.

It turns out that CL 68060043 introduced a factor of 1000
in the benchmark cost, by counting batches of 1000 as 1 op
instead of 1000 ops, and timers have actually gotten
dramatically faster since 2013, with the addition of per-P
timer heaps and other optimizations.

This CL rewrites the benchmarks to use testing.PB directly,
so that the factor of 1000 disappears, and "/op" really means "/op".
In the few tests that need to run in batches for one reason or
another, add "1000" to the name to make clear that batches
are being run.

Change-Id: I27ed74d1e420934982e4205aad4f218cdfc42509
Reviewed-on: https://go-review.googlesource.com/c/go/+/570495
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoos,internal/godebugs: add missing IncNonDefault calls
qmuntal [Mon, 11 Mar 2024 17:16:16 +0000 (18:16 +0100)]
os,internal/godebugs: add missing IncNonDefault calls

Fixes #66215

Change-Id: Id7de15feabe08f66c048dc114c09494813c9febc
Reviewed-on: https://go-review.googlesource.com/c/go/+/570695
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoencoding/binary: cache struct sizes to speed up Read and Write for slice of structs.
kwakubiney [Mon, 11 Mar 2024 22:53:08 +0000 (22:53 +0000)]
encoding/binary: cache struct sizes to speed up Read and Write for slice of structs.

A lot of allocations happen in dataSize due to reflection.

Cache the result of the function when encoding a
slice of structs similar to what is done for struct types
so that subsequent calls to dataSize can avoid allocations.

                        │   old.txt   │            new.txt            │
                        │   sec/op    │   sec/op     vs base          │
WriteSlice1000Structs-2   846.7µ ± 4%   856.4µ ± 3%  ~ (p=0.602 n=20)

                        │   old.txt    │            new.txt             │
                        │     B/s      │     B/s       vs base          │
WriteSlice1000Structs-2   84.48Mi ± 4%   83.52Mi ± 3%  ~ (p=0.602 n=20)

                        │   old.txt    │               new.txt               │
                        │     B/op     │     B/op      vs base               │
WriteSlice1000Structs-2   80.18Ki ± 0%   80.06Ki ± 0%  -0.15% (p=0.000 n=20)

                        │   old.txt   │              new.txt               │
                        │  allocs/op  │ allocs/op   vs base                │
WriteSlice1000Structs-2   16.000 ± 0%   1.000 ± 0%  -93.75% (p=0.000 n=2

                       │   old.txt   │              new.txt               │
                       │   sec/op    │   sec/op     vs base               │
ReadSlice1000Structs-2   847.4µ ± 4%   821.1µ ± 3%  -3.10% (p=0.012 n=20)

                       │   old.txt    │               new.txt               │
                       │     B/s      │     B/s       vs base               │
ReadSlice1000Structs-2   84.40Mi ± 4%   87.11Mi ± 3%  +3.20% (p=0.012 n=20)

                       │   old.txt    │               new.txt               │
                       │     B/op     │     B/op      vs base               │
ReadSlice1000Structs-2   80.12Ki ± 0%   80.00Ki ± 0%  -0.15% (p=0.000 n=20)

                       │   old.txt   │              new.txt               │
                       │  allocs/op  │ allocs/op   vs base                │
ReadSlice1000Structs-2   16.000 ± 0%   1.000 ± 0%  -93.75% (p=0.000 n=20)

Fixes #66253

Change-Id: I8227e61306db1fe103489ea4fee2429247c3debc
Reviewed-on: https://go-review.googlesource.com/c/go/+/570855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

13 months agocmd/go: change some counter names
Michael Matloob [Mon, 11 Mar 2024 20:35:45 +0000 (16:35 -0400)]
cmd/go: change some counter names

Primarily, this change removes the cmd/ prefix on the go command
counter names. The 'error' counter is changed to 'errors' reflecting
that it's a bucket that contains multiple errors. the switch-exec and
select-exec counters are moved into a 'toolchain' grouping.

For #58894

Change-Id: Id6e0e7a0b4a5e42a0aef04b1210d2bb5256eb6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/570736
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoruntime: add minimal debug tracing of runtime timers
Russ Cox [Sat, 9 Mar 2024 18:41:24 +0000 (13:41 -0500)]
runtime: add minimal debug tracing of runtime timers

Toggled by a compile-time const, so there should be no
runtime footprint in ordinary builds.

Change-Id: I7751847524f4fda3853388d3e5a18188bd737c27
Reviewed-on: https://go-review.googlesource.com/c/go/+/570336
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
13 months agoruntime: clean up timer state
Russ Cox [Sat, 9 Mar 2024 18:36:58 +0000 (13:36 -0500)]
runtime: clean up timer state

The timers had evolved to the point where the state was stored as follows:

if timer in heap:
    state has timerHeaped set
    if heap timer is stale:
        heap deadline in t.when
        real deadline in t.nextWhen
        state has timerNextWhen set
    else:
        real deadline in t.when
        t.nextWhen unset
else:
    real deadline in t.when
    t.nextWhen unset

That made it hard to find the real deadline and just hard to think about everything.
The new state is:

real deadline in t.when (always)
if timer in heap:
    state has timerHeaped set
    heap deadline in t.whenHeap
    if heap timer is stale:
        state has timerModified set

Separately, the 'state' word itself was being used as a lock
and state bits because the code started with CAS loops,
which we abstracted into the lock/unlock methods step by step.
At this point, we can switch to a real lock, making sure to
publish the one boolean needed by timers fast paths
at each unlock.

All this simplifies various logic considerably.

Change-Id: I35766204f7a26d999206bd56cc0db60ad1b17cbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/570335
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
13 months agoruntime: fix another lock ordering problem
Russ Cox [Wed, 13 Mar 2024 02:00:22 +0000 (22:00 -0400)]
runtime: fix another lock ordering problem

https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8753622336585847105/+/u/step/11/log/2
shows a staticlockranking crash with pollcache (defaulted to LEAF)
being held during a write barrier, which got unlucky and acquired
wbufSpans, triggering a lock ordering throw.

My change in https://go-review.googlesource.com/c/go/+/570335/13/src/runtime/netpoll.go
around line 700 caused batching of many write barriers on the first
call rather than having just a few write barriers on each call,
making the crash much more likely, but the ordering problem
appears to have always existed. We just never allocated enough
pollDescs to trigger it.

Change-Id: Icb5e8340a5027dd4f7535a5ef02b2868476539e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/571195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
13 months agocmd/asm,cmd/compile: generate less instructions for most 32 bit constant adds on...
Paul E. Murphy [Fri, 16 Feb 2024 19:29:16 +0000 (13:29 -0600)]
cmd/asm,cmd/compile: generate less instructions for most 32 bit constant adds on ppc64x

For GOPPC64 < 10 targets, most large 32 bit constants (those
exceeding int16 capacity) can be added using two instructions
instead of 3.

This cannot be done for values greater than 0x7FFF7FFF, so this
must be done during asm preprocessing as the optab matching
rules cannot differentiate this special case.

Likewise, constants 0x8000 <= x < 0x10000 are not converted. The
assembler currently generates 2 instructions sequences for these
constants.

Change-Id: I1ccc839c6c28fc32f15d286b2e52e2d22a2a06d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/568116
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>