]> Cypherpunks repositories - gostls13.git/log
gostls13.git
13 months agoruntime: fix timer race introduced in CL 573455
Russ Cox [Wed, 27 Mar 2024 14:08:25 +0000 (10:08 -0400)]
runtime: fix timer race introduced in CL 573455

There is a short window when timers.adjust could miss a
timer update. Close that window. Does not change benchmark.

goos: linux
goarch: amd64
pkg: time
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                   │ s7base.txt  │               s7.txt                │
                                   │   sec/op    │    sec/op     vs base               │
AdjustTimers10000-32                 239.9µ ± 5%   237.6µ ±  8%       ~ (p=0.631 n=10)
AdjustTimers10000SingleThread-32     1.686m ± 8%   1.710m ±  5%       ~ (p=0.481 n=10)
AdjustTimers10000NoReset-32          194.1µ ± 1%   190.8µ ±  2%  -1.69% (p=0.023 n=10)
AdjustTimers10000NoSleep-32          226.2µ ± 3%   222.9µ ±  3%       ~ (p=0.143 n=10)
AdjustTimers10000NoResetNoSleep-32   182.9µ ± 1%   180.9µ ±  2%       ~ (p=0.165 n=10)

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M3 Pro
                                   │ m3base.txt  │               m3.txt               │
                                   │   sec/op    │   sec/op     vs base               │
AdjustTimers10000-12                 269.3µ ± 2%   267.0µ ± 2%       ~ (p=0.529 n=10)
AdjustTimers10000SingleThread-12     1.176m ± 1%   1.213m ± 1%  +3.15% (p=0.000 n=10)
AdjustTimers10000NoReset-12          262.6µ ± 2%   261.4µ ± 3%       ~ (p=0.123 n=10)
AdjustTimers10000NoSleep-12          247.8µ ± 1%   246.5µ ± 1%       ~ (p=0.393 n=10)
AdjustTimers10000NoResetNoSleep-12   231.0µ ± 1%   232.3µ ± 1%       ~ (p=0.684 n=10)

Change-Id: Ifdfcdd5a25046027912a8b306644bde7ec2d3214
Reviewed-on: https://go-review.googlesource.com/c/go/+/574741
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoruntime: adjust when timers.adjust is called
Russ Cox [Thu, 28 Mar 2024 01:46:12 +0000 (21:46 -0400)]
runtime: adjust when timers.adjust is called

This new logic more closely mimics what we did before my CL stack.
I had reasoned that certainly

ts.adjust(now, force=true)
ts.run(now)

would be faster than

ts.adjust(now, force=false)
ts.run(now)
ts.adjust(now, force=true)

But certainty is just an emotion, and that turns out not to be the case.

I don't really understand why the second sequence is faster,
but it definitely is, so put it back.

goos: linux
goarch: amd64
pkg: time
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                   │ s7base.txt  │               s7.txt               │
                                   │   sec/op    │   sec/op     vs base               │
AdjustTimers10000-32                 263.3µ ± 4%   239.9µ ± 5%  -8.87% (p=0.000 n=10)
AdjustTimers10000SingleThread-32     1.742m ± 3%   1.686m ± 8%       ~ (p=0.105 n=10)
AdjustTimers10000NoReset-32          192.2µ ± 2%   194.1µ ± 1%  +1.00% (p=0.009 n=10)
AdjustTimers10000NoSleep-32          237.0µ ± 2%   226.2µ ± 3%  -4.55% (p=0.001 n=10)
AdjustTimers10000NoResetNoSleep-32   185.2µ ± 1%   182.9µ ± 1%  -1.23% (p=0.003 n=10)

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M3 Pro
                                   │ m3base.txt  │               m3.txt               │
                                   │   sec/op    │   sec/op     vs base               │
AdjustTimers10000-12                 272.6µ ± 3%   269.3µ ± 2%       ~ (p=0.063 n=10)
AdjustTimers10000SingleThread-12     1.126m ± 1%   1.176m ± 1%  +4.42% (p=0.000 n=10)
AdjustTimers10000NoReset-12          255.1µ ± 2%   262.6µ ± 2%  +2.96% (p=0.000 n=10)
AdjustTimers10000NoSleep-12          250.2µ ± 2%   247.8µ ± 1%       ~ (p=0.063 n=10)
AdjustTimers10000NoResetNoSleep-12   230.3µ ± 1%   231.0µ ± 1%       ~ (p=0.280 n=10)

Change-Id: I67b5765f97dfca0142ee38e15a9904b520f51e83
Reviewed-on: https://go-review.googlesource.com/c/go/+/574740
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 agoruntime: optimize timers.cleanHead
Russ Cox [Thu, 28 Mar 2024 02:00:31 +0000 (22:00 -0400)]
runtime: optimize timers.cleanHead

goos: linux
goarch: amd64
pkg: time
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                   │ s7base.txt  │               s7.txt                │
                                   │   sec/op    │   sec/op     vs base                │
AdjustTimers10000-32                 291.4µ ± 5%   263.3µ ± 4%   -9.64% (p=0.000 n=10)
AdjustTimers10000SingleThread-32     1.728m ± 5%   1.742m ± 3%        ~ (p=0.796 n=10)
AdjustTimers10000NoReset-32          253.1µ ± 6%   192.2µ ± 2%  -24.07% (p=0.000 n=10)
AdjustTimers10000NoSleep-32          277.3µ ± 3%   237.0µ ± 2%  -14.54% (p=0.000 n=10)
AdjustTimers10000NoResetNoSleep-32   241.4µ ± 2%   185.2µ ± 1%  -23.30% (p=0.000 n=10)

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M3 Pro
                                   │ m3base.txt  │               m3.txt                │
                                   │   sec/op    │   sec/op     vs base                │
AdjustTimers10000-12                 288.1µ ± 1%   272.6µ ± 3%   -5.38% (p=0.000 n=10)
AdjustTimers10000SingleThread-12     1.195m ± 1%   1.126m ± 1%   -5.74% (p=0.000 n=10)
AdjustTimers10000NoReset-12          280.8µ ± 1%   255.1µ ± 2%   -9.14% (p=0.000 n=10)
AdjustTimers10000NoSleep-12          292.5µ ± 1%   250.2µ ± 2%  -14.47% (p=0.000 n=10)
AdjustTimers10000NoResetNoSleep-12   279.8µ ± 2%   230.3µ ± 1%  -17.69% (p=0.000 n=10)

Change-Id: I36edb40ee2cd11ab44d20bff045fa77609dca648
Reviewed-on: https://go-review.googlesource.com/c/go/+/574739
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 agoruntime: avoid unnecessary netpoll wakeups during timer creation
Russ Cox [Thu, 28 Mar 2024 02:44:52 +0000 (22:44 -0400)]
runtime: avoid unnecessary netpoll wakeups during timer creation

goos: linux
goarch: amd64
pkg: time
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                   │ s7base.txt  │               s7.txt               │
                                   │   sec/op    │   sec/op     vs base               │
AdjustTimers10000-32                 315.1µ ± 4%   291.4µ ± 5%  -7.52% (p=0.001 n=10)
AdjustTimers10000SingleThread-32     1.728m ± 6%   1.728m ± 5%       ~ (p=0.971 n=10)
AdjustTimers10000NoReset-32          263.0µ ± 3%   253.1µ ± 6%  -3.75% (p=0.023 n=10)
AdjustTimers10000NoSleep-32          306.8µ ± 5%   277.3µ ± 3%  -9.62% (p=0.000 n=10)
AdjustTimers10000NoResetNoSleep-32   245.3µ ± 3%   241.4µ ± 2%       ~ (p=0.529 n=10)

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M3 Pro
                                   │ m3base.txt  │               m3.txt                │
                                   │   sec/op    │   sec/op     vs base                │
AdjustTimers10000-12                 385.5µ ± 3%   288.1µ ± 1%  -25.26% (p=0.000 n=10)
AdjustTimers10000SingleThread-12     1.213m ± 1%   1.195m ± 1%   -1.45% (p=0.001 n=10)
AdjustTimers10000NoReset-12          346.4µ ± 5%   280.8µ ± 1%  -18.94% (p=0.000 n=10)
AdjustTimers10000NoSleep-12          362.6µ ± 1%   292.5µ ± 1%  -19.33% (p=0.000 n=10)
AdjustTimers10000NoResetNoSleep-12   317.3µ ± 8%   279.8µ ± 2%  -11.79% (p=0.000 n=10)

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

13 months agoencoding/asn1: simplify appendFourDigits
apocelipes [Tue, 26 Mar 2024 06:44:26 +0000 (06:44 +0000)]
encoding/asn1: simplify appendFourDigits

The new code does not need a for-loop and is easier to read.

Change-Id: Ic182d63c4779c2179b721fcfaec362681284cc16
GitHub-Last-Rev: b3ee265df7eb4d51c945bf5453eb1b09f91912d9
GitHub-Pull-Request: golang/go#63879
Reviewed-on: https://go-review.googlesource.com/c/go/+/538721
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agointernal/sysinfo: implement CPUName on bsd systems
Russ Cox [Thu, 17 Aug 2023 19:44:20 +0000 (15:44 -0400)]
internal/sysinfo: implement CPUName on bsd systems

sysctl machdep.cpu.brand_string seems to be standard
across the BSDs. There does not seem to be a standard
way to get the CPU frequency.

Change-Id: Ic986d6c81dd54e1b84544317f2a53ce16801319b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520636
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
13 months agocmd/go: replace reflect.DeepEqual with slices.Equal and maps.Equal
Daniel Martí [Tue, 26 Mar 2024 20:59:41 +0000 (22:59 +0200)]
cmd/go: replace reflect.DeepEqual with slices.Equal and maps.Equal

All of these maps and slices are made up of comparable types,
so we can avoid the overhead of reflection entirely.

Change-Id: If77dbe648a336ba729c171e84c9ff3f7e160297d
Reviewed-on: https://go-review.googlesource.com/c/go/+/574597
Reviewed-by: Than McIntosh <thanm@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 agocmd/compile: rename cmd/compile/internal/pgo to cmd/compile/internal/pgoir
Michael Pratt [Tue, 5 Mar 2024 16:04:26 +0000 (11:04 -0500)]
cmd/compile: rename cmd/compile/internal/pgo to cmd/compile/internal/pgoir

This helps reduce confusion with cmd/internal/pgo, which performs
compilation-independent analysis. pgoir associates that data with the
IR from the current package compilation.

For #58102.

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

13 months agocmd/compile,cmd/preprofile: move logic to shared common package
Michael Pratt [Mon, 4 Mar 2024 18:29:39 +0000 (13:29 -0500)]
cmd/compile,cmd/preprofile: move logic to shared common package

The processing performed in cmd/preprofile is a simple version of the
same initial processing performed by cmd/compile/internal/pgo. Refactor
this processing into the new IR-independent cmd/internal/pgo package.

Now cmd/preprofile and cmd/compile run the same code for initial
processing of a pprof profile, guaranteeing that they always stay in
sync.

Since it is now trivial, this CL makes one change to the serialization
format: the entries are ordered by weight. This allows us to avoid
sorting ByWeight on deserialization.

Impact on PGO parsing when compiling cmd/compile with PGO:

* Without preprocessing: PGO parsing ~13.7% of CPU time
* With preprocessing (unsorted): ~2.9% of CPU time (sorting ~1.7%)
* With preprocessing (sorted): ~1.3% of CPU time

The remaining 1.3% of CPU time approximately breaks down as:

* ~0.5% parsing the preprocessed profile
* ~0.7% building weighted IR call graph
  * ~0.5% walking function IR to find direct calls
  * ~0.2% performing lookups for indirect calls targets

For #58102.

Change-Id: Iaba425ea30b063ca195fb2f7b29342961c8a64c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/569337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agoos: make readdir more robust on Windows
qmuntal [Mon, 25 Mar 2024 15:37:05 +0000 (16:37 +0100)]
os: make readdir more robust on Windows

On Windows, File.readdir currently fails if the volume information
can't be retrieved via GetVolumeInformationByHandle and if the
directory path is relative and can't be converted to an absolute
path.

This change makes readdir more robust by not failing in these cases,
as these steps are just necessary to support a potential call to
os.SameFile, but not for the actual readdir operation. os.SameFile
will still fail in these cases, but that's a separate issue tracked
in #62042.

Change-Id: I8d98d8379bdac4b2832fa433432a5f027756abaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/574155
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agotest: issue16016: use fewer goroutines for gccgo
Ian Lance Taylor [Tue, 26 Mar 2024 20:18:34 +0000 (13:18 -0700)]
test: issue16016: use fewer goroutines for gccgo

For https://gcc.gnu.org/PR114453

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

13 months agoall: make use of builtin clear
Jes Cok [Wed, 27 Mar 2024 12:44:18 +0000 (20:44 +0800)]
all: make use of builtin clear

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

13 months agocmd/preprofile: drop output directory check
Michael Pratt [Mon, 4 Mar 2024 18:20:43 +0000 (13:20 -0500)]
cmd/preprofile: drop output directory check

This check serves only to provide a more descriptive error if the output
directory doesn't exist. That isn't useless, but I don't see why this tool
specifically should do this when no other part of the toolchain does.

For #58102.

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

13 months agocmd/preprofile: clean up error handling
Michael Pratt [Mon, 4 Mar 2024 17:38:43 +0000 (12:38 -0500)]
cmd/preprofile: clean up error handling

This CL adjusts error handling to be a bit more idiomatic. The
processing function returns errors, leaving main to log and exit on
error.

This CL contains no functional changes.

For #58102.

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

13 months agocrypto/internal/boring: don't shadow named returns
Roland Shoemaker [Mon, 25 Mar 2024 16:11:26 +0000 (17:11 +0100)]
crypto/internal/boring: don't shadow named returns

In setupRSA we use named returns so that we can defer freeing of the
boring private key and context, but were using returns of the form
`return nil, nil, ...` which nil'd the named returns, preventing them
from actually being freed.

Update all of the returns to not shadow the named variables.

Thanks to Quim Muntal of Microsoft for reporting this issue.

Change-Id: Iaf0f0b17e123a7df730cb1e91a324fe622611f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/574195
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agoruntime,hash/maphash: reuse hashSets to save memory pressure
Keith Randall [Tue, 26 Mar 2024 16:23:16 +0000 (09:23 -0700)]
runtime,hash/maphash: reuse hashSets to save memory pressure

Might help with OOMs on 32-bit platforms

Change-Id: Idd5129c61ecdfeedd5a9a18fce85dbba27cab946
Reviewed-on: https://go-review.googlesource.com/c/go/+/574475
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agocrypto/aes: fix regression for ppc64x
Lynn Boger [Mon, 25 Mar 2024 16:14:27 +0000 (11:14 -0500)]
crypto/aes: fix regression for ppc64x

CL 561080 introduced some failures for CBC and GCM crypto tests that are run during a build resulting in dashboard failures.

Tests that are failing:
- TestCBCEncrypterAES
- TestCBCDecrypterAES
- TestAESGCM
- TestGCMCounterWrap
- TestGCMAsm

This fixes those failures.

Change-Id: I90d6f8d279a3051cf951a1a9628afb8d0b5c2f17
Reviewed-on: https://go-review.googlesource.com/c/go/+/574076
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
13 months agoall: fix a large number of comments
cui fliter [Fri, 22 Mar 2024 15:31:44 +0000 (23:31 +0800)]
all: fix a large number of comments

Partial typo corrections, following https://go.dev/wiki/Spelling

Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/573776
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

13 months agocmd/internal/ssa: fix typo in comment
guoguangwu [Fri, 22 Mar 2024 06:17:00 +0000 (06:17 +0000)]
cmd/internal/ssa: fix typo in comment

Change-Id: Ib66830792ebb15538596f4bf4a51d2b3f05c7fe7
GitHub-Last-Rev: 947445916abc91331f51e29c0541c510bd9c623c
GitHub-Pull-Request: golang/go#66460
Reviewed-on: https://go-review.googlesource.com/c/go/+/573557
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@google.com>
13 months agocmd/link: close memory profile
guoguangwu [Tue, 26 Mar 2024 06:38:55 +0000 (06:38 +0000)]
cmd/link: close memory profile

Change-Id: If17e982dd0272e90972d2d4a94b1a744343ae2ec
GitHub-Last-Rev: c8d03566b3e66a6de58e778102fa60f5d46ab2d9
GitHub-Pull-Request: golang/go#66531
Reviewed-on: https://go-review.googlesource.com/c/go/+/574335
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Than McIntosh <thanm@google.com>

13 months agoregexp/syntax: simplify the code
apocelipes [Mon, 25 Mar 2024 14:13:35 +0000 (14:13 +0000)]
regexp/syntax: simplify the code

Use the slices package and the built-in max to simplify the code.
There's no noticeable performance change in this modification.

Change-Id: I96e46ba8ab1323f1ba0b8c9b827836e217772cf2
GitHub-Last-Rev: f0111ac7e220f7dac03290125a3a83831012f235
GitHub-Pull-Request: golang/go#66511
Reviewed-on: https://go-review.googlesource.com/c/go/+/573978
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agoruntime,hash/maphash: make tests use less memory
Keith Randall [Mon, 25 Mar 2024 20:53:07 +0000 (13:53 -0700)]
runtime,hash/maphash: make tests use less memory

Use a list + sorting instead of a map to keep track of collisions.
Should save a fair amount of memory.

Change-Id: I7b48cdb5f7060d12ebbb950d56b5c479f131c027
Reviewed-on: https://go-review.googlesource.com/c/go/+/574275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Keith Randall <khr@google.com>
13 months agonet/http: fix typo in log message
Damien Neil [Mon, 25 Mar 2024 20:03:37 +0000 (13:03 -0700)]
net/http: fix typo in log message

Change-Id: I399c65b44706cf5407099e867de27b3acdaf4825
Reviewed-on: https://go-review.googlesource.com/c/go/+/574235
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agoslices: add examples
Jes Cok [Thu, 21 Mar 2024 05:50:37 +0000 (13:50 +0800)]
slices: add examples

For Clone, Grow, Clip, Concat, Contains, Repeat.

Fixes #66435

Change-Id: Ife8f61427e9cd18b7106c100de8f82f9d7840c9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/573255
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agonet/http: panic early in do when Client is nil
Kevin Burke [Fri, 24 Jun 2022 20:13:05 +0000 (13:13 -0700)]
net/http: panic early in do when Client is nil

Callers who invoke `*http.Client.Do` with a nil *Client will now panic
at the top of c.Do, instead of panicking when `deadline` attempts to
read `c.Timeout`.

Errors inside of net/http can be difficult to track down because the
caller is often invoking the standard library code via an SDK. This
can mean that there are many places to check when code panics, and
raises the importance of being clear about error messages.

If nil receiver calls panic during the `deadline()` call, callers
may confuse the error with a more common timeout or deadline
misconfiguration, which may lead a caller who passed a nil receiver
(the author, for example) down the wrong rabbit hole, or cause them to
suspect their timeout/deadline logic. It is less common to configure
client.Jar, so the probability of detecting the actual problem, given
the underlying error cause, is higher.

Fixes #53521.

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

13 months agoruntime: don't call lockOSThread for every syscall call on Windows
qmuntal [Mon, 11 Mar 2024 09:49:44 +0000 (10:49 +0100)]
runtime: don't call lockOSThread for every syscall call on Windows

Windows syscall.SyscallN currently calls lockOSThread for every syscall.
This can be expensive and produce unnecessary context switches,
especially when the syscall is called frequently under high contention.

The lockOSThread was necessary to ensure that cgocall wouldn't
reschedule the goroutine to a different M, as the syscall return values
are reported back in the M struct.

This CL instructs cgocall to copy the syscall return values into the
the M that will see the caller on return, so the caller no longer needs
to call lockOSThread.

Updates #58336.

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64,gotip-windows-amd64-longtest
Change-Id: If6644fd111dbacab74e7dcee2afa18ca146735da
Reviewed-on: https://go-review.googlesource.com/c/go/+/562915
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agocmd/internal/obj/riscv: use native rotation instructions for rva22u64
Joel Sing [Tue, 19 Mar 2024 11:36:42 +0000 (22:36 +1100)]
cmd/internal/obj/riscv: use native rotation instructions for rva22u64

When rva22u64 is available, we can now use the native rotation instructions
from the Zbb extension. Use these instead of synthesising rotation
instructions.

This provides a significant performance gain for SHA-512, the following
benchmarked on a StarFive VisionFive 2:

                    │ sha512.rva20u64 │            sha512.rva22u64            │
                    │       B/s       │      B/s       vs base                │
Hash8Bytes/New-4         859.4Ki ± 0%   1337.9Ki ± 0%  +55.68% (p=0.000 n=10)
Hash8Bytes/Sum384-4      888.7Ki ± 1%   1308.6Ki ± 1%  +47.25% (p=0.000 n=10)
Hash8Bytes/Sum512-4      869.1Ki ± 0%   1269.5Ki ± 1%  +46.07% (p=0.000 n=10)
Hash1K/New-4             19.83Mi ± 0%    29.03Mi ± 0%  +46.38% (p=0.000 n=10)
Hash1K/Sum384-4          20.00Mi ± 0%    28.86Mi ± 0%  +44.30% (p=0.000 n=10)
Hash1K/Sum512-4          19.93Mi ± 0%    28.72Mi ± 0%  +44.11% (p=0.000 n=10)
Hash8K/New-4             23.85Mi ± 0%    34.12Mi ± 0%  +43.09% (p=0.000 n=10)
Hash8K/Sum384-4          23.88Mi ± 0%    34.09Mi ± 0%  +42.77% (p=0.000 n=10)
Hash8K/Sum512-4          23.87Mi ± 0%    34.07Mi ± 0%  +42.71% (p=0.000 n=10)
geomean                  7.399Mi         10.78Mi       +45.77%

Change-Id: I9dca8e3f311eea101684c806cb998872dc697288
Reviewed-on: https://go-review.googlesource.com/c/go/+/572716
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agoruntime: fix the failures from longtest builders
Andy Pan [Mon, 25 Mar 2024 23:13:57 +0000 (07:13 +0800)]
runtime: fix the failures from longtest builders

Follow up CL 560155

Change-Id: Id9230d79c296452f3741123c75b45c3d3b1be4f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/574295
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agointernal/trace/v2: fix reader version for dumping text output
Michael Anthony Knyszek [Mon, 25 Mar 2024 17:00:55 +0000 (17:00 +0000)]
internal/trace/v2: fix reader version for dumping text output

There was recently a failure that we don't have a trace dump for because
the reader was passed Go122 but traces have moved onto version Go123.
Use version.Current to prevent this from happening again in the future.

Change-Id: I4f8b3c3ea5bad61a07839a697cd5d7793d62ea52
Reviewed-on: https://go-review.googlesource.com/c/go/+/574216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
13 months agoruntime: migrate internal/atomic to internal/runtime
Andy Pan [Thu, 1 Feb 2024 02:21:14 +0000 (10:21 +0800)]
runtime: migrate internal/atomic to internal/runtime

For #65355

Change-Id: I65dd090fb99de9b231af2112c5ccb0eb635db2be
Reviewed-on: https://go-review.googlesource.com/c/go/+/560155
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ibrahim Bazoka <ibrahimbazoka729@gmail.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agocmd/go/internal/modget: remove duplicate exit
Zxilly [Tue, 19 Mar 2024 01:09:54 +0000 (01:09 +0000)]
cmd/go/internal/modget: remove duplicate exit

base.ExitIfErrors() has been deferred at the begin of the function,
no need to call it again.

Change-Id: I4fc81572cfce0f84832448da667c65bb477dea22
GitHub-Last-Rev: cc156358755d516a9c8a6989f4601345bd3b55bc
GitHub-Pull-Request: golang/go#66392
Reviewed-on: https://go-review.googlesource.com/c/go/+/572576
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agoregexp: use slices to simplify the code
apocelipes [Mon, 25 Mar 2024 05:58:00 +0000 (05:58 +0000)]
regexp: use slices to simplify the code

Replace some "reflect.DeepEqual" calls in the tests with
"slices.Equal" which is much faster for slice comparisons.

Remove unnecessary "runeSlice" and redundant helper functions.

Change-Id: Ib5dc41848d7a3c5149f41701d60471a487cff476
GitHub-Last-Rev: 87b5ed043d2935b971aa676cc52b9b2c5b45736b
GitHub-Pull-Request: golang/go#66509
Reviewed-on: https://go-review.googlesource.com/c/go/+/573977
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
13 months agotest/stress: fix typo in comment
guoguangwu [Mon, 25 Mar 2024 02:21:10 +0000 (02:21 +0000)]
test/stress: fix typo in comment

Change-Id: I0f67801ef2d3af65c39a27b8db6ebaa769ff7f92
GitHub-Last-Rev: feb7f79ea519450a054de18e10ffa6284538708b
GitHub-Pull-Request: golang/go#66508
Reviewed-on: https://go-review.googlesource.com/c/go/+/574075
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>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
13 months agocrypto/rand: close /dev/random on plan9 after seeding
guoguangwu [Mon, 25 Mar 2024 00:52:53 +0000 (00:52 +0000)]
crypto/rand: close /dev/random on plan9 after seeding

Change-Id: I77241ed2ccace63062e862438dd9d7fcebc88201
GitHub-Last-Rev: dbff3282e06ac8a9af1635c750a37d1d69f18fc8
GitHub-Pull-Request: golang/go#66505
Reviewed-on: https://go-review.googlesource.com/c/go/+/573976
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agoos: reuse buffer pool more aggressively in readdir
qmuntal [Mon, 25 Mar 2024 11:19:47 +0000 (12:19 +0100)]
os: reuse buffer pool more aggressively in readdir

We can reuse the buffer pool more aggressively when reading a directory
by returning the buffer to the pool as soon as we get to the end of the
directory, rather than waiting until the the os.File is closed.

This yields a significant memory usage reduction when traversing
nested directories recursively via os.File#ReadDir (and friends),
as the file pointers tends to be closed only after the entire
traversal is done. For example, this pattern is used in os.RemoveAll.
These are the improvements observed in BenchmarkRemoveAll:

goos: linux
goarch: amd64
pkg: os
cpu: AMD EPYC 7763 64-Core Processor
            │   old.txt   │            new.txt            │
            │   sec/op    │   sec/op     vs base          │
RemoveAll-4   3.847m ± 2%   3.823m ± 1%  ~ (p=0.143 n=10)

            │   old.txt    │               new.txt                │
            │     B/op     │     B/op      vs base                │
RemoveAll-4   39.77Ki ± 2%   17.63Ki ± 1%  -55.68% (p=0.000 n=10)

            │  old.txt   │              new.txt              │
            │ allocs/op  │ allocs/op   vs base               │
RemoveAll-4   510.0 ± 0%   503.0 ± 0%  -1.37% (p=0.000 n=10)

Change-Id: I70e1037378a02f1d670ccb7b275ee55f0caa6d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/573358
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agonet/http: also log TLS errors which look like HTTP sent to an HTTPS port
Damien Neil [Mon, 25 Mar 2024 15:41:34 +0000 (08:41 -0700)]
net/http: also log TLS errors which look like HTTP sent to an HTTPS port

We log TLS handshake errors in general, but currently do not log errors
when the first TLS record looks like an attempt to send HTTP to an HTTPS
port. There doesn't seem to be any principled reason to log the one and
not the other, so just log all TLS handshake errors.

Fixes #66501

Change-Id: I5d78a754d054c220be935513448515721fa387a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/573979
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agolog/slog: use plain string concatenation for Attr.String
Kevin Burke [Thu, 21 Mar 2024 22:59:30 +0000 (15:59 -0700)]
log/slog: use plain string concatenation for Attr.String

Plain string concatenation with the plus operator for Attr.String is
much faster than invoking fmt.Sprintf. Added a benchmark to verify
this (just running on my Mac with stuff in the background but should
be sufficient to demonstrate the effect).

name          old time/op  new time/op  delta
AttrString-8  1.24µs ± 3%  0.43µs ± 0%  -65.17%  (p=0.000 n=20+17)

name          old alloc/op   new alloc/op   delta
AttrString-8      432B ± 0%      152B ± 0%   ~     (p=1.000 n=1+1)

name          old allocs/op  new allocs/op  delta
AttrString-8      30.0 ± 0%      16.0 ± 0%   ~     (p=1.000 n=1+1)

Change-Id: I18ac91cbff1047d168b51a595601e36b5f676615
Reviewed-on: https://go-review.googlesource.com/c/go/+/573517
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agoos: fix typo in test
guoguangwu [Sun, 24 Mar 2024 12:06:41 +0000 (12:06 +0000)]
os: fix typo in test

Change-Id: Ib445940f0f24385dde1b62277c8083e6369d0645
GitHub-Last-Rev: 02c18c27773e966145e379933e4e01d4531e7ec3
GitHub-Pull-Request: golang/go#66503
Reviewed-on: https://go-review.googlesource.com/c/go/+/574016
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
13 months agocrypto/aes: speed up AES by reducing allocations
Marten Seemann [Sun, 4 Feb 2024 05:59:59 +0000 (12:59 +0700)]
crypto/aes: speed up AES by reducing allocations

By embedding the arrays into aesCipher directly, we can save a few allocations
when creating a new AES cipher. This also avoids a lot of pointer chasing when
encrypting and decrypting, leading to 3-4% faster performance.

Fixes #65507.

name                     old time/op    new time/op    delta
Encrypt/AES-128-16         4.70ns ± 3%    4.46ns ± 2%   -5.08%  (p=0.000 n=10+10)
Encrypt/AES-192-16         4.90ns ± 3%    4.71ns ± 2%   -3.98%  (p=0.000 n=10+10)
Encrypt/AES-256-16         5.18ns ± 3%    4.91ns ± 1%   -5.15%  (p=0.000 n=10+10)
Decrypt/AES-128-16         4.51ns ± 2%    4.37ns ± 1%   -3.01%  (p=0.000 n=10+10)
Decrypt/AES-192-16         4.77ns ± 2%    4.63ns ± 2%   -3.05%  (p=0.000 n=10+10)
Decrypt/AES-256-16         5.10ns ± 2%    4.93ns ± 3%   -3.27%  (p=0.000 n=10+10)
Expand/AES-128-16          52.5ns ± 4%    55.9ns ± 3%   +6.58%  (p=0.000 n=10+10)
Expand/AES-192-16          45.6ns ± 5%    48.1ns ± 2%   +5.56%  (p=0.000 n=10+10)
Expand/AES-256-16          69.2ns ± 5%    71.7ns ± 3%   +3.61%  (p=0.006 n=9+10)
CreateCipher/AES-128-16     130ns ± 3%      84ns ± 3%  -35.13%  (p=0.000 n=10+10)
CreateCipher/AES-192-16     128ns ± 2%      78ns ± 3%  -38.82%  (p=0.000 n=10+10)
CreateCipher/AES-256-16     156ns ± 3%     105ns ± 4%  -32.33%  (p=0.000 n=10+10)

name                     old speed      new speed      delta
Encrypt/AES-128-16       3.40GB/s ± 2%  3.59GB/s ± 2%   +5.35%  (p=0.000 n=10+10)
Encrypt/AES-192-16       3.27GB/s ± 3%  3.40GB/s ± 2%   +4.13%  (p=0.000 n=10+10)
Encrypt/AES-256-16       3.09GB/s ± 2%  3.26GB/s ± 1%   +5.42%  (p=0.000 n=10+10)
Decrypt/AES-128-16       3.55GB/s ± 2%  3.66GB/s ± 1%   +3.09%  (p=0.000 n=10+10)
Decrypt/AES-192-16       3.35GB/s ± 2%  3.46GB/s ± 2%   +3.14%  (p=0.000 n=10+10)
Decrypt/AES-256-16       3.14GB/s ± 2%  3.24GB/s ± 3%   +3.39%  (p=0.000 n=10+10)

name                     old alloc/op   new alloc/op   delta
Encrypt/AES-128-16          0.00B          0.00B          ~     (all equal)
Encrypt/AES-192-16          0.00B          0.00B          ~     (all equal)
Encrypt/AES-256-16          0.00B          0.00B          ~     (all equal)
Decrypt/AES-128-16          0.00B          0.00B          ~     (all equal)
Decrypt/AES-192-16          0.00B          0.00B          ~     (all equal)
Decrypt/AES-256-16          0.00B          0.00B          ~     (all equal)
Expand/AES-128-16           0.00B          0.00B          ~     (all equal)
Expand/AES-192-16           0.00B          0.00B          ~     (all equal)
Expand/AES-256-16           0.00B          0.00B          ~     (all equal)
CreateCipher/AES-128-16      448B ± 0%      512B ± 0%  +14.29%  (p=0.000 n=10+10)
CreateCipher/AES-192-16      512B ± 0%      512B ± 0%     ~     (all equal)
CreateCipher/AES-256-16      576B ± 0%      512B ± 0%  -11.11%  (p=0.000 n=10+10)

name                     old allocs/op  new allocs/op  delta
Encrypt/AES-128-16           0.00           0.00          ~     (all equal)
Encrypt/AES-192-16           0.00           0.00          ~     (all equal)
Encrypt/AES-256-16           0.00           0.00          ~     (all equal)
Decrypt/AES-128-16           0.00           0.00          ~     (all equal)
Decrypt/AES-192-16           0.00           0.00          ~     (all equal)
Decrypt/AES-256-16           0.00           0.00          ~     (all equal)
Expand/AES-128-16            0.00           0.00          ~     (all equal)
Expand/AES-192-16            0.00           0.00          ~     (all equal)
Expand/AES-256-16            0.00           0.00          ~     (all equal)
CreateCipher/AES-128-16      4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.000 n=10+10)
CreateCipher/AES-192-16      4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.000 n=10+10)
CreateCipher/AES-256-16      4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.000 n=10+10)

Change-Id: I0ea0b21cf84b11b6a5fc7c6ace144390eb55438b
Reviewed-on: https://go-review.googlesource.com/c/go/+/561080
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
13 months agonet/http: eliminate the needless idle timeout for TestServerNoReadTimeout
Andy Pan [Thu, 21 Mar 2024 13:08:24 +0000 (13:08 +0000)]
net/http: eliminate the needless idle timeout for TestServerNoReadTimeout

Change-Id: I1339749bfeac99848beca780cebb9c87564da656
Reviewed-on: https://go-review.googlesource.com/c/go/+/573335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
13 months agonet/http: update bundled x/net/http2
Andy Pan [Thu, 21 Mar 2024 12:59:39 +0000 (12:59 +0000)]
net/http: update bundled x/net/http2

Keep ReadTimeout, ReadHeaderTimeout, IdleTimeout and WriteTimeout in sync

Change-Id: I32b43884c0078eca86f20ec363f1d702ba298d1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/573315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agointernal/poll: use sync.OnceValue to determine kernel version ≥ 5.3 in CopyFileRange
Tobias Klauser [Fri, 22 Mar 2024 12:39:13 +0000 (13:39 +0100)]
internal/poll: use sync.OnceValue to determine kernel version ≥ 5.3 in CopyFileRange

Change-Id: I13fdf86c3f46bf3c83cb116e9dd3bc4ab1a949d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/573755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.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>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
13 months agotest: put type declaration back inside the function
cui fliter [Fri, 22 Mar 2024 15:07:57 +0000 (23:07 +0800)]
test: put type declaration back inside the function

Because issue #47631 has been fixed, remove TODO.

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

13 months agocmd/link: remove objIdx structure
Jeremy Quirke [Sat, 2 Dec 2023 10:03:13 +0000 (10:03 +0000)]
cmd/link: remove objIdx structure

This indirection appears to be unnecessary for linking or linker debugging, and therefore hinders readability.

Since all *oReaders are added to loader.objs *only* via the Preload -> addObj path, before any symbols are examined, there is no possible way the "i" member of this structure is still useful; and is likely a remnant of an earlier design.

Change-Id: Icd880f40bf3299bf1aa0a14cf217268e49ee90c5
GitHub-Last-Rev: dd2d512cbe99a551585fc9f895eca28a5bfde21b
GitHub-Pull-Request: golang/go#57460
Reviewed-on: https://go-review.googlesource.com/c/go/+/459456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

13 months agocmd/dist: avoid CPU underutilization starting from GOMAXPROCS=2 runtime
qiulaidongfeng [Sat, 23 Mar 2024 03:19:33 +0000 (03:19 +0000)]
cmd/dist: avoid CPU underutilization starting from GOMAXPROCS=2 runtime

This CL is doing now is:
change maxbg to increase test parallelism.
adjust test sequence.

This CL speeds up the go tool dist test,
most of the speed up is due to the fact that the
three time-consuming tests
cmd/internal/testdir and API check and runtime/race
can be done in parallel with the GOMAXPROCS=2 runtime
on a machine with enough CPU cores.

In windows with an 8-core 16-thread CPU,
this CL can complete all other tests before
GOMAXPROCS=2 runtime -cpu=1,2,4 -quick completes.

Fixes #65164

Change-Id: I56ed7031d58be3bece9f975bfc73e5c834d0a4fa
GitHub-Last-Rev: 18cffb770f60399c889ceb40ef8207a2d0c488e5
GitHub-Pull-Request: golang/go#65703
Reviewed-on: https://go-review.googlesource.com/c/go/+/563916
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@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: ensure server handler is done in TestServerNoWriteTimeout
Damien Neil [Fri, 22 Mar 2024 21:33:50 +0000 (14:33 -0700)]
net/http: ensure server handler is done in TestServerNoWriteTimeout

Surprisingly, newClientServerTest doesn't ensure that server handlers
are done in its t.Cleanup function. This test's handler can outlive
the test and attempt to log after the test has completed, causing
race detector failures.

Add an explicit call to Server.Shutdown to ensure the handler
has completed.

We should also probably add a Shutdown to clientServerTest.close,
but that's a larger change; this fixes the immediate problem.

Change-Id: Ibe81b4b382c9c8a920b0ff5f76dea6afe69b10f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/573895
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>

13 months agoencoding/gob: close files used in dump.go and encgen.go
guoguangwu [Thu, 21 Mar 2024 08:15:08 +0000 (08:15 +0000)]
encoding/gob: close files used in dump.go and encgen.go

Change-Id: Ic1dd899fa52fdf9098955fc14a828d2f07da8037
GitHub-Last-Rev: 6e0438ec7178382e2a7d56f0a053cec33fbe9e78
GitHub-Pull-Request: golang/go#66437
Reviewed-on: https://go-review.googlesource.com/c/go/+/573235
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
13 months agopath/filepath: use slices to simplify the test code
apocelipes [Fri, 22 Mar 2024 09:04:08 +0000 (09:04 +0000)]
path/filepath: use slices to simplify the test code

Change-Id: I020ca2ed8a6af60977f2c492cd742f824906d4ec
GitHub-Last-Rev: b27fda463058e86eafbe5bd10e5c99e10dd609a8
GitHub-Pull-Request: golang/go#66462
Reviewed-on: https://go-review.googlesource.com/c/go/+/573715
Reviewed-by: David Chase <drchase@google.com>
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 agoruntime: add fast path for (*timers).adjust
Ian Lance Taylor [Thu, 21 Mar 2024 18:33:24 +0000 (11:33 -0700)]
runtime: add fast path for (*timers).adjust

Affected benchmark results, including new benchmark (some of these may
just be noise, of course):

AdjustTimers10000-12           797.7µ ±  2%   709.6µ ±   2%  -11.04% (p=0.000 n=10)
TickerResetNaive-12            62.69n ±  1%   63.56n ±   1%   +1.40% (p=0.018 n=10)
NowUnixMicro-12                29.95n ±  1%   30.25n ±   4%   +1.00% (p=0.024 n=10)
ParseDuration-12               81.88n ±  0%   81.45n ±   0%   -0.51% (p=0.006 n=10)
UnmarshalText-12               186.9n ±  1%   185.2n ±   1%   -0.88% (p=0.006 n=10)
geomean                        151.8n         151.2n          -0.40%

Change-Id: I3ef8356249c5d703b314498e34ee8095093671c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/573455
Reviewed-by: Austin Clements <austin@google.com>
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>
Commit-Queue: Ian Lance Taylor <iant@google.com>

13 months agointernal/trace/v2: break up ordering.Advance into dispatched methods
Michael Anthony Knyszek [Fri, 23 Feb 2024 23:26:49 +0000 (23:26 +0000)]
internal/trace/v2: break up ordering.Advance into dispatched methods

Currently ordering.Advance is one massive switch statement. This isn't
amazing for readability because it's hard to see at a glance what
happens before and after. Some of the state sharing is nice, but
otherwise, it can get confusing quickly (especially where break is used,
and where there are nested switches).

This CL breaks up the switch statement into individual methods on
ordering.Advance which are loaded and dispatched from a table. This CL
uses a table instead of a switch statement because the arguments passed
are all the same each time, and the table can provide a very precise
mapping for each event; with a switch, we'd be tempted to group cases
that call the same handler method together. It also prevents us from
using defer in many cases, which may help clean up the code. (Each case
in the switch is completely self-contained, yet we can't use a defer
because it's function-scoped.)

As an aside, this should also improve performance a bit. The Go compiler
doesn't handle massive irregular functions very well, especially one
with a lot of return points and (previously) a conditionally deferred
call.

Change-Id: I3ef2cf75301c795b6f23da1e058b0ac303fea8bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/566576
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
13 months agoruntime: add tracing for iter.Pull
Michael Anthony Knyszek [Tue, 20 Feb 2024 21:16:33 +0000 (21:16 +0000)]
runtime: add tracing for iter.Pull

This change resolves a TODO in the coroutine switch implementation (used
exclusively by iter.Pull at the moment) to enable tracing. This was
blocked on eliminating the atomic load in the tracer's "off" path
(completed in the previous CL in this series) and the addition of new
tracer events to minimize the overhead of tracing in this circumstance.

This change introduces 3 new event types to support coroutine switches:
GoCreateBlocked, GoSwitch, and GoSwitchDestroy.

GoCreateBlocked needs to be introduced because the goroutine created for
the coroutine starts out in a blocked state. There's no way to represent
this in the tracer right now, so we need a new event for it.

GoSwitch represents the actual coroutine switch, which conceptually
consists of a GoUnblock, a GoBlock, and a GoStart event in series
(unblocking the next goroutine to run, blocking the current goroutine,
and then starting the next goroutine to run).

GoSwitchDestroy is closely related to GoSwitch, implementing the same
semantics except that GoBlock is replaced with GoDestroy. This is used
when exiting the coroutine.

The implementation of all this is fairly straightforward, and the trace
parser simply translates GoSwitch* into the three constituent events.

Because GoSwitch and GoSwitchDestroy imply a GoUnblock and a GoStart,
they need to synchronize with other past and future GoStart events to
create a correct partial ordering in the trace. Therefore, these events
need a sequence number for the goroutine that will be unblocked and
started.

Also, while implementing this, I noticed that the coroutine
implementation is actually buggy with respect to LockOSThread. In fact,
it blatantly disregards its invariants without an explicit panic. While
such a case is likely to be rare (and inefficient!) we should decide how
iter.Pull behaves with respect to runtime.LockOSThread.

Lastly, this change also bumps the trace version from Go 1.22 to Go
1.23. We're adding events that are incompatible with a Go 1.22 parser,
but Go 1.22 traces are all valid Go 1.23 traces, so the newer parser
supports both (and the CL otherwise updates the Go 1.22 definitions of
events and such). We may want to reconsider the structure and naming of
some of these packages though; it could quickly get confusing.

For #61897.

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

13 months agoRevert "testing: add TB.SetGOMAXPROCS function"
Ian Lance Taylor [Thu, 21 Mar 2024 21:42:52 +0000 (21:42 +0000)]
Revert "testing: add TB.SetGOMAXPROCS function"

This reverts CL 519235.

Reason for revert: Proposal is still in incoming.

For #62020

Change-Id: Icccb930209f36097f5d930c01eda6b5042bdddc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/573516
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agodatabase/sql: fix typo in comment
guoguangwu [Fri, 22 Mar 2024 01:26:02 +0000 (01:26 +0000)]
database/sql: fix typo in comment

Change-Id: Ie8ac82b6a1685299a92ec59acbd80b6de38e377c
GitHub-Last-Rev: 325df8d1488b02bfa239d66cdf870e3d37169d76
GitHub-Pull-Request: golang/go#66457
Reviewed-on: https://go-review.googlesource.com/c/go/+/573615
Reviewed-by: Ian Lance Taylor <iant@google.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 agocmd/internal/obj/riscv: improve register MOVB/MOVH/MOVBU/MOVHU for rva22u64
Joel Sing [Sat, 9 Dec 2023 08:18:00 +0000 (19:18 +1100)]
cmd/internal/obj/riscv: improve register MOVB/MOVH/MOVBU/MOVHU for rva22u64

When GORISCV64 enables rva22u64, use SEXTB for MOVB, SEXTH for MOVH, ZEXTH
for MOVHU and ADDUW for MOVWU. These are single instruction alternatives
to the two instruction shift sequences that are needed otherwise.

Change-Id: Iea5e394f57e238ae8771400a87287c1ee507d44c
Reviewed-on: https://go-review.googlesource.com/c/go/+/572736
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
13 months agosyscall: export Tc{get,set}pgrp for testing
Joel Sing [Sat, 16 Mar 2024 14:02:16 +0000 (01:02 +1100)]
syscall: export Tc{get,set}pgrp for testing

Provide appropriate implementations of Tc{get,set}pgrp and export
these for use in the TestForeground* tests in exec_unix_test.go.
This avoids calling ioctl via syscall.Syscall on BSDs.

Fixes #59667
Updates #63900

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

13 months agonet/http: use slices to simplify the code
apocelipes [Thu, 21 Mar 2024 20:39:28 +0000 (20:39 +0000)]
net/http: use slices to simplify the code

"strSliceContains" is replaced by "slices.Contains".

Replace "sort.Strings" with "slices.Sort" since it becomes a wrapper
of "slices.Sort" from Go 1.22.

"headerSorter" no longer has to implement "sort.Interface".
We use "slice.SortFunc" to sort kvs.

Change-Id: Ic29b4c3db147c16079575eca7ad6ff6c0f581188
GitHub-Last-Rev: 78221d5aa223a259a89860b672f39a34897df253
GitHub-Pull-Request: golang/go#66440
Reviewed-on: https://go-review.googlesource.com/c/go/+/573275
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

13 months agocmd/go: close debug trace file
guoguangwu [Thu, 21 Mar 2024 04:03:26 +0000 (04:03 +0000)]
cmd/go: close debug trace file

Change-Id: Ia83312e6b0448573d40fe9a58ab42cd0d8f8f44a
GitHub-Last-Rev: 30f462817b3500c02445efa1033a1191c5ad5626
GitHub-Pull-Request: golang/go#66436
Reviewed-on: https://go-review.googlesource.com/c/go/+/573215
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
13 months agoruntime/cgo: fix clang mach_port_t cast warning
Roland Shoemaker [Thu, 21 Mar 2024 15:50:04 +0000 (08:50 -0700)]
runtime/cgo: fix clang mach_port_t cast warning

Converting *void directly to mach_port_t causes newer clang to throw a
void-pointer-to-int-cast warning/error.

Change-Id: I709955d4678bed3f690a8337ce85fd8678d217bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/573415
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

13 months agounsafe: add available godoc link
cui fliter [Sun, 5 Nov 2023 10:48:27 +0000 (18:48 +0800)]
unsafe: add available godoc link

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

13 months agohtml/template: add available godoc link
cui fliter [Fri, 13 Oct 2023 17:02:53 +0000 (01:02 +0800)]
html/template: add available godoc link

Change-Id: I2871e98eaf13f207e467120592d604761be5fe17
Reviewed-on: https://go-review.googlesource.com/c/go/+/535084
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@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 agotesting: add TB.SetGOMAXPROCS function
sivchari [Mon, 26 Feb 2024 06:08:13 +0000 (15:08 +0900)]
testing: add TB.SetGOMAXPROCS function

Add a new method TB.SetGOMAXPROCS which sets variable of GOMAXPROCS.
This method aims to set a variable for the isolated lifetime of the test and cleans up.
And unset this when the test ends.
This method disables the test or benchmark from running in
parallel.

Fixes: #62020
Change-Id: Iae44109d0def35cc47049c3ca4cd5306173d52ee
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/519235
Reviewed-by: Bryan Mills <bcmills@google.com>
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 agocmd/compile,cmd/go,cmd/internal,runtime: remove dynamic checks for atomics for ARM64...
Andrey Bokhanko [Wed, 6 Mar 2024 14:44:03 +0000 (17:44 +0300)]
cmd/compile,cmd/go,cmd/internal,runtime: remove dynamic checks for atomics for ARM64 targets that support LSE

Remove dynamic checks for atomic instructions for ARM64 targets that support LSE extension.

For #66131

Change-Id: I0ec1b183a3f4ea4c8a537430646e6bc4b4f64271
Reviewed-on: https://go-review.googlesource.com/c/go/+/569536
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Shu-Chun Weng <scw@google.com>
13 months agoruntime: make tidExists more robust
Michael Anthony Knyszek [Wed, 28 Feb 2024 23:25:52 +0000 (23:25 +0000)]
runtime: make tidExists more robust

The LockThreadExit tests in the runtime have been observed to fail after
reading /proc/self/task/<tid>/stat and blindly assuming its contents
followed a specific format. The parsing code is also wrong, because
splitting by spaces doesn't work when the comm name contains a space.
It also ignores errors without reporting them, which isn't great.

This change rewrites tidExists to be more robust by using
/proc/self/task/<tid>/status instead. It also modifies tidExists'
signature to report an error to its caller. Its caller then prints that
error.

Ignoring a non-not-exist error with opening this file is the likely but
unconfirmed cause of #65736 (ESRCH). This change also checks for that
error explicitly as an optimistic fix.

Fixes #65736.

Change-Id: Iea560b457d514426da2781b7eb7b8616a91ec23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/567938
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
13 months agocmd/compile: include constant bools in memcombine
Keith Randall [Thu, 21 Mar 2024 16:15:30 +0000 (09:15 -0700)]
cmd/compile: include constant bools in memcombine

Constant bools are like constant 1-byte values, they memcombine just fine.

(There are still trickier cases that this pass doesn't catch
yet, see TODO at memcombine.go:503.)

Fixes #66413

Change-Id: Ia67cf72ed1c416e27ac22da443bd88a3f09a6cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/573416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
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>