]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 months agogo/types, types2: set up recording of positions for declarations
Mark Freeman [Thu, 10 Apr 2025 15:27:29 +0000 (11:27 -0400)]
go/types, types2: set up recording of positions for declarations

This creates the infrastructure needed to record compiler panics
induced somewhere beneath a declaration. For now, this is turned
off via a flag.

This does not yet use the position information for better error
messages. That is moved off to a separate CL.

Change-Id: I6b44135a84ebd2f4c0141408ba9228d72c497d55
Reviewed-on: https://go-review.googlesource.com/c/go/+/664475
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agolog/slog: export Source method in Record for custom handler support
Ernesto Alejandro Santana Hidalgo [Sun, 4 May 2025 04:30:25 +0000 (04:30 +0000)]
log/slog: export Source method in Record for custom handler support

Currently, the `source` method in `slog.Record` is not accessible to
custom handlers, requiring developers to re-implement logic for
retrieving source location information. This commit exports the `source`
method as `Source`, enabling consistent access for custom logging
handlers and reducing code redundancy.

Fixes #70280

Change-Id: I3eb3bc60658abc5de95697a10bddd11ab54c6e13
GitHub-Last-Rev: bd81afe5a502bf0e2d03c30d0f5199a532cc4c62
GitHub-Pull-Request: golang/go#70281
Reviewed-on: https://go-review.googlesource.com/c/go/+/626976
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agobytes, strings: reduce Split{,After}Seq heap allocations
tdakkota [Sat, 3 May 2025 16:45:02 +0000 (19:45 +0300)]
bytes, strings: reduce Split{,After}Seq heap allocations

This CL slightly changes flow of splitSeq to help compiler to inline the iterator closure.

goos: linux
goarch: amd64
pkg: strings
cpu: AMD Ryzen 9 5950X 16-Core Processor
                                    │   sec/op    │   sec/op     vs base                │
SplitSeqEmptySeparator-32             3.590m ± 0%   3.430m ± 2%   -4.46% (p=0.000 n=30)
SplitSeqSingleByteSeparator-32        647.0µ ± 0%   656.1µ ± 0%   +1.41% (p=0.000 n=30)
SplitSeqMultiByteSeparator-32         423.9µ ± 1%   384.5µ ± 0%   -9.31% (p=0.000 n=30)
SplitAfterSeqEmptySeparator-32        3.372m ± 4%   3.514m ± 0%   +4.20% (p=0.000 n=30)
SplitAfterSeqSingleByteSeparator-32   648.5µ ± 2%   537.6µ ± 0%  -17.10% (p=0.000 n=30)
SplitAfterSeqMultiByteSeparator-32    423.3µ ± 2%   364.4µ ± 2%  -13.91% (p=0.000 n=30)
geomean                               984.7µ        917.3µ        -6.85%

                                    │    B/op    │   B/op     vs base                     │
SplitSeqEmptySeparator-32             24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
SplitSeqSingleByteSeparator-32        24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
SplitSeqMultiByteSeparator-32         24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
SplitAfterSeqEmptySeparator-32        24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
SplitAfterSeqSingleByteSeparator-32   24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
SplitAfterSeqMultiByteSeparator-32    24.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=30)
geomean                               24.00                   ?

For #73524

Change-Id: Ic83c5751a41c65030356a208e4ad1f500723e695
Reviewed-on: https://go-review.googlesource.com/c/go/+/669735
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Commit-Queue: Alan Donovan <adonovan@google.com>

3 months agopkgbits: improve documentation in reloc.go
Mark Freeman [Mon, 28 Apr 2025 16:55:44 +0000 (12:55 -0400)]
pkgbits: improve documentation in reloc.go

Change-Id: I71cc0db153c559d4c5b48d1d744daf16deffe6d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/668536
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoRevert "cmd/compile: allow all of the preamble to be preemptible"
Keith Randall [Mon, 5 May 2025 17:51:52 +0000 (10:51 -0700)]
Revert "cmd/compile: allow all of the preamble to be preemptible"

This reverts commits

3f3782feed6e0726ddb08afd32dad7d94fbb38c6 (CL 648518)
b386b628521780c048af14a148f373c84e687b26 (CL 668475)

Fixes #73542

Change-Id: I218851c5c0b62700281feb0b3f82b6b9b97b910d
Reviewed-on: https://go-review.googlesource.com/c/go/+/670055
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: on amd64, use flag result of x instead of doing (TEST x x)
khr@golang.org [Sun, 4 May 2025 17:34:41 +0000 (10:34 -0700)]
cmd/compile: on amd64, use flag result of x instead of doing (TEST x x)

So we can avoid using a TEST where it isn't needed.

Currently only implemented for ADD{Q,L}const.

Change-Id: Ia9c4c69bb6033051a45cfd3d191376c7cec9d423
Reviewed-on: https://go-review.googlesource.com/c/go/+/669875
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>

3 months agogo/parser: use non-adjusted position while parsing CommentGroups
Mateusz Poliwczak [Thu, 1 May 2025 12:20:45 +0000 (12:20 +0000)]
go/parser: use non-adjusted position while parsing CommentGroups

Line directives should not affect the way Comments get grouped
into CommentGroups.

Change-Id: I9aa4b558cb1333b32be692e8720291d0e6961cae
GitHub-Last-Rev: de867b27bff28983716ba9126329d75f456a2b5a
GitHub-Pull-Request: golang/go#69133
Reviewed-on: https://go-review.googlesource.com/c/go/+/609515
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agonet,os: support converting between *os.File and net.Conn on Windows
qmuntal [Fri, 25 Apr 2025 12:11:31 +0000 (14:11 +0200)]
net,os: support converting between *os.File and net.Conn on Windows

The runtime poller and os.NewFile recently gained support for
disassociating the handle from the runtime poller IOCP (see CL 664455).
This was the main blocker for allowing the conversion between *os.File
and net.Conn.

Implementing the conversion is now trivial. The only remaining work,
implemented in this CL, is improving os.NewFile to also support
socket handles and updating some build tags so that Windows can share
almost the same net's File implementation as Unix.

There is one important limitation, though: the duplicated socket handle
returned by the various File methods in the net package is not
usable on other process. If someone needs to pass a socket handle to
another process, they should manually call the WSADuplicateSocket
Windows API passing the process ID of the target process.

Fixes #9503.
Fixes #10350.
Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Ic43cadaac2662b925d57a9d362ddc7ae21d1b56e
Reviewed-on: https://go-review.googlesource.com/c/go/+/668195
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agogo/types: fix typo in Info.Types doc comment
Russ Cox [Sat, 3 May 2025 21:06:41 +0000 (17:06 -0400)]
go/types: fix typo in Info.Types doc comment

Change-Id: Ib95b77ab3dc6e48158e25e70fabb2579f3706b5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/669755
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
3 months agoruntime: clear frame pointer in morestack
Michael Pratt [Fri, 2 May 2025 18:58:42 +0000 (14:58 -0400)]
runtime: clear frame pointer in morestack

Corollary to CL 669615.

morestack uses the frame pointer from g0.sched.bp. This doesn't really
make any sense. morestack wasn't called by whatever used g0 last, so at
best unwinding will get misleading results.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest
Change-Id: I6a6a636c3a2994eb88f890c506c96fd899e993a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/669616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agoruntime: don't restore from g0.sched in systemstack on arm64
Michael Pratt [Wed, 30 Apr 2025 19:14:50 +0000 (15:14 -0400)]
runtime: don't restore from g0.sched in systemstack on arm64

On arm64, systemstack restores the frame pointer from g0.sched to R29
prior to calling the callback. That doesn't really make any sense. The
frame pointer value in g0.sched is some arbitrary BP from a prior
context save, but that is not the caller of systemstack.

amd64 does not do this. In fact, it leaves BP completely unmodified so
frame pointer unwinders like gdb can walk through the systemstack frame
and continue traceback on the caller's stack. Unlike mcall, systemstack
always returns to the original goroutine, so that is safe.

We should do the same on arm64.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest
Change-Id: I6a6a636c35d321dd5d7dc1c4d09e29b55b1ab621
Reviewed-on: https://go-review.googlesource.com/c/go/+/669236
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoruntime: clear frame pointer in mcall
Michael Pratt [Fri, 2 May 2025 18:18:03 +0000 (14:18 -0400)]
runtime: clear frame pointer in mcall

On amd64, mcall leaves BP untouched, so the callback will push BP,
connecting the g0 stack to the calling g stack. This seems OK (frame
pointer unwinders like Linux perf can see what user code called into the
scheduler), but the "scheduler" part is problematic.

mcall is used when calling into the scheduler to deschedule the current
goroutine (e.g., in goyield). Once the goroutine is descheduled, it may
be picked up by another M and continue execution. The other thread is
mutating the goroutine stack, but our M still has a frame pointer
pointing to the goroutine stack.

A frame pointer unwinder like Linux perf could get bogus values off of
the mutating stack. Note that though the execution tracer uses
framepointer unwinding, it never unwinds a g0, so it isn't affected.

Clear the frame pointer in mcall so that unwinding always stops at
mcall.

On arm64, mcall stores the frame pointer from g0.sched.bp. This doesn't
really make any sense. mcall wasn't called by whatever used g0 last, so
at best unwinding will get misleading results (e.g., it might look like
cgocallback calls mcall?).

Also clear the frame pointer on arm64.

Other architectures don't use frame pointers.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest
Change-Id: I6a6a636cb6404f3c95ecabdb969c9b8184615cee
Reviewed-on: https://go-review.googlesource.com/c/go/+/669615
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 months agocmd/go/internal/vcs: include Subversion VCS build information
Stefan Schlosser [Tue, 22 Apr 2025 15:49:26 +0000 (15:49 +0000)]
cmd/go/internal/vcs: include Subversion VCS build information

The existing implementation lacks the Status function for retrieving VCS build
information for Subversion. As a consequence, binaries aren't stamped with the
Revision, CommitTime and Uncommitted information from SVN repositories.

This change provides the svnStatus function and retrieves the information by
running svn info and svn status commands.

Fixes #73444

Change-Id: Ie6d95ffbb3a3c580cc42128ad1f8d82a869c91f2
GitHub-Last-Rev: 3472222865638a13b122c8995561166cfe228fa8
GitHub-Pull-Request: golang/go#73446
Reviewed-on: https://go-review.googlesource.com/c/go/+/666875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
3 months agoruntime: mark and scan small objects in whole spans [green tea]
Michael Anthony Knyszek [Wed, 12 Mar 2025 18:52:58 +0000 (18:52 +0000)]
runtime: mark and scan small objects in whole spans [green tea]

Our current parallel mark algorithm suffers from frequent stalls on
memory since its access pattern is essentially random. Small objects
are the worst offenders, since each one forces pulling in at least one
full cache line to access even when the amount to be scanned is far
smaller than that. Each object also requires an independent access to
per-object metadata.

The purpose of this change is to improve garbage collector performance
by scanning small objects in batches to obtain better cache locality
than our current approach. The core idea behind this change is to defer
marking and scanning small objects, and then scan them in batches
localized to a span.

This change adds scanned bits to each small object (<=512 bytes) span in
addition to mark bits. The scanned bits indicate that the object has
been scanned. (One way to think of them is "grey" bits and "black" bits
in the tri-color mark-sweep abstraction.) Each of these spans is always
8 KiB and if they contain pointers, the pointer/scalar data is already
packed together at the end of the span, allowing us to further optimize
the mark algorithm for this specific case.

When the GC encounters a pointer, it first checks if it points into a
small object span. If so, it is first marked in the mark bits, and then
the object is queued on a work-stealing P-local queue. This object
represents the whole span, and we ensure that a span can only appear at
most once in any queue by maintaining an atomic ownership bit for each
span. Later, when the pointer is dequeued, we scan every object with a
set mark that doesn't have a corresponding scanned bit. If it turns out
that was the only object in the mark bits since the last time we scanned
the span, we scan just that object directly, essentially falling back to
the existing algorithm. noscan objects have no scan work, so they are
never queued.

Each span's mark and scanned bits are co-located together at the end of
the span. Since the span is always 8 KiB in size, it can be found with
simple pointer arithmetic. Next to the marks and scans we also store the
size class, eliminating the need to access the span's mspan altogether.

The work-stealing P-local queue is a new source of GC work. If this
queue gets full, half of it is dumped to a global linked list of spans
to scan. The regular scan queues are always prioritized over this queue
to allow time for darts to accumulate. Stealing work from other Ps is a
last resort.

This change also adds a new debug mode under GODEBUG=gctrace=2 that
dumps whole-span scanning statistics by size class on every GC cycle.

A future extension to this CL is to use SIMD-accelerated scanning
kernels for scanning spans with high mark bit density.

For #19112. (Deadlock averted in GOEXPERIMENT.)
For #73581.

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

3 months agocmd/api: skip 3 non-TestCheck tests in -check mode
Dmitri Shuralyov [Tue, 29 Apr 2025 03:28:20 +0000 (23:28 -0400)]
cmd/api: skip 3 non-TestCheck tests in -check mode

TestIssue64958 takes a while, so it's not worth running both without
and with -check flag. The others are fast, but there's still no good
reason to run anything but TestCheck when the -check flag is on.

Change-Id: I13ebb90e3c863006f21441909b05364e1b316ed6
Reviewed-on: https://go-review.googlesource.com/c/go/+/668656
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

3 months agocmd/internal/obj/riscv: add support for vector permutation instructions
Joel Sing [Wed, 12 Feb 2025 12:40:58 +0000 (23:40 +1100)]
cmd/internal/obj/riscv: add support for vector permutation instructions

Add support for vector permutation instructions to the RISC-V assembler.
This includes integer scalar move, floating point scalar move, slide up
and slide down, register gather, compression and whole vector register
move instructions.

Change-Id: I1da9f393091504fd81714006355725b8b9ecadea
Reviewed-on: https://go-review.googlesource.com/c/go/+/646780
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
3 months agocmd/internal/obj/riscv: add support for vector mask instructions
Joel Sing [Sun, 2 Feb 2025 12:09:12 +0000 (23:09 +1100)]
cmd/internal/obj/riscv: add support for vector mask instructions

Add support for vector mask instructions to the RISC-V assembler.
These allow manipulation of vector masks and include mask register
logical instructions, population count and find-first bit set
instructions.

Change-Id: I3ab3aa0f918338aee9b37ac5a2b2fdc407875072
Reviewed-on: https://go-review.googlesource.com/c/go/+/646779
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agocmd/internal/obj/riscv: add support for vector reduction instructions
Joel Sing [Sun, 2 Feb 2025 11:26:07 +0000 (22:26 +1100)]
cmd/internal/obj/riscv: add support for vector reduction instructions

Add support for vector reduction instructions to the RISC-V assembler,
including single-width integer reduction, widening integer reduction,
single-width floating-point reduction and widening floating-point
reduction.

Change-Id: I8f17bef11389f3a017e0430275023fc5d75936e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/646778
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 months agoos: fix Root.Mkdir permission bits on OpenBSD
Josh Rickmar [Thu, 1 May 2025 15:09:40 +0000 (15:09 +0000)]
os: fix Root.Mkdir permission bits on OpenBSD

Pass missing mode bits in the mkdirat() syscall wrapper.

Fixes #73559

Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854
GitHub-Last-Rev: 669c17361d86bc9065bb6b47a2d60aa86bcfa12d
GitHub-Pull-Request: golang/go#73565
Reviewed-on: https://go-review.googlesource.com/c/go/+/669375
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 months agosync: WaitGroup.Go: document that f must not panic
Alan Donovan [Thu, 24 Apr 2025 02:58:05 +0000 (22:58 -0400)]
sync: WaitGroup.Go: document that f must not panic

Fixes #63796

Change-Id: Ib11d32574011e13aab3a0ad504f0d10009627503
Reviewed-on: https://go-review.googlesource.com/c/go/+/667695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

3 months agocmd/compile: improve multiplication strength reduction
Keith Randall [Mon, 11 Nov 2024 20:21:14 +0000 (12:21 -0800)]
cmd/compile: improve multiplication strength reduction

Use an automatic algorithm to generate strength reduction code.
You give it all the linear combination (a*x+b*y) instructions in your
architecture, it figures out the rest.

Just amd64 and arm64 for now.

Fixes #67575

Change-Id: I35c69382bebb1d2abf4bb4e7c43fd8548c6c59a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/626998
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile,internal/cpu,runtime: intrinsify math/bits.OnesCount on riscv64
Joel Sing [Wed, 19 Mar 2025 12:57:23 +0000 (23:57 +1100)]
cmd/compile,internal/cpu,runtime: intrinsify math/bits.OnesCount on riscv64

For riscv64/rva22u64 and above, we can intrinsify math/bits.OnesCount
using the CPOP/CPOPW machine instructions. Since the native Go
implementation of OnesCount is relatively expensive, it is also
worth emitting a check for Zbb support when compiled for rva20u64.

On a Banana Pi F3, with GORISCV64=rva22u64:

              │     oc.1     │                oc.2                 │
              │    sec/op    │   sec/op     vs base                │
OnesCount-8     16.930n ± 0%   4.389n ± 0%  -74.08% (p=0.000 n=10)
OnesCount8-8     5.642n ± 0%   5.016n ± 0%  -11.10% (p=0.000 n=10)
OnesCount16-8    9.404n ± 0%   5.015n ± 0%  -46.67% (p=0.000 n=10)
OnesCount32-8   13.165n ± 0%   4.388n ± 0%  -66.67% (p=0.000 n=10)
OnesCount64-8   16.300n ± 0%   4.388n ± 0%  -73.08% (p=0.000 n=10)
geomean          11.40n        4.629n       -59.40%

On a Banana Pi F3, compiled with GORISCV64=rva20u64 and with Zbb
detection enabled:

              │     oc.3     │                oc.4                 │
              │    sec/op    │   sec/op     vs base                │
OnesCount-8     16.930n ± 0%   5.643n ± 0%  -66.67% (p=0.000 n=10)
OnesCount8-8     5.642n ± 0%   5.642n ± 0%        ~ (p=0.447 n=10)
OnesCount16-8   10.030n ± 0%   6.896n ± 0%  -31.25% (p=0.000 n=10)
OnesCount32-8   13.170n ± 0%   5.642n ± 0%  -57.16% (p=0.000 n=10)
OnesCount64-8   16.300n ± 0%   5.642n ± 0%  -65.39% (p=0.000 n=10)
geomean          11.55n        5.873n       -49.16%

On a Banana Pi F3, compiled with GORISCV64=rva20u64 but with Zbb
detection disabled:

              │    oc.3     │                oc.5                 │
              │   sec/op    │   sec/op     vs base                │
OnesCount-8     16.93n ± 0%   29.47n ± 0%  +74.07% (p=0.000 n=10)
OnesCount8-8    5.642n ± 0%   5.643n ± 0%        ~ (p=0.191 n=10)
OnesCount16-8   10.03n ± 0%   15.05n ± 0%  +50.05% (p=0.000 n=10)
OnesCount32-8   13.17n ± 0%   18.18n ± 0%  +38.04% (p=0.000 n=10)
OnesCount64-8   16.30n ± 0%   21.94n ± 0%  +34.60% (p=0.000 n=10)
geomean         11.55n        15.84n       +37.16%

For hardware without Zbb, this adds ~5ns overhead, while for hardware
with Zbb we achieve a performance gain up of up to 11ns. It is worth
noting that OnesCount8 is cheap enough that it is preferable to stick
with the generic version in this case.

Change-Id: Id657e40e0dd1b1ab8cc0fe0f8a68df4c9f2d7da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/660856
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: intrinsify math/bits.Bswap on riscv64
Joel Sing [Wed, 19 Mar 2025 14:09:23 +0000 (01:09 +1100)]
cmd/compile: intrinsify math/bits.Bswap on riscv64

For riscv64/rva22u64 and above, we can intrinsify math/bits.Bswap
using the REV8 machine instruction.

On a StarFive VisionFive 2 with GORISCV64=rva22u64:

                 │     rb.1     │                rb.2                 │
                 │    sec/op    │   sec/op     vs base                │
ReverseBytes-4     18.790n ± 0%   4.026n ± 0%  -78.57% (p=0.000 n=10)
ReverseBytes16-4    6.710n ± 0%   5.368n ± 0%  -20.00% (p=0.000 n=10)
ReverseBytes32-4   13.420n ± 0%   5.368n ± 0%  -60.00% (p=0.000 n=10)
ReverseBytes64-4   17.450n ± 0%   4.026n ± 0%  -76.93% (p=0.000 n=10)
geomean             13.11n        4.649n       -64.54%

Change-Id: I26eee34270b1721f7304bb1cddb0fda129b20ece
Reviewed-on: https://go-review.googlesource.com/c/go/+/660855
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agointernal/bytealg: deduplicate code between Count/CountString for riscv64
Joel Sing [Thu, 27 Feb 2025 12:04:15 +0000 (23:04 +1100)]
internal/bytealg: deduplicate code between Count/CountString for riscv64

Change-Id: I22eb4e7444e5fe5f6767cc960895f3c6e2fa13cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/661615
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agocmd/internal/obj/riscv: add support for vector floating-point instructions
Joel Sing [Wed, 12 Feb 2025 12:40:28 +0000 (23:40 +1100)]
cmd/internal/obj/riscv: add support for vector floating-point instructions

Add support for vector floating-point instructions to the RISC-V
assembler. This includes single-width and widening addition and
subtraction, multiplication and division, fused multiply-addition,
comparison, min/max, sign-injection, classification and type
conversion instructions.

Change-Id: I8bceb1c5d7eead0561ba5407ace00805a6144f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/646777
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
3 months agomath/big: fix incorrect register allocation for mipsx/mips64x
Julian Zhu [Fri, 25 Apr 2025 12:59:13 +0000 (20:59 +0800)]
math/big: fix incorrect register allocation for mipsx/mips64x

According to the MIPS ABI, R26/R27 are reserved for OS kernel, and may be clobbered by it. They must not be used by user mode.

See Figure 3-18 of MIPS ELF ABI specification: https://refspecs.linuxfoundation.org/elf/mipsabi.pdf

Fixes #73472

Change-Id: Ifda692a803176bfaab2c70d6623636c5d135f42e
Reviewed-on: https://go-review.googlesource.com/c/go/+/667816
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/dist: move "devel" substring in git-inferred development version
Dmitri Shuralyov [Fri, 25 Apr 2025 00:48:10 +0000 (20:48 -0400)]
cmd/dist: move "devel" substring in git-inferred development version

Keep the property that the "devel" substring is always present in these
development versions of Go, but also gain the property that it's viable
to use functions in the go/version package such as Lang, Compare, and
get the expected results without needing to trim the "devel " prefix.

For #73369.
For #41116.
Fixes #73372.

Change-Id: Ieea4692e8c6cf0135e010f49f85300f6b038d6b1
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/668015
Reviewed-by: Funda Secgin <fundasecgin30@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocmd/link: fix cgo on riscv64 when building with gcc-15
Mark Ryan [Fri, 25 Apr 2025 15:23:49 +0000 (17:23 +0200)]
cmd/link: fix cgo on riscv64 when building with gcc-15

It's not currently possible to build cgo programs that are partially
compiled with gcc-15 on riscv64 using the internal linker. There are
two reasons for this.

1. When gcc-15 compiles _cgo_export.c, which contains no actual code,
   for a riscv64 target, it emits a label in the .text section called
   .Letext0. This label is referred to by another section, .debug_line,
   and an entry is generated in the symbol table for it. The Go linker
   panics when processing the .Letext0 symbol in _cgo_export.o, as it
   occurs in an empty section.
2. GCC-15 is generating additional debug symbols with the .LVUS
   prefix, e.g., .LVUS33, that need to be ignored.

We fix the issue by removing the check in
cmd/link/internal/loader/loader.go that panics if we encounter a
symbol in an empty section (the comments preceding this check suggest
it's safe to remove it) and by adding .LVUS to the list of symbol
prefixes to ignore.

Fixes #72840

Change-Id: I00658b6bdd01606dde1581b5bc2f42edfc37de82
Reviewed-on: https://go-review.googlesource.com/c/go/+/668276
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
3 months agocmd/go, cmd/internal/objabi: detect "devel" version by substring
Dmitri Shuralyov [Fri, 25 Apr 2025 23:43:16 +0000 (19:43 -0400)]
cmd/go, cmd/internal/objabi: detect "devel" version by substring

These were the remaining instances in the main Go repo I found where a
Go version like "devel go1.25-9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700"
is considered to be a development version rather than a release version,
but the version "go1.25-devel_9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700"
is not.

Update this in preparation of the move of "devel" from front to middle.

For #73372.
For #73369.

Change-Id: If5442ecb0751c08b3a1b4d1148193e501700b956
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/668355
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 months agoos: test overlapped pipes deadlines on Windows
qmuntal [Fri, 25 Apr 2025 08:12:28 +0000 (10:12 +0200)]
os: test overlapped pipes deadlines on Windows

NewFile recently added support for overlapped I/O on Windows,
which allows us to set deadlines on them, but the test coverage for
this new feature is not exhaustive.

Modify the existing pipe deadline tests to also exercise named
overlapped pipes.

Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: I86d284d9fb054c24959045a922cf84feeda5b5f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/668095
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agosyscall: cache Errno.Error() on Windows
Jake Bailey [Mon, 24 Mar 2025 23:01:06 +0000 (16:01 -0700)]
syscall: cache Errno.Error() on Windows

Windows is unlike the other OSs and depends on a syscall for most
errors. This can be costly; cache the returned string for later reuse.

This helps test caching, since errors are written out as string to the
test ID, which are often PathErrors wrapping Errnos.

For now, only cache ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND.

goos: windows
goarch: amd64
pkg: syscall
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
               │    old.txt    │               new.txt               │
               │    sec/op     │   sec/op     vs base                │
ErrnoString-20   1788.00n ± 1%   11.08n ± 1%  -99.38% (p=0.000 n=10)

               │  old.txt   │              new.txt               │
               │    B/op    │   B/op     vs base                 │
ErrnoString-20   48.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=10)

               │  old.txt   │               new.txt               │
               │ allocs/op  │ allocs/op   vs base                 │
ErrnoString-20   1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)

For #72992

Change-Id: I9a0910fa6538772ffc64ef7670b44059a2c7d18c
Reviewed-on: https://go-review.googlesource.com/c/go/+/667495
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>

3 months agonet: support IPv6 addresses in ListenMulticastUDP on Windows
qmuntal [Fri, 25 Apr 2025 13:30:53 +0000 (15:30 +0200)]
net: support IPv6 addresses in ListenMulticastUDP on Windows

Fixes #63529.

Change-Id: Id9246af1a72beef3149af571f0891437bba2f4e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/668216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
3 months agotesting: use more doc links
Sean Liao [Tue, 29 Apr 2025 15:54:06 +0000 (16:54 +0100)]
testing: use more doc links

Change-Id: Ide372735165b7510fd8d7588451a37fa743e59c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/668915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agocmd/compile: relax tighten register-pressure heuristic slightly
Jakub Ciolek [Sat, 19 Apr 2025 11:27:31 +0000 (13:27 +0200)]
cmd/compile: relax tighten register-pressure heuristic slightly

Sometimes a value has multiple args, but they are the same
dependency. Relax the regalloc heuristic for those.

No measurable compile-time regression according to compilebench,
maybe even a small improvement.

name    old time/op  new time/op  delta
StdCmd   14.4s ± 1%   14.4s ± 1%  -0.39%  (p=0.101 n=11+11)

compilecmp:

linux/amd64:

strconv
strconv.formatBits 1199 -> 1189  (-0.83%)
strconv.formatDecimal 637 -> 631  (-0.94%)

strconv [cmd/compile]
strconv.formatBits 1199 -> 1189  (-0.83%)
strconv.formatDecimal 637 -> 631  (-0.94%)

image
image.NewGray16 286 -> 275  (-3.85%)
image.NewAlpha16 286 -> 275  (-3.85%)

regexp/syntax
regexp/syntax.ranges.Less 150 -> 147  (-2.00%)
regexp/syntax.(*compiler).rune 774 -> 773  (-0.13%)
regexp/syntax.(*ranges).Swap 197 -> 180  (-8.63%)
regexp/syntax.ranges.Swap 146 -> 134  (-8.22%)
regexp/syntax.(*compiler).cap 440 -> 425  (-3.41%)
regexp/syntax.(*compiler).nop 310 -> 297  (-4.19%)
regexp/syntax.(*compiler).compile 5815 -> 5733  (-1.41%)
regexp/syntax.(*ranges).Less 211 -> 197  (-6.64%)

regexp/syntax [cmd/compile]
regexp/syntax.(*compiler).compile 5815 -> 5733  (-1.41%)
regexp/syntax.(*compiler).rune 774 -> 773  (-0.13%)
regexp/syntax.(*compiler).cap 440 -> 425  (-3.41%)
regexp/syntax.(*ranges).Less 211 -> 197  (-6.64%)
regexp/syntax.ranges.Swap 146 -> 134  (-8.22%)
regexp/syntax.(*ranges).Swap 197 -> 180  (-8.63%)
regexp/syntax.(*compiler).nop 310 -> 297  (-4.19%)
regexp/syntax.ranges.Less 150 -> 147  (-2.00%)

crypto/elliptic
crypto/elliptic.(*nistCurve[go.shape.*uint8]).pointFromAffine 1272 -> 1240  (-2.52%)

image/gif
image/gif.(*decoder).readColorTable 652 -> 646  (-0.92%)
image/gif.(*encoder).colorTablesMatch 350 -> 349  (-0.29%)

crypto/internal/cryptotest
crypto/internal/cryptotest.testCipher.func3 1289 -> 1286  (-0.23%)

internal/trace/internal/tracev1
internal/trace/internal/tracev1.(*parser).collectBatchesAndCPUSamples 1352 -> 1338  (-1.04%)

internal/fuzz
internal/fuzz.byteSliceDuplicateBytes 741 -> 718  (-3.10%)

cmd/compile/internal/types
cmd/compile/internal/types.CalcSize 3663 -> 3633  (-0.82%)

cmd/compile/internal/rttype
cmd/compile/internal/rttype.Init 2149 -> 2124  (-1.16%)

cmd/link/internal/loadmacho
cmd/link/internal/loadmacho.macholoadsym 1213 -> 1212  (-0.08%)

cmd/compile/internal/rangefunc
cmd/compile/internal/rangefunc.(*rewriter).checks 5207 -> 5175  (-0.61%)

net/http
net/http.(*http2SettingsFrame).Setting 155 -> 147  (-5.16%)

cmd/compile/internal/rttype [cmd/compile]
cmd/compile/internal/rttype.Init 2149 -> 2124  (-1.16%)

cmd/compile/internal/rangefunc [cmd/compile]
cmd/compile/internal/rangefunc.(*rewriter).checks 5207 -> 5175  (-0.61%)

cmd/link/internal/ld
cmd/link/internal/ld.pefips 3119 -> 3109  (-0.32%)

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.parseDash 593 -> 587  (-1.01%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.(*poset).setOrder 3442 -> 3416  (-0.76%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul16 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul8 2054 -> 2022  (-1.56%)
inserted cmd/compile/internal/ssa.tighten.deferwrap5

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul8 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul16 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.tighten.deferwrap4 76 -> 67  (-11.84%)
cmd/compile/internal/ssa.tighten 6746 -> 5082  (-24.67%)
inserted cmd/compile/internal/ssa.tighten.deferwrap5

file                                             before   after    Δ       %
strconv.s                                        49029    49020    -9      -0.018%
strconv [cmd/compile].s                          49029    49020    -9      -0.018%
image.s                                          34963    34941    -22     -0.063%
regexp/syntax.s                                  83017    82860    -157    -0.189%
regexp/syntax [cmd/compile].s                    83017    82860    -157    -0.189%
crypto/elliptic.s                                26848    26816    -32     -0.119%
image/gif.s                                      22840    22833    -7      -0.031%
crypto/internal/cryptotest.s                     63834    63832    -2      -0.003%
internal/trace/internal/tracev1.s                52995    52981    -14     -0.026%
internal/trace.s                                 181396   181412   +16     +0.009%
internal/fuzz.s                                  85526    85503    -23     -0.027%
cmd/internal/obj/s390x.s                         121651   121683   +32     +0.026%
cmd/internal/obj/ppc64.s                         139867   139871   +4      +0.003%
cmd/compile/internal/types.s                     71425    71395    -30     -0.042%
cmd/internal/obj/ppc64 [cmd/compile].s           139952   139956   +4      +0.003%
cmd/internal/obj/s390x [cmd/compile].s           121753   121785   +32     +0.026%
cmd/compile/internal/rttype.s                    10418    10393    -25     -0.240%
cmd/link/internal/loadmacho.s                    23270    23272    +2      +0.009%
cmd/compile/internal/rangefunc.s                 35050    35018    -32     -0.091%
cmd/vendor/github.com/google/pprof/profile.s     148264   148273   +9      +0.006%
net/http.s                                       612895   612910   +15     +0.002%
cmd/compile/internal/rttype [cmd/compile].s      10397    10372    -25     -0.240%
cmd/compile/internal/rangefunc [cmd/compile].s   35681    35649    -32     -0.090%
net/http/cookiejar.s                             28758    28761    +3      +0.010%
cmd/compile/internal/reflectdata.s               86639    86644    +5      +0.006%
cmd/compile/internal/reflectdata [cmd/compile].s 89725    89730    +5      +0.006%
cmd/link/internal/ld.s                           649596   649633   +37     +0.006%
cmd/vendor/rsc.io/markdown.s                     116731   116757   +26     +0.022%
cmd/compile/internal/ssa.s                       3574185  3574642  +457    +0.013%
cmd/compile/internal/ssa [cmd/compile].s         3725364  3723715  -1649   -0.044%
cmd/compile/internal/ssagen.s                    415135   415155   +20     +0.005%
total                                            36475376 36473818 -1558   -0.004%

linux/arm64:

go/printer
go/printer.(*printer).expr1 7152 -> 7168  (+0.22%)

fmt [cmd/compile]
fmt.(*ss).advance 1712 -> 1696  (-0.93%)

crypto/x509
crypto/x509.marshalCertificatePolicies.func1.2.(*Builder).AddASN1ObjectIdentifier.1 changed

internal/fuzz
internal/fuzz.minimizeBytes changed

cmd/internal/obj/arm64
cmd/internal/obj/arm64.bitconEncode changed

math/big [cmd/compile]
math/big.(*Float).Int64 512 -> 528  (+3.12%)
math/big.NewInt changed
math/big.fmtE 720 -> 736  (+2.22%)
math/big.basicSqr changed

cmd/asm/internal/asm
cmd/asm/internal/asm.(*Parser).asmText 1424 -> 1440  (+1.12%)

go/constant [cmd/compile]
go/constant.UnaryOp changed
go/constant.BinaryOp changed

crypto/tls
crypto/tls.prf10 576 -> 560  (-2.78%)

cmd/internal/obj/arm64 [cmd/compile]
cmd/internal/obj/arm64.bitconEncode changed

cmd/vendor/golang.org/x/term
cmd/vendor/golang.org/x/term.(*Terminal).addKeyToLine changed

cmd/compile/internal/ir
cmd/compile/internal/ir.ConstOverflow changed

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

cmd/compile/internal/ir [cmd/compile]
cmd/compile/internal/ir.ConstOverflow changed

cmd/compile/internal/rttype
cmd/compile/internal/rttype.Init changed

cmd/compile/internal/rttype [cmd/compile]
cmd/compile/internal/rttype.Init changed

cmd/compile/internal/abi [cmd/compile]
cmd/compile/internal/abi.(*ABIParamAssignment).RegisterTypesAndOffsets 1344 -> 1328  (-1.19%)

cmd/vendor/golang.org/x/tools/go/types/typeutil
cmd/vendor/golang.org/x/tools/go/types/typeutil.hasher.hash changed

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.(*rustState).expandPunycode changed

net/http/cookiejar
net/http/cookiejar.adapt changed
net/http/cookiejar.encode changed

cmd/compile/internal/reflectdata
cmd/compile/internal/reflectdata.OldMapType changed

cmd/compile/internal/reflectdata [cmd/compile]
cmd/compile/internal/reflectdata.OldMapType changed

cmd/vendor/github.com/google/pprof/internal/report
cmd/vendor/github.com/google/pprof/internal/report.(*Report).newTrimmedGraph 2336 -> 2368  (+1.37%)

cmd/link/internal/ld
cmd/link/internal/ld.(*relocSymState).relocsym changed

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.parseDash changed
cmd/vendor/rsc.io/markdown.parseLinkRefDef changed

cmd/trace
main.(*stackMap).profile 912 -> 880  (-3.51%)

cmd/vendor/golang.org/x/tools/go/analysis/passes/tests
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.checkExampleOutput 832 -> 816  (-1.92%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.shouldElimIfElse changed
cmd/compile/internal/ssa.storeOrder changed
cmd/compile/internal/ssa.elimIfElse changed
cmd/compile/internal/ssa.tighten 3408 -> 3456  (+1.41%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.storeOrder changed
cmd/compile/internal/ssa.elimIfElse changed
cmd/compile/internal/ssa.shouldElimIfElse changed
cmd/compile/internal/ssa.tighten 4960 -> 4976  (+0.32%)
cmd/compile/internal/ssa.branchelim changed

file                                                     before   after    Δ       %
runtime.s                                                624064   624032   -32     -0.005%
runtime [cmd/compile].s                                  679456   679424   -32     -0.005%
strconv.s                                                48528    48560    +32     +0.066%
strconv [cmd/compile].s                                  48528    48560    +32     +0.066%
index/suffixarray.s                                      41808    41856    +48     +0.115%
fmt.s                                                    72272    72256    -16     -0.022%
math/big.s                                               152992   153024   +32     +0.021%
go/printer.s                                             77680    77696    +16     +0.021%
fmt [cmd/compile].s                                      81760    81744    -16     -0.020%
math/big [cmd/compile].s                                 153040   153072   +32     +0.021%
cmd/asm/internal/asm.s                                   57360    57376    +16     +0.028%
crypto/tls.s                                             354304   354288   -16     -0.005%
cmd/compile/internal/abi [cmd/compile].s                 22752    22736    -16     -0.070%
cmd/vendor/github.com/google/pprof/internal/report.s     67008    67040    +32     +0.048%
cmd/trace.s                                              215040   215008   -32     -0.015%
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.s 12544    12528    -16     -0.128%
cmd/compile/internal/ssa.s                               3209248  3209296  +48     +0.001%
cmd/compile/internal/ssa [cmd/compile].s                 3319152  3319168  +16     +0.000%
total                                                    33366288 33366416 +128    +0.000%

Change-Id: I8111792c9dd4f927b49a6d5dd90a3fdc3ec26277
Reviewed-on: https://go-review.googlesource.com/c/go/+/666836
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: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
3 months agodoc: fix grammar and spelling
John Bampton [Tue, 29 Apr 2025 11:46:09 +0000 (11:46 +0000)]
doc: fix grammar and spelling

Minor typo fixes in the docs

Change-Id: I56b5d0318936aecc7775fb5bc70534456707da49
GitHub-Last-Rev: b4d042f8a997aa0d3824d8f9350dd24090b21073
GitHub-Pull-Request: golang/go#73531
Reviewed-on: https://go-review.googlesource.com/c/go/+/668815
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/internal/obj/loong64: fix the error parameters when calling UnspillRegisterArgs
Guoqi Chen [Mon, 28 Apr 2025 11:35:38 +0000 (19:35 +0800)]
cmd/internal/obj/loong64: fix the error parameters when calling UnspillRegisterArgs

This bug was introduced in CL 648518.

Fixes #73518.

Change-Id: I4988dd0b636c6a6a48d2aa2e2ae868e43f69995a
Reviewed-on: https://go-review.googlesource.com/c/go/+/668475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocrypto/internal/hpke: rename Receipient to Recipient
John Bampton [Wed, 9 Apr 2025 21:08:06 +0000 (21:08 +0000)]
crypto/internal/hpke: rename Receipient to Recipient

receipient -> recipient

Change-Id: I9ed5937acf0f3808283e35221f8b4f41408eee7c
GitHub-Last-Rev: 0ed5ff7a46808d5311af3620b6577734a1e557f4
GitHub-Pull-Request: golang/go#73131
Reviewed-on: https://go-review.googlesource.com/c/go/+/662175
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
3 months agocmd/list: fix -retracted flag description
goto1134 [Mon, 29 May 2023 09:23:27 +0000 (09:23 +0000)]
cmd/list: fix -retracted flag description

Change-Id: Ia1ab220485af2f38c3ddcd4c5d5bca1b195a33ed
GitHub-Last-Rev: fb9933427d852518c93efbc4f2c2e4d4ee9b9197
GitHub-Pull-Request: golang/go#59847
Reviewed-on: https://go-review.googlesource.com/c/go/+/489175
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agomime: speed up ParseMediaType
Julien Cretel [Tue, 22 Apr 2025 16:49:42 +0000 (16:49 +0000)]
mime: speed up ParseMediaType

Add benchmarks for ParseMediaType.

Eschew UTF-8 decoding and strings.IndexFunc where possible, and rely
on 128-bit bitmaps instead. Eliminate some bounds checks.

Some benchmark results (no changes to allocations):

goos: darwin
goarch: amd64
pkg: mime
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                      │     old     │                 new                 │
                      │   sec/op    │   sec/op     vs base                │
ParseMediaType-8        71.75µ ± 0%   55.53µ ± 0%  -22.60% (p=0.000 n=20)
ParseMediaTypeBogus-8   5.330µ ± 0%   3.603µ ± 0%  -32.41% (p=0.000 n=20)
geomean                 19.56µ        14.14µ       -27.67%

Change-Id: I324c9990fe43581484916ecff61ca6c708467a89
GitHub-Last-Rev: e2293d64b3852722bef920169eaa44e7ded3111c
GitHub-Pull-Request: golang/go#73436
Reviewed-on: https://go-review.googlesource.com/c/go/+/666655
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>

3 months agosync: tidy WaitGroup documentation, add WaitGroup.Go example
Austin Clements [Fri, 4 Apr 2025 16:18:58 +0000 (12:18 -0400)]
sync: tidy WaitGroup documentation, add WaitGroup.Go example

This reframes the WaitGroup documentation with Go at its center and
Add/Done as more "advanced" features.

Updates #63796

Change-Id: I8101972626fdb00c6f7fb185b685227823d10db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/662975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agoruntime: don't read /dev/random on Plan 9
David du Colombier [Sat, 5 Apr 2025 18:35:12 +0000 (20:35 +0200)]
runtime: don't read /dev/random on Plan 9

In CL 656755, the readRandom function was modified
to read an integer from /dev/random.

However, on Plan 9, /dev/random can only return
a few hundred bits a second.

The issue is that readRandom is called by randinit,
which is called at the creation of Go processes.

Consequently, it lead the Go programs to be very
slow on Plan 9.

This change reverts the change done in CL 656755
to make the readRandom function always returning 0
on Plan 9.

Change-Id: Ibe1bf7e4c8cbc82998e4f5e1331f5e29a047c4fc
Cq-Include-Trybots: luci.golang.try:gotip-plan9-arm

Reviewed-on: https://go-review.googlesource.com/c/go/+/663195
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 months agocmd/dist: add "devel" substring check to isRelease computation
Dmitri Shuralyov [Thu, 24 Apr 2025 21:07:04 +0000 (17:07 -0400)]
cmd/dist: add "devel" substring check to isRelease computation

Non-release versions that are built from source without a VERSION file
specifying any particular version end up with a development version like
"devel go1.25-67e0681aef Thu Apr 24 12:17:27 2025 -0700". Right now
those versions are correctly determined to be non-release because they
don't have a "go" prefix, instead they have a "devel " prefix.

In preparation of being able to move the "devel" substring, add a check
that said substring isn't present anywhere, since it is certain not to
be included in any released Go version we publish at https://go.dev/dl/.

For #73372.

Change-Id: Ia3e0d03b5723d4034d6270c3a2224f8dfae380e9
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/667955
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocmd/compile: allow all of the preamble to be preemptible
Keith Randall [Tue, 11 Feb 2025 23:02:08 +0000 (15:02 -0800)]
cmd/compile: allow all of the preamble to be preemptible

We currently make some parts of the preamble unpreemptible because
it confuses morestack. See comments in the code.

Instead, have morestack handle those weird cases so we can
remove unpreemptible marks from most places.

This CL makes user functions preemptible everywhere if they have no
write barriers (at least, on x86). In cmd/go the fraction of functions
that need preemptible markings drops from 82% to 36%. Makes the cmd/go
binary 0.3% smaller.

Update #35470

Change-Id: Ic83d5eabfd0f6d239a92e65684bcce7e67ff30bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/648518
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agoruntime, internal/fuzz: add comparison tracing for libFuzzer on loong64
limeidan [Thu, 13 Mar 2025 11:51:03 +0000 (19:51 +0800)]
runtime, internal/fuzz: add comparison tracing for libFuzzer on loong64

Change-Id: I212330962453139fa353db29928786b64c9ff063
Reviewed-on: https://go-review.googlesource.com/c/go/+/667455
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 months agocmd/internal/obj: add new assembly format for BFPT and BFPF on loong64
Guoqi Chen [Wed, 23 Apr 2025 02:30:39 +0000 (10:30 +0800)]
cmd/internal/obj: add new assembly format for BFPT and BFPF on loong64

On loong64, BFPT and BFPF are mapped to the platform assembly as follows:

   Go asm syntax:
        BFPT   FCCx, offs21
        BFPF   FCCx, offs21
   Equivalent platform assembler syntax:
        bcnez  cj, offs21
        bceqz  cj, offs21

If the condition register is not specified, it defaults to FCC0.

Change-Id: I2cc3df62a9c55d4b5eb124789358983c6737319c
Reviewed-on: https://go-review.googlesource.com/c/go/+/667456
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
3 months agocrypto/sha256: improve performance of riscv64 assembly
Julian Zhu [Tue, 31 Dec 2024 05:35:56 +0000 (13:35 +0800)]
crypto/sha256: improve performance of riscv64 assembly

Simplified the implementation of Ch and Maj by reducing instructions, based on CL 605495 which made the same change for SHA-512.

goos: linux
goarch: riscv64
pkg: crypto/sha256
cpu: Spacemit(R) X60
                    │  oldsha256  │              newsha256              │
                    │   sec/op    │   sec/op     vs base                │
Hash8Bytes/New-8      2.303µ ± 0%   2.098µ ± 0%   -8.90% (p=0.000 n=10)
Hash8Bytes/Sum224-8   2.535µ ± 0%   2.329µ ± 0%   -8.13% (p=0.000 n=10)
Hash8Bytes/Sum256-8   2.558µ ± 0%   2.352µ ± 0%   -8.04% (p=0.000 n=10)
Hash1K/New-8          28.67µ ± 0%   25.21µ ± 0%  -12.06% (p=0.000 n=10)
Hash1K/Sum224-8       28.89µ ± 0%   25.43µ ± 0%  -11.99% (p=0.000 n=10)
Hash1K/Sum256-8       28.91µ ± 0%   25.43µ ± 0%  -12.04% (p=0.000 n=10)
Hash8K/New-8          218.0µ ± 1%   192.7µ ± 2%  -11.58% (p=0.000 n=10)
Hash8K/Sum224-8       218.0µ ± 1%   193.6µ ± 1%  -11.20% (p=0.000 n=10)
Hash8K/Sum256-8       219.1µ ± 1%   193.4µ ± 1%  -11.74% (p=0.000 n=10)
geomean               24.93µ        22.28µ       -10.65%

                    │  oldsha256   │              newsha256               │
                    │     B/s      │     B/s       vs base                │
Hash8Bytes/New-8      3.309Mi ± 0%   3.633Mi ± 0%   +9.80% (p=0.000 n=10)
Hash8Bytes/Sum224-8   3.009Mi ± 0%   3.271Mi ± 0%   +8.72% (p=0.000 n=10)
Hash8Bytes/Sum256-8   2.985Mi ± 0%   3.242Mi ± 0%   +8.63% (p=0.000 n=10)
Hash1K/New-8          34.06Mi ± 0%   38.73Mi ± 0%  +13.72% (p=0.000 n=10)
Hash1K/Sum224-8       33.80Mi ± 0%   38.40Mi ± 0%  +13.63% (p=0.000 n=10)
Hash1K/Sum256-8       33.78Mi ± 0%   38.40Mi ± 0%  +13.69% (p=0.000 n=10)
Hash8K/New-8          35.84Mi ± 1%   40.54Mi ± 2%  +13.10% (p=0.000 n=10)
Hash8K/Sum224-8       35.83Mi ± 1%   40.35Mi ± 1%  +12.61% (p=0.000 n=10)
Hash8K/Sum256-8       35.66Mi ± 1%   40.40Mi ± 1%  +13.29% (p=0.000 n=10)
geomean               15.54Mi        17.39Mi       +11.89%

Change-Id: I9aa692fcfd70634dc6c308db9b5d06bd82ac2302
Reviewed-on: https://go-review.googlesource.com/c/go/+/639495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
3 months agosync/atomic: document that atomic types should not be copied
Mateusz Poliwczak [Wed, 27 Sep 2023 12:57:06 +0000 (12:57 +0000)]
sync/atomic: document that atomic types should not be copied

Change-Id: I3c557d02cd676a389b5c5ea70ed92c8959041e3b
GitHub-Last-Rev: 8732da19a64853834ca155cafc1d7b2967290c31
GitHub-Pull-Request: golang/go#63256
Reviewed-on: https://go-review.googlesource.com/c/go/+/531375
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
3 months agoruntime: fix typo in comment
changwang ma [Fri, 25 Oct 2024 15:46:35 +0000 (23:46 +0800)]
runtime: fix typo in comment

Change-Id: I85f518e36c18f4f0eda8b167750b43cd8c48ecff
Reviewed-on: https://go-review.googlesource.com/c/go/+/622675
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 months agocmd/compile: put constant value on node inside parentheses
Keith Randall [Tue, 22 Apr 2025 22:14:17 +0000 (15:14 -0700)]
cmd/compile: put constant value on node inside parentheses

That's where the unified IR writer expects it.

Fixes #73476

Change-Id: Ic22bd8dee5be5991e6d126ae3f6eccb2acdc0b19
Reviewed-on: https://go-review.googlesource.com/c/go/+/667415
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agoruntime/debug: update SetCrashOutput example to not pass parent env vars
Felix Geisendörfer [Thu, 24 Apr 2025 14:38:58 +0000 (16:38 +0200)]
runtime/debug: update SetCrashOutput example to not pass parent env vars

Fixes #73490

Change-Id: I500fa73f4215c7f490779f53c1c2c0d775f51a95
Reviewed-on: https://go-review.googlesource.com/c/go/+/667775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agocmd/compile: add cast in range loop final value computation
Keith Randall [Thu, 24 Apr 2025 15:38:56 +0000 (08:38 -0700)]
cmd/compile: add cast in range loop final value computation

When replacing a loop where the iteration variable has a named type,
we need to compute the last iteration value as i = T(len(a)-1), not
just i = len(a)-1.

Fixes #73491

Change-Id: Ic1cc3bdf8571a40c10060f929a9db8a888de2b70
Reviewed-on: https://go-review.googlesource.com/c/go/+/667815
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agoruntime: fix tag pointers on aix
Keith Randall [Thu, 24 Apr 2025 06:23:53 +0000 (23:23 -0700)]
runtime: fix tag pointers on aix

Clean up tagged pointers a bit. I got the shifts wrong
for the weird aix case.

Change-Id: I21449fd5973f4651fd1103d3b8be9c2b9b93a490
Reviewed-on: https://go-review.googlesource.com/c/go/+/667715
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoos,internal/poll: disassociate handle from IOCP in File.Fd
qmuntal [Thu, 10 Apr 2025 15:45:47 +0000 (17:45 +0200)]
os,internal/poll: disassociate handle from IOCP in File.Fd

Go 1.25 will gain support for overlapped IO on handles passed to
os.NewFile thanks to CL 662236. It was previously not possible to add
an overlapped handle to the Go runtime's IO completion port (IOCP),
and now happens on the first call the an IO method.

This means that there is code that relies on the fact that File.Fd
returns a handle that can always be associated with a custom IOCP.
That wouldn't be the case anymore, as a handle can only be associated
with one IOCP at a time and it must be explicitly disassociated.

To fix this breaking change, File.Fd will disassociate the handle
from the Go runtime IOCP before returning it. It is then not necessary
to defer the association until the first IO method is called, which
was recently added in CL 661955 to support this same use case, but
in a more complex and unreliable way.

Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Id8a7e04d35057047c61d1733bad5bf45494b2c28
Reviewed-on: https://go-review.googlesource.com/c/go/+/664455
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoruntime: use precise bounds of Go data/bss for race detector
Keith Randall [Wed, 23 Apr 2025 21:15:51 +0000 (14:15 -0700)]
runtime: use precise bounds of Go data/bss for race detector

We only want to call into the race detector for Go global variables.
By rounding up the region bounds, we can include some C globals.
Even worse, we can include only *part* of a C global, leading to
race{read,write}range calls which straddle the end of shadow memory.
That causes the race detector to barf.

Fix some off-by-one errors in the assembly comparisons. We want to
skip calling the race detector when addr == racedataend.

Fixes #73483

Change-Id: I436b0f588d6165b61f30cb7653016ba9b7cbf585
Reviewed-on: https://go-review.googlesource.com/c/go/+/667655
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
3 months agoruntime: align taggable pointers more so we can use low bits for tag
Keith Randall [Tue, 15 Apr 2025 21:55:06 +0000 (14:55 -0700)]
runtime: align taggable pointers more so we can use low bits for tag

Currently we assume alignment to 8 bytes, so we can steal the low 3 bits.
This CL assumes alignment to 512 bytes, so we can steal the low 9 bits.

That's 6 extra bits!

Aligning to 512 bytes wastes a bit of space but it is not egregious.
Most of the objects that we make tagged pointers to are pretty big.

Update #49405

Change-Id: I66fc7784ac1be5f12f285de1d7851d5a6871fb75
Reviewed-on: https://go-review.googlesource.com/c/go/+/665815
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/vet: add hostport analyzer
Alan Donovan [Wed, 23 Apr 2025 18:23:45 +0000 (14:23 -0400)]
cmd/vet: add hostport analyzer

+ test, release note

Fixes #28308

Change-Id: I190e2fe513eeb6b90b0398841f67bf52510b5f59
Reviewed-on: https://go-review.googlesource.com/c/go/+/667596
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/vendor: update x/tools and x/text
Alan Donovan [Wed, 23 Apr 2025 19:52:28 +0000 (15:52 -0400)]
cmd/vendor: update x/tools and x/text

This CL updates x/tools to 68e94bd and x/text to v0.24.0,
updates the vendor tree, and re-runs the bundle step for net/http.

Updates golang/go#28308

Change-Id: I4184f77547f535270ddc8e2ce6542377e3046ffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/667597
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

3 months agocrypto/tls: skip part of the test based on GOOS instead of GOARCH
Nevkontakte [Mon, 21 Apr 2025 13:13:04 +0000 (13:13 +0000)]
crypto/tls: skip part of the test based on GOOS instead of GOARCH

This allows to skip the last part of the test under GopherJS as well as
WebAssembly, since GopherJS shares GOOS=js with wasm.

Change-Id: I41adad788043c1863b23eb2a6da9bc9aa2833092
GitHub-Last-Rev: d8d42a3b7ccb2bee6479306b6ac1a319443702ec
GitHub-Pull-Request: golang/go#51827
Reviewed-on: https://go-review.googlesource.com/c/go/+/394114
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agointernal/goexperiment: add Green Tea GC goexperiment
Michael Anthony Knyszek [Fri, 31 Jan 2025 20:12:19 +0000 (20:12 +0000)]
internal/goexperiment: add Green Tea GC goexperiment

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

3 months agoruntime: move some malloc constants to internal/runtime/gc
Michael Anthony Knyszek [Tue, 4 Mar 2025 19:18:22 +0000 (19:18 +0000)]
runtime: move some malloc constants to internal/runtime/gc

These constants are needed by some future generator programs.

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

3 months agoruntime: move sizeclass defs to new package internal/runtime/gc
Michael Anthony Knyszek [Tue, 4 Mar 2025 19:02:48 +0000 (19:02 +0000)]
runtime: move sizeclass defs to new package internal/runtime/gc

We will want to reference these definitions from new generator programs,
and this is a good opportunity to cleanup all these old C-style names.

Change-Id: Ifb06f0afc381e2697e7877f038eca786610c96de
Reviewed-on: https://go-review.googlesource.com/c/go/+/655275
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agoruntime: optimize the function memequal using SIMD on loong64
limeidan [Tue, 22 Apr 2025 02:24:27 +0000 (10:24 +0800)]
runtime: optimize the function memequal using SIMD on loong64

goos: linux
goarch: loong64
pkg: bytes
cpu: Loongson-3A6000-HV @ 2500.00MHz
                              │      old      │                 new                  │
                              │    sec/op     │    sec/op     vs base                │
Equal/0                          0.4012n ± 0%   0.4003n ± 0%   -0.21% (p=0.000 n=10)
Equal/same/1                      2.555n ± 1%    2.419n ± 0%   -5.32% (p=0.000 n=10)
Equal/same/6                      2.574n ± 1%    2.425n ± 1%   -5.79% (p=0.000 n=10)
Equal/same/9                      2.578n ± 0%    2.419n ± 1%   -6.19% (p=0.000 n=10)
Equal/same/15                     2.565n ± 1%    2.417n ± 0%   -5.73% (p=0.000 n=10)
Equal/same/16                     2.576n ± 1%    2.414n ± 0%   -6.31% (p=0.000 n=10)
Equal/same/20                     2.573n ± 1%    2.416n ± 0%   -6.10% (p=0.000 n=10)
Equal/same/32                     2.559n ± 0%    2.411n ± 0%   -5.80% (p=0.000 n=10)
Equal/same/4K                     2.579n ± 1%    2.410n ± 0%   -6.53% (p=0.000 n=10)
Equal/same/4M                     2.571n ± 0%    2.411n ± 0%   -6.22% (p=0.000 n=10)
Equal/same/64M                    2.568n ± 1%    2.413n ± 0%   -6.05% (p=0.000 n=10)
Equal/1                           5.215n ± 0%    6.404n ± 0%  +22.80% (p=0.000 n=10)
Equal/6                          11.630n ± 0%    6.404n ± 0%  -44.94% (p=0.000 n=10)
Equal/9                          15.240n ± 0%    6.404n ± 0%  -57.98% (p=0.000 n=10)
Equal/15                         22.925n ± 0%    6.404n ± 0%  -72.07% (p=0.000 n=10)
Equal/16                         24.070n ± 0%    5.203n ± 0%  -78.38% (p=0.000 n=10)
Equal/20                         28.880n ± 0%    6.404n ± 0%  -77.83% (p=0.000 n=10)
Equal/32                         43.320n ± 0%    6.404n ± 0%  -85.22% (p=0.000 n=10)
Equal/4K                        4938.50n ± 0%    55.43n ± 0%  -98.88% (p=0.000 n=10)
Equal/4M                         5048.8µ ± 0%    202.0µ ± 0%  -96.00% (p=0.000 n=10)
Equal/64M                        80.819m ± 0%    4.539m ± 0%  -94.38% (p=0.000 n=10)
EqualBothUnaligned/64_0          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_1          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_4          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_7          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/4096_0       4937.00n ± 0%    65.64n ± 0%  -98.67% (p=0.000 n=10)
EqualBothUnaligned/4096_1       4937.00n ± 0%    78.85n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4096_4       4937.00n ± 0%    78.87n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4096_7       4937.00n ± 0%    78.87n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4194304_0     5049.2µ ± 0%    204.2µ ± 0%  -95.96% (p=0.000 n=10)
EqualBothUnaligned/4194304_1     5049.2µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/4194304_4     5049.4µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/4194304_7     5049.2µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/67108864_0    80.796m ± 0%    3.863m ± 0%  -95.22% (p=0.000 n=10)
EqualBothUnaligned/67108864_1    80.801m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
EqualBothUnaligned/67108864_4    80.799m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
EqualBothUnaligned/67108864_7    80.781m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
geomean                           1.040µ         149.6n       -85.63%

Change-Id: Id4c2bc0ca758337dd9759df83750c761814be488
Reviewed-on: https://go-review.googlesource.com/c/go/+/667255
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agoruntime: fix typos in comments
Xiaolin Zhao [Thu, 17 Apr 2025 12:21:29 +0000 (20:21 +0800)]
runtime: fix typos in comments

Change-Id: Id169b68cc93bb6eb4cdca384efaaf971fcfa32b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/666316
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agoRevert "runtime: only poll network from one P at a time in findRunnable"
Carlos Amedee [Tue, 22 Apr 2025 20:42:26 +0000 (13:42 -0700)]
Revert "runtime: only poll network from one P at a time in findRunnable"

This reverts commit 352dd2d932c1c1c6dbc3e112fcdfface07d4fffb.

Reason for revert: cockroachdb benchmark failing. Likely due to CL 564197.

For #73474

Change-Id: Id5d83cd8bb8fe9ee7fddb8dc01f1a01f2d40154e
Reviewed-on: https://go-review.googlesource.com/c/go/+/667336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>

3 months agonet/http: replace map lookup with switch for scheme port
1911860538 [Thu, 17 Apr 2025 14:51:18 +0000 (14:51 +0000)]
net/http: replace map lookup with switch for scheme port

Improve scheme port lookup by replacing map with switch, reducing overhead and improving performance.

Change-Id: I45c790da15e237d5f32c50d342b3713b98fd2ffa
GitHub-Last-Rev: 4c02e4cabf181b365fbf2b722e3051625a289527
GitHub-Pull-Request: golang/go#73422
Reviewed-on: https://go-review.googlesource.com/c/go/+/666356
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
3 months agoruntime, internal/runtime/maps: speed-up empty/zero map lookups
Mateusz Poliwczak [Mon, 7 Apr 2025 13:21:16 +0000 (15:21 +0200)]
runtime, internal/runtime/maps: speed-up empty/zero map lookups

This lets the inliner do a better job optimizing the mapKeyError call.

goos: linux
goarch: amd64
pkg: runtime
cpu: AMD Ryzen 5 4600G with Radeon Graphics
                                 │ /tmp/before2 │             /tmp/after3             │
                                 │    sec/op    │   sec/op     vs base                │
MapAccessZero/Key=int64-12          1.875n ± 0%   1.875n ± 0%        ~ (p=0.506 n=25)
MapAccessZero/Key=int32-12          1.875n ± 0%   1.875n ± 0%        ~ (p=0.082 n=25)
MapAccessZero/Key=string-12         1.902n ± 1%   1.902n ± 1%        ~ (p=0.256 n=25)
MapAccessZero/Key=mediumType-12     2.816n ± 0%   1.958n ± 0%  -30.47% (p=0.000 n=25)
MapAccessZero/Key=bigType-12        2.815n ± 0%   1.935n ± 0%  -31.26% (p=0.000 n=25)
MapAccessEmpty/Key=int64-12         1.942n ± 0%   2.109n ± 0%   +8.60% (p=0.000 n=25)
MapAccessEmpty/Key=int32-12         2.110n ± 0%   1.940n ± 0%   -8.06% (p=0.000 n=25)
MapAccessEmpty/Key=string-12        2.024n ± 0%   2.109n ± 0%   +4.20% (p=0.000 n=25)
MapAccessEmpty/Key=mediumType-12    3.157n ± 0%   2.344n ± 0%  -25.75% (p=0.000 n=25)
MapAccessEmpty/Key=bigType-12       3.054n ± 0%   2.115n ± 0%  -30.75% (p=0.000 n=25)
geomean                             2.305n        2.011n       -12.75%

Change-Id: Iee83930884dc4c8a791a711aa189a1c93b68d536
Reviewed-on: https://go-review.googlesource.com/c/go/+/663495
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocmd/compile: constant fold 128-bit multiplies
Keith Randall [Mon, 21 Apr 2025 19:44:24 +0000 (12:44 -0700)]
cmd/compile: constant fold 128-bit multiplies

The full 64x64->128 multiply comes up when using bits.Mul64.
The 64x64->64+overflow multiply comes up in unsafe.Slice when using
a constant length.

Change-Id: I298515162ca07d804b2d699d03bc957ca30a4ebc
Reviewed-on: https://go-review.googlesource.com/c/go/+/667175
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoruntime: commit to spinbitmutex GOEXPERIMENT
Rhys Hiltner [Fri, 14 Mar 2025 19:38:34 +0000 (12:38 -0700)]
runtime: commit to spinbitmutex GOEXPERIMENT

Use the "spinbit" mutex implementation always (including on platforms
that need to emulate atomic.Xchg8), and delete the prior "tristate"
implementations.

The exception is GOARCH=wasm, where the Go runtime does not use multiple
threads.

For #68578

Change-Id: Ifc29bbfa05071d776c23a19ae185891a03a82417
Reviewed-on: https://go-review.googlesource.com/c/go/+/658456
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoruntime: fix test of when a mutex is contended
Rhys Hiltner [Tue, 8 Apr 2025 18:34:56 +0000 (11:34 -0700)]
runtime: fix test of when a mutex is contended

This is used only in tests that verify reports of runtime-internal mutex
contention.

For #66999
For #70602

Change-Id: I72cb1302d8ea0524f1182ec892f5c9a1923cddba
Reviewed-on: https://go-review.googlesource.com/c/go/+/667095
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agosync: use atomic.Bool for Once.done
Prabhav Dogra [Sun, 20 Apr 2025 07:52:58 +0000 (07:52 +0000)]
sync: use atomic.Bool for Once.done

Updated the use of atomic.Uint32 to atomic.Bool for sync package.

Change-Id: Ib8da66fea86ef06e1427ac5118016b96fbcda6b1
GitHub-Last-Rev: d36e0f431fcde988f90badf86bbf04a18a411947
GitHub-Pull-Request: golang/go#73447
Reviewed-on: https://go-review.googlesource.com/c/go/+/666895
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
3 months agoruntime: only poll network from one P at a time in findRunnable
Ian Lance Taylor [Thu, 15 Feb 2024 01:54:00 +0000 (17:54 -0800)]
runtime: only poll network from one P at a time in findRunnable

For #65064

Change-Id: Ifecd7e332d2cf251750752743befeda4ed396f33
Reviewed-on: https://go-review.googlesource.com/c/go/+/564197
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Artur M. Wolff <artur.m.wolff@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocmd/compile: ensure we evaluate side effects of len() arg
Keith Randall [Fri, 14 Mar 2025 20:36:58 +0000 (13:36 -0700)]
cmd/compile: ensure we evaluate side effects of len() arg

For any len() which requires the evaluation of its arg (according to the spec).

Update #72844

Change-Id: Id2b0bcc78073a6d5051abd000131dafdf65e7f26
Reviewed-on: https://go-review.googlesource.com/c/go/+/658097
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/compile: don't evaluate side effects of range over array
Keith Randall [Wed, 19 Mar 2025 17:17:22 +0000 (10:17 -0700)]
cmd/compile: don't evaluate side effects of range over array

If the thing we're ranging over is an array or ptr to array, and
it doesn't have a function call or channel receive in it, then we
shouldn't evaluate it.

Typecheck the ranged-over value as a constant in that case.
That makes the unified exporter replace the range expression
with a constant int.

Change-Id: I0d4ea081de70d20cf6d1fa8d25ef6cb021975554
Reviewed-on: https://go-review.googlesource.com/c/go/+/659317
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
3 months agocmd/compile/internal/escape: avoid reading ir.Node during inner loop of walkOne
thepudds [Wed, 12 Mar 2025 18:45:17 +0000 (14:45 -0400)]
cmd/compile/internal/escape: avoid reading ir.Node during inner loop of walkOne

Broadly speaking, escape analysis has two main phases. First, it
traverses the AST while building a data-flow graph of locations and
edges. Second, during "solve", it repeatedly walks the data-flow graph
while carefully propagating information about each location, including
whether a location's address reaches the heap.

Once escape analysis is in the solve phase and repeatedly walking the
data-flow graph, almost all the information it needs is within the
location graph, with a notable exception being the ir.Class of an
ir.Name, which currently must be checked by following a pointer from
the location to its ir.Node.

For typical graphs, that does not matter much, but if the graph becomes
large enough, cache misses in the inner solve loop start to matter more,
and the class is checked many times in the inner loop.

We therefore store the class information on the location in the graph
to reduce how much memory we need to load in the inner loop.

The package github.com/microsoft/typescript-go/internal/checker
has many locations, and compilation currently spends most of its time
in escape analysis.

This CL gives roughly a 30% speedup for wall clock compilation time
for the checker package:

  go1.24.0:      91.79s
  this CL:       64.98s

Linux perf shows a healthy reduction for example in l2_request.miss and
dTLB-load-misses on an amd64 test VM.

We could tweak things a bit more, though initial review feedback
has suggested it would be good to get this in as it stands.

Subsequent CLs in this stack give larger improvements.

Updates #72815

Change-Id: I3117430dff684c99e6da1e0d7763869873379238
Reviewed-on: https://go-review.googlesource.com/c/go/+/657295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jake Bailey <jacob.b.bailey@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
3 months agocrypto/sha512: remove unnecessary move op, replace with direct add
Julian Zhu [Tue, 15 Apr 2025 13:17:20 +0000 (21:17 +0800)]
crypto/sha512: remove unnecessary move op, replace with direct add

goos: linux
goarch: riscv64
pkg: crypto/sha512
                    │      o      │                 n                  │
                    │   sec/op    │   sec/op     vs base               │
Hash8Bytes/New-4      3.499µ ± 0%   3.444µ ± 0%  -1.56% (p=0.000 n=10)
Hash8Bytes/Sum384-4   4.012µ ± 0%   3.957µ ± 0%  -1.37% (p=0.000 n=10)
Hash8Bytes/Sum512-4   4.218µ ± 0%   4.162µ ± 0%  -1.32% (p=0.000 n=10)
Hash1K/New-4          17.07µ ± 0%   16.57µ ± 0%  -2.97% (p=0.000 n=10)
Hash1K/Sum384-4       17.59µ ± 0%   17.11µ ± 0%  -2.76% (p=0.000 n=10)
Hash1K/Sum512-4       17.78µ ± 0%   17.30µ ± 0%  -2.72% (p=0.000 n=10)
Hash8K/New-4          112.2µ ± 0%   108.7µ ± 0%  -3.08% (p=0.000 n=10)
Hash8K/Sum384-4       112.7µ ± 0%   109.2µ ± 0%  -3.09% (p=0.000 n=10)
Hash8K/Sum512-4       112.9µ ± 0%   109.4µ ± 0%  -3.07% (p=0.000 n=10)
geomean               19.72µ        19.24µ       -2.44%

                    │      o       │                  n                  │
                    │     B/s      │     B/s       vs base               │
Hash8Bytes/New-4      2.184Mi ± 0%   2.213Mi ± 0%  +1.31% (p=0.000 n=10)
Hash8Bytes/Sum384-4   1.898Mi ± 1%   1.926Mi ± 0%  +1.51% (p=0.000 n=10)
Hash8Bytes/Sum512-4   1.812Mi ± 1%   1.831Mi ± 0%  +1.05% (p=0.000 n=10)
Hash1K/New-4          57.20Mi ± 0%   58.95Mi ± 0%  +3.06% (p=0.000 n=10)
Hash1K/Sum384-4       55.51Mi ± 0%   57.09Mi ± 0%  +2.84% (p=0.000 n=10)
Hash1K/Sum512-4       54.91Mi ± 0%   56.44Mi ± 0%  +2.79% (p=0.000 n=10)
Hash8K/New-4          69.63Mi ± 0%   71.84Mi ± 0%  +3.17% (p=0.000 n=10)
Hash8K/Sum384-4       69.30Mi ± 0%   71.52Mi ± 0%  +3.20% (p=0.000 n=10)
Hash8K/Sum512-4       69.19Mi ± 0%   71.39Mi ± 0%  +3.18% (p=0.000 n=10)
geomean               19.65Mi        20.13Mi       +2.45%

Change-Id: Ib68b934276ec08246d4ae60ef9870c233f0eac69
Reviewed-on: https://go-review.googlesource.com/c/go/+/665595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 months agocrypto/internal/fips140/aes: actually use the VTBL instruction on arm64
Joel Sing [Sat, 19 Apr 2025 05:57:37 +0000 (15:57 +1000)]
crypto/internal/fips140/aes: actually use the VTBL instruction on arm64

Support for the VTBL instruction was added in CL 110015 - use it
directly, rather than using WORD encodings. Note that one of the
WORD encodings does not actually match the instruction in the
comment - use the instruction that matches the existing encoding
instead.

Change-Id: I1933162f8144a6b86b38e8b550d36907131b1dd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/666795
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agonet: simplify readProtocols via sync.OnceFunc
1911860538 [Fri, 18 Apr 2025 14:11:29 +0000 (14:11 +0000)]
net: simplify readProtocols via sync.OnceFunc

In this case, using sync.OnceFunc is a better choice.

Change-Id: I52d27b9741265c90300a04a03537020e1aaaaaa7
GitHub-Last-Rev: a281daea255f1508a9042e8c8c7eb7ca1cef2430
GitHub-Pull-Request: golang/go#73434
Reviewed-on: https://go-review.googlesource.com/c/go/+/666635
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
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>
4 months agofs: clarify documentation for ReadDir method
Matthew Burton [Sat, 5 Apr 2025 20:56:42 +0000 (16:56 -0400)]
fs: clarify documentation for ReadDir method

The fs.ReadDir method behaves the same way as
os.ReadDir, in that when n <= 0, ReadDir returns
all DirEntry values remaining in the dictionary.

Update the comment to reflect that only remaining
DirEntry values are returned (not all entries),
for subsequent calls.

Fixes #69301

Change-Id: I41ef7ef1c8e3fe7d64586f5297512697dc60dd40
Reviewed-on: https://go-review.googlesource.com/c/go/+/663215
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agomath/big: use clearer loop bounds check elimination
Russ Cox [Fri, 11 Apr 2025 12:54:58 +0000 (08:54 -0400)]
math/big: use clearer loop bounds check elimination

Checking that the lengths are equal and panicking teaches the compiler
that it can assume “i in range for z” implies “i in range for x”, letting us
simplify the actual loops a bit.

It also turns up a few places in math/big that were playing maybe a little
too fast and loose with slice lengths. Update those to explicitly set all the
input slices to the same length.

These speedups are basically irrelevant, since they only happen
in real code if people are compiling with -tags math_big_pure_go.
But at least the code is clearer.

benchmark \ system                   c3h88    c2s16       s7      386   s7-386   c4as16      mac      arm  loong64  ppc64le  riscv64    s390x
AddVV/words=1/impl=go                    ~  +11.20%   +5.11%   -7.67%   -7.77%   +1.90%  +10.76%  -33.22%        ~  +10.98%        ~   +6.60%
AddVV/words=10/impl=go             -22.12%  -13.48%  -10.37%  -17.95%  -18.07%  -24.58%  -22.04%  -29.95%  -14.22%        ~   -6.33%   +3.66%
AddVV/words=16/impl=go              -9.75%  -13.73%        ~  -21.90%  -18.66%  -30.03%  -20.45%  -28.09%  -17.33%   -7.15%   -8.96%  +12.55%
AddVV/words=100/impl=go             -5.91%   -1.02%        ~  -29.23%  -22.18%  -25.62%   -6.49%  -23.59%  -22.31%   -1.88%  -14.13%   +9.23%
AddVV/words=1000/impl=go            -0.52%   -0.19%   -3.58%  -33.89%  -23.46%  -22.46%        ~  -24.00%  -24.73%   +0.93%  -15.79%  +12.32%
AddVV/words=10000/impl=go                ~        ~        ~  -33.79%  -23.72%  -23.79%   -5.98%  -23.92%        ~   +0.78%  -15.45%   +8.59%
AddVV/words=100000/impl=go               ~        ~        ~  -33.90%  -24.25%  -22.82%   -4.09%  -24.63%        ~   +1.00%  -13.56%        ~
SubVV/words=1/impl=go                    ~  +11.64%  +14.05%        ~   -4.07%        ~  +10.79%  -33.69%        ~        ~   +3.89%  +12.33%
SubVV/words=10/impl=go             -10.31%  -14.09%   -7.38%  +13.76%  -13.25%  -18.05%  -20.08%  -24.97%  -14.15%  +10.13%   -0.97%   -2.51%
SubVV/words=16/impl=go              -8.06%  -13.73%   -5.70%  +17.00%  -12.83%  -23.76%  -17.52%  -25.25%  -17.30%   -2.80%   -4.96%  -18.25%
SubVV/words=100/impl=go             -9.22%   -1.30%   -2.76%  +20.88%  -14.35%  -15.29%   -8.49%  -19.64%  -22.31%   -0.68%  -14.30%   -9.04%
SubVV/words=1000/impl=go            -0.60%        ~   -3.43%  +23.08%  -16.14%  -11.96%        ~  -28.52%  -24.73%        ~  -15.95%   -9.91%
SubVV/words=10000/impl=go                ~        ~        ~  +26.01%  -15.24%  -11.92%        ~  -28.26%   +4.25%        ~  -15.42%   -5.95%
SubVV/words=100000/impl=go               ~        ~        ~  +25.71%  -15.83%  -12.13%        ~  -27.88%   -1.27%        ~  -13.57%   -6.72%
LshVU/words=1/impl=go               +0.56%   +0.36%        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~
LshVU/words=10/impl=go             +13.37%   +4.63%        ~        ~        ~        ~        ~   -2.90%        ~        ~        ~        ~
LshVU/words=16/impl=go             +22.83%   +6.47%        ~        ~        ~        ~        ~        ~   +0.80%        ~        ~   +5.88%
LshVU/words=100/impl=go             +7.56%  +13.95%        ~        ~        ~        ~        ~        ~   +0.33%   -2.50%        ~        ~
LshVU/words=1000/impl=go            +0.64%  +17.92%        ~        ~        ~        ~        ~   -6.52%        ~   -2.58%        ~        ~
LshVU/words=10000/impl=go                ~  +17.60%        ~        ~        ~        ~        ~   -6.64%   -6.22%   -1.40%        ~        ~
LshVU/words=100000/impl=go               ~  +14.57%        ~        ~        ~        ~        ~        ~   -5.47%        ~        ~        ~
RshVU/words=1/impl=go                    ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~   +2.72%
RshVU/words=10/impl=go                   ~        ~        ~        ~        ~        ~        ~   +2.50%        ~        ~        ~        ~
RshVU/words=16/impl=go                   ~   +0.53%        ~        ~        ~        ~        ~   +3.82%        ~        ~        ~        ~
RshVU/words=100/impl=go                  ~        ~        ~        ~        ~        ~        ~   +6.18%        ~        ~        ~        ~
RshVU/words=1000/impl=go                 ~        ~        ~        ~        ~        ~        ~   +7.00%        ~        ~        ~        ~
RshVU/words=10000/impl=go                ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~
RshVU/words=100000/impl=go               ~        ~        ~        ~        ~        ~        ~   +7.05%        ~        ~        ~        ~
MulAddVWW/words=1/impl=go          -10.34%   +4.43%  +10.62%   -1.62%   -4.74%   -2.86%  +11.75%        ~   -8.00%   +8.89%   +3.87%        ~
MulAddVWW/words=10/impl=go          -1.61%   -5.87%        ~   -8.30%   -4.55%   +0.87%        ~   -5.28%  -20.82%        ~        ~   -2.32%
MulAddVWW/words=16/impl=go          -2.96%   -5.28%        ~   -9.22%   -5.28%        ~        ~   -3.74%  -19.52%   -1.48%   -2.53%   -9.52%
MulAddVWW/words=100/impl=go         -3.89%   -7.53%   +1.93%  -10.49%   -4.87%   -8.27%        ~        ~   -0.65%   -0.61%   -7.59%  -20.61%
MulAddVWW/words=1000/impl=go        -0.45%   -3.91%   +4.54%  -11.46%   -4.69%   -8.53%        ~        ~   -0.05%        ~   -8.88%  -19.77%
MulAddVWW/words=10000/impl=go            ~   -3.30%   +4.10%  -11.34%   -4.10%   -9.43%        ~   -0.61%        ~   -0.55%   -8.21%  -18.48%
MulAddVWW/words=100000/impl=go      -0.30%   -3.03%   +4.31%  -11.55%   -4.41%   -9.74%        ~   -0.75%   +0.63%        ~   -7.80%  -19.82%
AddMulVVWW/words=1/impl=go               ~  +13.09%  +12.50%   -7.05%  -10.41%   +2.53%  +13.32%   -3.49%        ~  +15.56%   +3.62%        ~
AddMulVVWW/words=10/impl=go        -15.96%   -9.06%   -5.06%  -14.56%  -11.83%   -5.44%  -26.30%  -14.23%  -11.44%   -1.79%   -5.93%   -6.60%
AddMulVVWW/words=16/impl=go        -19.05%  -12.43%   -6.19%  -14.24%  -12.67%   -8.65%  -18.64%  -16.56%  -10.64%   -3.00%   -7.61%  -12.80%
AddMulVVWW/words=100/impl=go       -22.13%  -16.59%  -13.04%  -13.79%  -11.46%  -12.01%   -6.46%  -21.80%   -5.08%   -3.13%  -13.60%  -22.53%
AddMulVVWW/words=1000/impl=go      -17.07%  -17.05%  -14.08%  -13.59%  -12.13%  -11.21%        ~  -22.81%   -4.27%   -1.27%  -16.35%  -23.47%
AddMulVVWW/words=10000/impl=go     -15.03%  -16.78%  -14.23%  -13.86%  -11.84%  -11.69%        ~  -22.75%  -13.39%   -1.10%  -14.37%  -22.01%
AddMulVVWW/words=100000/impl=go    -13.70%  -14.90%  -14.26%  -13.55%  -12.04%  -11.63%        ~  -22.61%        ~   -2.53%  -10.42%  -23.16%

Change-Id: Ic6f64344484a762b818c7090d1396afceb638607
Reviewed-on: https://go-review.googlesource.com/c/go/+/665155
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
4 months agomath/big: replace assembly with mini-compiler output
Russ Cox [Thu, 10 Apr 2025 21:01:24 +0000 (17:01 -0400)]
math/big: replace assembly with mini-compiler output

Step 4 of the mini-compiler: switch to the new generated assembly.
No systematic performance regressions, and many many improvements.

In the benchmarks, the systems are:

c3h88     GOARCH=amd64     c3h88 perf gomote (newer Intel, Google Cloud)
c2s16     GOARCH=amd64     c2s16 perf gomote (Intel, Google Cloud)
s7        GOARCH=amd64     rsc basement server (AMD Ryzen 9 7950X)
386       GOARCH=386       gotip-linux-386 gomote (Intel, Google Cloud)
s7-386    GOARCH=386       rsc basement server (AMD Ryzen 9 7950X)
c4as16    GOARCH=arm64     c4as16 perf gomote (Google Cloud)
mac       GOARCH=arm64     Apple M3 Pro in MacBook Pro
arm       GOARCH=arm       gotip-linux-arm gomote
loong64   GOARCH=loong64   gotip-linux-loong64 gomote
ppc64le   GOARCH=ppc64le   gotip-linux-ppc64le gomote
riscv64   GOARCH=riscv64   gotip-linux-riscv64 gomote
s390x     GOARCH=s390x     linux-s390x-ibm old gomote

benchmark \ system           c3h88    c2s16       s7      386   s7-386   c4as16      mac      arm  loong64  ppc64le  riscv64    s390x
AddVV/words=1               -4.03%   +5.21%   -4.04%   +4.94%        ~        ~        ~        ~  -19.51%        ~        ~        ~
AddVV/words=10             -10.20%   +0.34%   -3.46%  -11.50%   -7.46%   +7.66%   +5.97%        ~  -17.90%        ~        ~        ~
AddVV/words=16             -10.91%   -6.45%   -8.45%  -21.86%  -17.90%   +2.73%   -1.61%        ~  -22.47%   -3.54%        ~        ~
AddVV/words=100             -3.77%   -4.30%   -3.17%  -47.27%  -45.34%   -0.78%        ~   -8.74%  -27.19%        ~        ~        ~
AddVV/words=1000            -0.08%   -0.71%        ~  -49.21%  -48.07%        ~        ~  -16.80%  -24.74%        ~        ~        ~
AddVV/words=10000                ~        ~        ~  -48.73%  -48.56%   -0.06%        ~  -17.08%        ~        ~   -4.81%        ~
AddVV/words=100000               ~        ~        ~  -47.80%  -48.38%        ~        ~  -15.10%  -25.06%        ~   -5.34%        ~
SubVV/words=1               -0.84%   +3.43%   -3.62%   +1.34%        ~   -0.76%        ~        ~  -18.18%   +5.58%        ~        ~
SubVV/words=10              -9.99%   +0.34%        ~  -11.23%   -8.24%   +7.53%   +6.15%        ~  -17.55%   +2.77%   -2.08%        ~
SubVV/words=16             -11.94%   -6.45%   -6.81%  -21.82%  -18.11%   +1.58%   -1.21%        ~  -20.36%        ~        ~        ~
SubVV/words=100             -3.38%   -4.32%   -1.80%  -46.14%  -46.43%   +0.41%        ~   -7.20%  -26.17%        ~   -0.42%        ~
SubVV/words=1000            -0.38%   -0.80%        ~  -49.22%  -48.90%        ~        ~  -15.86%  -24.73%        ~        ~        ~
SubVV/words=10000                ~        ~        ~  -49.57%  -49.64%   -0.03%        ~  -15.85%  -26.52%        ~   -5.05%        ~
SubVV/words=100000               ~        ~        ~  -46.88%  -49.66%        ~        ~  -15.45%  -16.11%        ~   -4.99%        ~
LshVU/words=1                    ~   +5.78%        ~        ~   -2.48%   +1.61%   +2.18%   +2.70%  -18.16%  -34.16%  -21.29%        ~
LshVU/words=10             -18.34%   -3.78%   +2.21%        ~        ~   -2.81%  -12.54%        ~  -25.02%  -24.78%  -38.11%  -66.98%
LshVU/words=16             -23.15%   +1.03%   +7.74%   +0.73%        ~   +8.88%   +1.56%        ~  -25.37%  -28.46%  -41.27%        ~
LshVU/words=100            -32.85%   -8.86%   -2.58%        ~   +2.69%   +1.24%        ~  -20.63%  -44.14%  -42.68%  -53.09%        ~
LshVU/words=1000           -37.30%   -0.20%   +5.67%        ~        ~   +1.44%        ~  -27.83%  -45.01%  -37.07%  -57.02%  -46.57%
LshVU/words=10000          -36.84%   -2.30%   +3.82%        ~   +1.86%   +1.57%  -66.81%  -28.00%  -13.15%  -35.40%  -41.97%        ~
LshVU/words=100000         -40.30%        ~   +3.96%        ~        ~        ~        ~  -24.91%  -19.06%  -36.14%  -40.99%  -66.03%
RshVU/words=1               -3.17%   +4.76%   -4.06%   +4.31%   +4.55%        ~        ~        ~  -20.61%        ~  -26.20%  -51.33%
RshVU/words=10             -22.08%   -4.41%  -17.99%   +3.64%  -11.87%        ~  -16.30%        ~  -30.01%        ~  -40.37%  -63.05%
RshVU/words=16             -26.03%   -8.50%  -18.09%        ~  -17.52%   +6.50%        ~   -2.85%  -30.24%        ~  -42.93%  -63.13%
RshVU/words=100            -20.87%  -28.83%  -29.45%        ~  -26.25%   +1.46%   -1.14%  -16.20%  -45.65%  -16.20%  -53.66%  -77.27%
RshVU/words=1000           -24.03%  -21.37%  -26.71%        ~  -28.95%   +0.98%        ~  -18.82%  -45.21%  -23.55%  -57.09%  -71.18%
RshVU/words=10000          -24.56%  -22.44%  -27.01%        ~  -28.88%   +0.78%   -5.35%  -17.47%  -16.87%  -20.67%  -41.97%        ~
RshVU/words=100000         -23.36%  -15.65%  -27.54%        ~  -29.26%   +1.73%   -6.67%  -13.68%  -21.40%  -23.02%  -40.37%  -66.31%
MulAddVWW/words=1           +2.37%   +8.14%        ~   +4.10%   +3.71%        ~        ~        ~  -21.62%        ~   +1.12%        ~
MulAddVWW/words=10               ~   -2.72%  -15.15%   +8.04%        ~        ~        ~   -2.52%  -19.48%        ~   -6.18%        ~
MulAddVWW/words=16               ~   +1.49%        ~   +4.49%   +6.58%   -8.70%   -7.16%  -12.08%  -21.43%   -6.59%   -9.05%        ~
MulAddVWW/words=100         +0.37%   +1.11%   -4.51%  -13.59%        ~  -11.10%   -3.63%  -21.40%  -22.27%   -2.92%  -14.41%        ~
MulAddVWW/words=1000             ~   +0.90%   -7.13%  -18.94%        ~  -14.02%   -9.97%  -28.31%  -18.72%   -2.32%  -15.80%        ~
MulAddVWW/words=10000            ~   +1.08%   -6.75%  -19.10%        ~  -14.61%   -9.04%  -28.48%  -14.29%   -2.25%   -9.40%        ~
MulAddVWW/words=100000           ~        ~   -6.93%  -18.09%        ~  -14.33%   -9.66%  -28.92%  -16.63%   -2.43%   -8.23%        ~
AddMulVVWW/words=1          +2.30%   +4.83%  -11.37%   +4.58%        ~   -3.14%        ~        ~  -10.58%  +30.35%        ~        ~
AddMulVVWW/words=10         -3.27%        ~   +8.96%   +5.74%        ~   +2.67%   -1.44%   -7.64%  -13.41%        ~        ~        ~
AddMulVVWW/words=16         -6.12%        ~        ~        ~   +1.91%   -7.90%  -16.22%  -14.07%  -14.26%   -4.15%   -7.30%        ~
AddMulVVWW/words=100        -5.48%   -2.14%        ~   -9.40%   +9.98%   -1.43%  -12.35%  -18.56%  -21.94%        ~   -9.84%        ~
AddMulVVWW/words=1000      -11.35%   -3.40%   -3.64%  -11.04%  +12.82%   -1.33%  -15.63%  -20.50%  -20.95%        ~  -11.06%  -51.97%
AddMulVVWW/words=10000     -10.31%   -1.61%   -8.41%  -12.15%  +13.10%   -1.03%  -16.34%  -22.46%   -1.00%        ~  -10.33%  -49.80%
AddMulVVWW/words=100000    -13.71%        ~   -8.31%  -12.18%  +12.98%   -1.35%  -15.20%  -21.89%        ~        ~   -9.38%  -48.30%

Change-Id: I0a33c33602c0d053c84d9946e662500cfa048e2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/664938
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agomath/big: add shift and mul to mini-compiler
Russ Cox [Thu, 10 Apr 2025 23:17:30 +0000 (19:17 -0400)]
math/big: add shift and mul to mini-compiler

Step 3 of the mini-compiler: add the generators for the shift and mul routines.

Change-Id: I981d5b7086262c740036f5db768d3e63083984e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/664937
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agomath/big: add all architectures to mini-compiler
Russ Cox [Thu, 10 Apr 2025 23:16:22 +0000 (19:16 -0400)]
math/big: add all architectures to mini-compiler

Step 2 of the mini-compiler: add all the remaining architectures.

Change-Id: I8c5283aa8baa497785a5c15f2248528fa9ae886e
Reviewed-on: https://go-review.googlesource.com/c/go/+/664936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

4 months agomath/big: new mini-compiler for arith assembly
Russ Cox [Thu, 10 Apr 2025 20:58:51 +0000 (16:58 -0400)]
math/big: new mini-compiler for arith assembly

The arith assembly is big enough, and the details that you have to keep
in mind are complex enough and varied enough, that it is worth using
a Go program to generate the assembly. That way, all the architectures
can use the same algorithms, and porting to new architectures will be
easier.

This is the first of a sequence of CLs to introduce a new mini-compiler
for generating the arith assembly, in math/big/internal/asmgen.
This CL has the basics of the compiler as well as a couple simple
architectures and the generator for addVV/subVV. It does not check
in the generated assembly yet. That will happen in a followup CL after
the other architectures and generators have been added.

Change-Id: Ib704c60fd972fc5690ac04d8fae3712ee2c1a80a
Reviewed-on: https://go-review.googlesource.com/c/go/+/664935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

4 months agomath/big: replace addVW/subVW assembly with fast pure Go
Russ Cox [Mon, 7 Apr 2025 21:13:20 +0000 (17:13 -0400)]
math/big: replace addVW/subVW assembly with fast pure Go

The vast majority of the time, carry propagation is limited and
addVW/subVW only need to consider a single word for carry propagation.
As Josh Bleecher-Snyder pointed out in 2019 (CL 164968), once carrying
is done, the remaining words can be handled faster with copy (memmove).
In the benchmarks below, this is the data=random case.

Even more important, if the source and destination are the same,
the copy can be optimized away entirely, making a small in-place
addition to a big.Int O(1) instead of O(N). To date, only a few
systems (amd64, arm64, and pure Go, meaning wasm) make use of this
asymptotic improvement. This is the data=shortcut case.

This CL deletes the addVW/subVW assembly and replaces it with
an optimized pure Go version. Using Go makes it easy to call
the real copy builtin, which will use optimized memmove code,
instead of recreating a worse memmove in assembly (as arm64 does)
or omitting the copy optimization entirely (as most others do).

The worst case for the Go version versus assembly is the case
of incrementing 2^N-1 by 1, which has to propagate a carry
the entire length of the array. This is the data=carry case.
On balance, we believe this case is rare enough to be worth
taking a hit in that case, in exchange for significant wins
in the other cases and the deletion of significant amounts of
assembly of varying quality. (Remember that half the assembly has
the copy optimization and shortcut, while half does not.)

In the benchmarks, the systems are:

c2s16     GOARCH=amd64     c2s16 perf gomote (Intel, Google Cloud)
c3h88     GOARCH=amd64     c3h88 perf gomote (newer Intel, Google Cloud)
s7        GOARCH=amd64     rsc basement server (AMD Ryzen 9 7950X)
c4as16    GOARCH=arm64     c4as16 perf gomote (Google Cloud)
mac       GOARCH=arm64     Apple M3 Pro in MacBook Pro
386       GOARCH=386       gotip-linux-386 gomote
arm       GOARCH=arm       gotip-linux-arm gomote
loong64   GOARCH=loong64   gotip-linux-loong64 gomote
ppc64le   GOARCH=ppc64le   gotip-linux-ppc64le gomote
riscv64   GOARCH=riscv64   gotip-linux-riscv64 gomote

benchmark \ system                    c2s16     c3h88       s7    c4as16       mac       386      arm  loong64   ppc64le  riscv64

AddVW/words=1/data=random            -1.15%    -1.74%   -5.89%    -9.80%   -11.54%   +23.71%  -12.74%  -14.25%   +14.67%  +10.27%
AddVW/words=2/data=random            -2.59%         ~   -4.38%   -19.31%   -15.41%   +24.80%        ~  -19.99%   +13.73%  +19.71%
AddVW/words=3/data=random            -3.75%   -19.10%   -3.79%   -23.15%   -17.04%   +20.04%  -10.07%  -23.20%         ~  +15.39%
AddVW/words=4/data=random            -2.84%    +7.05%   -8.77%   -22.64%   -15.77%   +16.01%   -7.36%  -28.22%         ~  +23.00%
AddVW/words=5/data=random           -10.97%    +2.16%  -12.09%   -20.89%   -17.14%    +9.42%   -4.69%  -32.60%         ~  +10.07%
AddVW/words=6/data=random            -9.87%         ~   -7.54%   -19.08%    -6.46%         ~   -3.44%  -34.61%         ~  +12.19%
AddVW/words=7/data=random           -14.36%         ~  -10.09%   -19.10%   -10.47%    -6.20%   -5.06%  -38.14%   -11.54%   +6.79%
AddVW/words=8/data=random           -17.50%         ~  -11.06%   -25.14%   -12.88%    -8.35%   -5.11%  -41.39%   -14.04%  +11.87%
AddVW/words=9/data=random           -19.76%    -4.05%  -15.47%   -24.08%   -16.50%   -12.34%  -21.56%  -44.25%   -14.82%        ~
AddVW/words=10/data=random          -13.89%         ~   -9.69%   -23.06%    -8.04%   -12.58%  -19.25%  -32.80%   -11.68%        ~
AddVW/words=16/data=random          -29.36%   -15.35%  -21.86%   -25.04%   -19.89%   -32.26%  -16.29%  -42.66%   -25.92%   -3.01%
AddVW/words=32/data=random          -39.02%   -28.76%  -39.87%   -11.22%    -2.85%   -55.40%  -31.17%  -55.37%   -37.92%  -16.28%
AddVW/words=64/data=random          -25.94%   -19.09%  -20.60%    -6.90%    +8.91%   -51.00%  -43.72%  -62.27%   -44.11%  -28.74%
AddVW/words=100/data=random         -22.79%   -18.13%  -18.25%         ~   +33.89%   -67.40%  -51.77%  -63.54%   -53.75%  -30.97%
AddVW/words=1000/data=random         -8.98%    -3.84%        ~    -3.15%         ~   -93.35%  -63.92%  -65.66%   -68.67%  -42.30%
AddVW/words=10000/data=random        -1.38%    -0.38%        ~         ~         ~   -89.16%  -65.18%  -44.65%   -70.35%  -20.08%
AddVW/words=100000/data=random            ~         ~        ~         ~         ~   -87.03%  -64.51%  -36.08%   -61.40%  -16.53%

SubVW/words=1/data=random            -3.67%         ~   -8.38%   -10.26%    -3.07%   +45.78%   -6.06%  -11.17%         ~        ~
SubVW/words=2/data=random            -3.48%   -10.07%   -5.76%   -20.14%    -8.45%   +44.28%        ~  -19.09%         ~  +16.98%
SubVW/words=3/data=random            -7.11%   -26.64%   -4.48%   -22.07%    -9.21%   +35.61%        ~  -23.93%   -18.20%        ~
SubVW/words=4/data=random            -4.23%    +7.19%   -8.95%   -22.62%   -13.89%   +33.20%   -8.96%  -29.96%         ~  +22.23%
SubVW/words=5/data=random           -11.49%    +1.92%  -10.86%   -22.27%   -17.53%   +24.48%   -2.88%  -35.19%   -19.55%        ~
SubVW/words=6/data=random            -7.67%         ~   -7.72%   -18.44%    -6.24%   +12.03%   -2.00%  -39.68%   -10.73%        ~
SubVW/words=7/data=random           -13.69%   -18.32%  -11.82%   -18.92%   -11.57%    +6.63%        ~  -43.54%   -30.81%        ~
SubVW/words=8/data=random           -16.02%         ~  -11.07%   -24.50%   -11.92%    +4.32%   -3.01%  -46.95%   -24.14%        ~
SubVW/words=9/data=random           -18.76%    -3.34%  -14.84%   -23.79%   -17.50%         ~  -21.80%  -49.98%   -29.62%        ~
SubVW/words=10/data=random          -13.23%         ~   -9.25%   -21.26%   -11.63%         ~  -18.58%  -39.19%   -20.09%        ~
SubVW/words=16/data=random          -28.25%   -13.24%  -22.66%   -27.18%   -19.13%   -23.38%  -20.24%  -51.01%   -28.06%   -3.05%
SubVW/words=32/data=random          -38.41%   -28.88%  -40.12%   -11.20%    -2.80%   -49.17%  -34.67%  -63.29%   -39.25%  -15.20%
SubVW/words=64/data=random          -25.51%   -19.24%  -22.20%    -6.57%    +9.98%   -48.52%  -48.14%  -69.50%   -49.44%  -27.92%
SubVW/words=100/data=random         -21.69%   -18.51%        ~    +1.92%   +34.42%   -65.88%  -54.67%  -71.24%   -58.88%  -30.71%
SubVW/words=1000/data=random         -9.81%    -4.05%   -2.14%    -3.06%         ~   -93.37%  -67.33%  -74.12%   -68.36%  -42.17%
SubVW/words=10000/data=random             ~    -0.52%        ~         ~         ~   -88.87%  -68.54%  -44.94%   -70.63%  -19.95%
SubVW/words=100000/data=random            ~         ~        ~         ~         ~   -86.69%  -68.09%  -48.36%   -62.42%  -19.32%

AddVW/words=1/data=shortcut         -29.38%   -25.38%  -27.37%   -23.15%   -25.41%    +3.01%  -33.60%  -36.12%   -15.76%        ~
AddVW/words=2/data=shortcut         -32.79%   -34.72%  -31.47%   -24.47%   -28.21%    -3.75%  -34.66%  -43.89%   -23.65%  -21.56%
AddVW/words=3/data=shortcut         -38.50%   -46.83%  -35.67%   -26.38%   -30.29%   -10.41%  -44.89%  -47.68%   -30.93%  -26.85%
AddVW/words=4/data=shortcut         -40.40%   -28.85%  -34.19%   -29.83%   -32.95%   -16.09%  -42.86%  -51.02%   -34.19%  -26.69%
AddVW/words=5/data=shortcut         -43.87%   -35.42%  -36.46%   -32.59%   -37.72%   -20.82%  -45.14%  -54.01%   -35.49%  -30.48%
AddVW/words=6/data=shortcut         -46.98%   -39.34%  -42.22%   -35.43%   -38.18%   -27.46%  -46.72%  -56.61%   -40.21%  -34.07%
AddVW/words=7/data=shortcut         -49.63%   -47.97%  -46.61%   -35.28%   -41.93%   -31.14%  -49.29%  -58.89%   -41.10%  -37.01%
AddVW/words=8/data=shortcut         -50.48%   -42.33%  -45.40%   -40.24%   -41.74%   -32.92%  -50.62%  -60.98%   -44.85%  -38.10%
AddVW/words=9/data=shortcut         -54.27%   -43.52%  -49.06%   -42.16%   -45.22%   -37.57%  -51.84%  -62.91%   -46.04%  -40.82%
AddVW/words=10/data=shortcut        -56.01%   -45.40%  -51.42%   -43.29%   -46.14%   -38.65%  -53.65%  -64.62%   -47.05%  -43.21%
AddVW/words=16/data=shortcut        -62.73%   -55.66%  -59.31%   -56.38%   -54.31%   -53.16%  -61.03%  -72.29%   -58.24%  -52.57%
AddVW/words=32/data=shortcut        -74.00%   -69.42%  -71.75%   -33.65%   -37.35%   -71.73%  -72.59%  -82.44%   -70.87%  -67.69%
AddVW/words=64/data=shortcut        -56.69%   -52.72%  -52.09%   -35.48%   -36.87%   -84.24%  -83.10%  -90.37%   -82.56%  -80.81%
AddVW/words=100/data=shortcut       -56.68%   -53.18%  -51.49%   -33.49%   -37.72%   -89.95%  -88.21%  -93.37%   -88.47%  -86.52%
AddVW/words=1000/data=shortcut      -56.68%   -52.45%  -51.66%   -35.31%   -36.65%   -98.88%  -98.62%  -99.24%   -98.78%  -98.41%
AddVW/words=10000/data=shortcut     -56.70%   -52.40%  -51.92%   -33.49%   -36.98%   -99.89%  -99.86%  -99.92%   -99.87%  -99.91%
AddVW/words=100000/data=shortcut    -56.67%   -52.46%  -52.38%   -35.31%   -37.20%   -99.99%  -99.99%  -99.99%   -99.99%  -99.99%

SubVW/words=1/data=shortcut         -29.80%   -20.71%  -26.94%   -23.24%   -25.33%   +26.97%  -32.02%  -37.85%   -40.20%  -12.67%
SubVW/words=2/data=shortcut         -35.47%   -36.38%  -31.93%   -25.43%   -30.18%   +18.96%  -33.48%  -46.48%   -39.38%  -18.65%
SubVW/words=3/data=shortcut         -39.22%   -49.96%  -36.90%   -25.82%   -30.96%   +12.53%  -40.67%  -51.07%   -43.71%  -23.78%
SubVW/words=4/data=shortcut         -40.46%   -24.90%  -34.66%   -29.87%   -33.97%    +4.60%  -42.32%  -54.92%   -42.83%  -22.45%
SubVW/words=5/data=shortcut         -43.84%   -34.17%  -38.00%   -32.55%   -37.27%    -2.46%  -43.09%  -58.18%   -45.70%  -26.45%
SubVW/words=6/data=shortcut         -47.69%   -37.49%  -42.73%   -35.90%   -37.73%    -8.52%  -46.55%  -61.01%   -44.00%  -30.14%
SubVW/words=7/data=shortcut         -49.45%   -50.66%  -46.88%   -34.77%   -41.64%   -14.46%  -48.92%  -63.46%   -50.47%  -33.39%
SubVW/words=8/data=shortcut         -50.45%   -39.31%  -47.14%   -40.47%   -41.70%   -15.77%  -50.21%  -65.64%   -47.71%  -34.01%
SubVW/words=9/data=shortcut         -54.28%   -43.07%  -49.42%   -41.34%   -44.99%   -19.39%  -51.55%  -67.61%   -56.92%  -36.82%
SubVW/words=10/data=shortcut        -56.85%   -47.88%  -50.92%   -42.76%   -45.67%   -23.60%  -53.04%  -69.34%   -60.18%  -39.43%
SubVW/words=16/data=shortcut        -62.36%   -54.83%  -58.80%   -55.83%   -53.74%   -41.04%  -60.16%  -76.75%   -60.56%  -48.63%
SubVW/words=32/data=shortcut        -73.68%   -68.64%  -71.57%   -33.52%   -37.34%   -64.73%  -72.67%  -85.89%   -71.87%  -64.56%
SubVW/words=64/data=shortcut        -56.68%   -51.66%  -52.56%   -34.75%   -37.54%   -80.30%  -83.58%  -92.39%   -83.41%  -78.70%
SubVW/words=100/data=shortcut       -56.68%   -50.97%  -51.57%   -33.68%   -36.78%   -87.42%  -88.53%  -94.84%   -88.87%  -84.96%
SubVW/words=1000/data=shortcut      -56.68%   -50.89%  -52.10%   -34.94%   -37.77%   -98.59%  -98.71%  -99.43%   -98.80%  -98.20%
SubVW/words=10000/data=shortcut     -56.68%   -51.00%  -52.44%   -33.65%   -37.27%   -99.86%  -99.87%  -99.94%   -99.88%  -99.90%
SubVW/words=100000/data=shortcut    -56.68%   -50.80%  -52.20%   -34.79%   -37.46%   -99.99%  -99.99%  -99.99%   -99.99%  -99.99%

AddVW/words=1/data=carry             -0.51%    -5.29%  -24.03%   -26.48%         ~         ~  -33.14%  -30.23%         ~  -20.74%
AddVW/words=2/data=carry             -6.36%         ~  -21.05%   -39.40%         ~   +10.72%  -29.12%  -31.34%         ~  -17.29%
AddVW/words=3/data=carry                  ~         ~  -17.46%   -19.53%   +17.58%         ~  -26.23%  -23.61%    +7.80%  -14.34%
AddVW/words=4/data=carry            +19.02%   +16.80%        ~         ~   +28.25%         ~  -27.90%  -20.31%   +19.16%        ~
AddVW/words=5/data=carry             +3.97%   +53.02%        ~         ~   +11.31%         ~  -19.05%  -17.47%   +16.81%        ~
AddVW/words=6/data=carry             +2.98%   +19.83%        ~         ~   +14.84%         ~  -18.48%  -14.92%   +18.25%        ~
AddVW/words=7/data=carry                  ~         ~        ~         ~   +27.17%         ~  -15.50%  -12.74%   +13.00%        ~
AddVW/words=8/data=carry             +0.58%   +22.32%        ~    +6.10%   +29.63%         ~  -13.04%        ~   +28.46%   +2.95%
AddVW/words=9/data=carry                  ~   +31.53%        ~         ~   +14.42%         ~  -11.32%        ~   +18.37%   +3.28%
AddVW/words=10/data=carry            +3.94%   +22.36%        ~    +6.29%   +19.22%         ~  -11.27%        ~   +20.10%   +3.91%
AddVW/words=16/data=carry            +2.82%   +14.23%        ~   +10.06%   +25.91%   -16.12%        ~        ~   +52.28%  +10.40%
AddVW/words=32/data=carry                 ~   +25.35%  +13.66%         ~   +34.89%   -34.39%   +6.51%  -18.71%   +41.06%  +19.42%
AddVW/words=64/data=carry           -42.03%         ~  -39.70%    +6.65%   +32.29%   -39.94%  +14.34%        ~   +19.68%  +20.86%
AddVW/words=100/data=carry          -33.95%   -34.28%  -39.65%         ~   +27.72%   -26.80%  +17.40%        ~   +26.39%  +23.32%
AddVW/words=1000/data=carry         -42.49%   -47.87%  -47.44%    +1.25%    +4.25%   -41.76%  +23.40%        ~   +25.48%  +27.99%
AddVW/words=10000/data=carry        -41.85%   -48.49%  -49.43%         ~         ~   -42.09%  +24.61%  -10.32%   +40.55%  +18.35%
AddVW/words=100000/data=carry       -28.18%   -48.13%  -48.24%    +1.35%         ~   -42.90%  +24.73%   -9.79%   +22.55%  +17.16%

SubVW/words=1/data=carry            -10.32%   -17.16%  -24.14%   -26.24%         ~   +18.43%  -34.10%  -29.54%    -9.57%        ~
SubVW/words=2/data=carry            -19.45%   -23.31%  -20.74%   -39.73%         ~   +15.74%  -28.13%  -30.21%         ~  -18.74%
SubVW/words=3/data=carry                  ~   -16.18%  -15.34%   -19.54%   +17.62%   +12.39%  -27.64%  -27.09%         ~  -14.97%
SubVW/words=4/data=carry            +11.67%   +24.42%        ~         ~   +25.11%   +14.07%  -28.08%  -26.18%         ~        ~
SubVW/words=5/data=carry             +8.08%   +25.64%        ~         ~   +10.35%    +8.12%  -21.75%  -25.50%         ~   -4.86%
SubVW/words=6/data=carry                  ~   +13.82%        ~         ~   +12.92%    +6.79%  -20.25%  -24.70%         ~   -2.74%
SubVW/words=7/data=carry                  ~         ~   +8.29%    +4.51%   +26.59%    +4.62%  -18.01%  -24.09%         ~   -1.26%
SubVW/words=8/data=carry                  ~   +23.16%  +16.19%    +6.16%   +25.46%    +6.74%  -15.57%  -22.74%         ~   +1.44%
SubVW/words=9/data=carry                  ~   +30.71%  +20.81%         ~   +12.36%         ~  -12.99%        ~         ~   +3.13%
SubVW/words=10/data=carry            +5.03%   +19.53%  +14.84%   +14.16%   +16.12%         ~  -11.64%  -16.00%   +15.45%   +3.29%
SubVW/words=16/data=carry           +14.42%   +15.58%  +33.07%   +11.43%   +24.65%         ~        ~  -21.90%   +25.59%   +9.40%
SubVW/words=32/data=carry                 ~   +27.57%  +46.58%         ~   +35.35%    -8.49%        ~  -24.04%   +11.86%  +18.40%
SubVW/words=64/data=carry           -24.34%   -27.83%  -20.90%   +13.34%   +37.17%   -14.90%        ~   -8.81%   +12.88%  +18.92%
SubVW/words=100/data=carry          -25.19%   -34.70%  -27.45%   +12.86%   +28.42%   -14.48%        ~        ~   +25.71%  +21.93%
SubVW/words=1000/data=carry         -24.93%   -47.86%  -47.26%    +2.66%         ~   -23.88%        ~        ~   +25.99%  +27.81%
SubVW/words=10000/data=carry        -24.17%   -36.48%  -49.41%    +1.06%         ~   -25.06%        ~  -26.50%   +27.94%  +18.36%
SubVW/words=100000/data=carry       -22.51%   -35.86%  -49.46%    +3.96%         ~   -25.18%        ~  -22.15%   +26.86%  +15.44%

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

4 months agomath/big: add more complete tests and benchmarks of assembly
Russ Cox [Sun, 30 Mar 2025 20:56:29 +0000 (16:56 -0400)]
math/big: add more complete tests and benchmarks of assembly

Also fix a few real but currently harmless bugs from CL 664895.
There were a few places that were still wrong if z != x or if a != 0.

Change-Id: Id8971e2505523bc4708780c82bf998a546f4f081
Reviewed-on: https://go-review.googlesource.com/c/go/+/664897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
4 months agoregexp/syntax: recognize category aliases like \p{Letter}
Russ Cox [Wed, 8 Jan 2025 16:27:07 +0000 (11:27 -0500)]
regexp/syntax: recognize category aliases like \p{Letter}

The Unicode specification defines aliases for some of the general
category names. For example the category "L" has alias "Letter".

The regexp package supports \p{L} but not \p{Letter}, because there
was nothing in the Unicode tables that lets regexp know about Letter.
Now that package unicode provides CategoryAliases (see #70780),
we can use it to provide \p{Letter} as well.

This is the only feature missing from making package regexp suitable
for use in a JSON-API Schema implementation. (The official test suite
includes usage of aliases like \p{Letter} instead of \p{L}.)

For better conformity with Unicode TR18, also accept case-insensitive
matches for names and ignore underscores, hyphens, and spaces;
and add Any, ASCII, and Assigned.

Fixes #70781.

Change-Id: I50ff024d99255338fa8d92663881acb47f1e92a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/641377
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
4 months agounicode: add CategoryAliases, Cn, LC
Russ Cox [Wed, 8 Jan 2025 16:21:30 +0000 (11:21 -0500)]
unicode: add CategoryAliases, Cn, LC

CategoryAliases is for regexp to use, for things like \p{Letter} as an alias for \p{L}.
Cn and LC are special-case categories that were never implemented
but should have been.

These changes were generated by the updated generator in CL 641395.

Fixes #70780.

Change-Id: Ibba20ff76191c8ae9631ac5ba19965790fe0cc81
Reviewed-on: https://go-review.googlesource.com/c/go/+/641376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
4 months agointernal/runtime/maps: move tombstone test to swiss file
Michael Pratt [Fri, 18 Apr 2025 10:23:33 +0000 (06:23 -0400)]
internal/runtime/maps: move tombstone test to swiss file

This test fails on GOEXPERIMENT=noswissmap as it is testing behavior
specific to swissmaps. Move it to map_swiss_test.go to skip it on
noswissmap.

We could also switch the test to use NewTestMap, which provides a
swissmap even in GOEXPERIMENT=noswissmap, but that is tedious to use and
noswissmap is going away soon anyway.

For #70886.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-noswissmap
Change-Id: I6a6a636c5ec72217d936cd01e9da36ae127ea2c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/666437
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agoencoding/json: add json/v2 with GOEXPERIMENT=jsonv2 guard
Damien Neil [Fri, 11 Apr 2025 21:19:51 +0000 (14:19 -0700)]
encoding/json: add json/v2 with GOEXPERIMENT=jsonv2 guard

This imports the proposed new v2 JSON API implemented in
github.com/go-json-experiment/json as of commit
d3c622f1b874954c355e60c8e6b6baa5f60d2fed.

When GOEXPERIMENT=jsonv2 is set, the encoding/json/v2 and
encoding/jsontext packages are visible, the encoding/json
package is implemented in terms of encoding/json/v2, and
the encoding/json package include various additional APIs.
(See #71497 for details.)

When GOEXPERIMENT=jsonv2 is not set, the new API is not
present and the encoding/json package is unchanged.

The experimental API is not bound by the Go compatibility
promise and is expected to evolve as updates are made to
the json/v2 proposal.

The contents of encoding/json/internal/jsontest/testdata
are compressed with zstd v1.5.7 with the -19 option.

Fixes #71845
For #71497

Change-Id: Ib8c94e5f0586b6aaa22833190b41cf6ef59f4f01
Reviewed-on: https://go-review.googlesource.com/c/go/+/665796
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
4 months agointernal,runtime: use the builtin clear
apocelipes [Thu, 17 Apr 2025 08:19:48 +0000 (08:19 +0000)]
internal,runtime: use the builtin clear

To simplify the code.

Change-Id: I023de705504c0b580718eec3c7c563b6cf2c8184
GitHub-Last-Rev: 026b32c799b13d0c7ded54f2e61429e6c5ed0aa8
GitHub-Pull-Request: golang/go#73412
Reviewed-on: https://go-review.googlesource.com/c/go/+/666118
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 months agocmd/compile: use the builtin clear
apocelipes [Thu, 17 Apr 2025 07:49:35 +0000 (07:49 +0000)]
cmd/compile: use the builtin clear

To simplify the code a bit.

Change-Id: Ia72f576de59ff161ec389a4992bb635f89783540
GitHub-Last-Rev: eaec8216be964418a085649fcca53a042f28ce1a
GitHub-Pull-Request: golang/go#73411
Reviewed-on: https://go-review.googlesource.com/c/go/+/666117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 months agointernal/poll: remove outdated tests
qmuntal [Mon, 14 Apr 2025 09:22:04 +0000 (11:22 +0200)]
internal/poll: remove outdated tests

TestFileFdsAreInitialised and TestSerialFdsAreInitialised were added
to ensure handles passed to os.NewFile were not added to the runtime
poller. This used to be problematic because the poller could crash
if an external I/O event was received (see #21172).

This is not an issue anymore since CL 482495 and #19098.

Change-Id: I292ceae27724fefe6f438a398ebfe351dd5231d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/665315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
4 months agointernal/runtime/maps: prune tombstones in maps before growing
Keith Randall [Tue, 7 Jan 2025 05:53:22 +0000 (21:53 -0800)]
internal/runtime/maps: prune tombstones in maps before growing

Before growing, if there are lots of tombstones try to remove them.
If we can remove enough, we can continue at the given size for a
while longer.

Fixes #70886

Change-Id: I71e0d873ae118bb35798314ec25e78eaa5340d73
Reviewed-on: https://go-review.googlesource.com/c/go/+/640955
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agodatabase/sql: wake cleaner if maxIdleTime set to less than maxLifetime
Philip Roberts [Thu, 9 Mar 2023 11:16:56 +0000 (11:16 +0000)]
database/sql: wake cleaner if maxIdleTime set to less than maxLifetime

The existing implementation wouldn't wake the connection cleaner if
maxIdleTime was set to a value less than maxLifetime while an existing
connection was open - resulting in idle connections not being discarded
until after the first maxLifetime had passed.

Fixes #45993

Change-Id: I074ed7ba9803354c8b3a41f2625ae0d8a7d5059b
GitHub-Last-Rev: 0d149d8d38bc9c2ad42a2a20dcfc73994d54fe23
GitHub-Pull-Request: golang/go#58490
Reviewed-on: https://go-review.googlesource.com/c/go/+/467655
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 months agocrypto/rand: add and update examples
Sean Liao [Sun, 13 Apr 2025 16:48:48 +0000 (17:48 +0100)]
crypto/rand: add and update examples

Change-Id: I77406c22b82c9f8bc57323c783f63c4897486e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/665096
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 months agonet/http: add test for proxyAuth
zxc111 [Tue, 11 May 2021 12:57:36 +0000 (12:57 +0000)]
net/http: add test for proxyAuth

Change-Id: Ib4edae749ce8da433e992e08a90c9cf3d4357081
GitHub-Last-Rev: 19d87d12ab6b299b37e8907429f4dff52ab53745
GitHub-Pull-Request: golang/go#46102
Reviewed-on: https://go-review.googlesource.com/c/go/+/318690
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agonet/url: clarify why @ is allowed in userinfo
1911860538 [Fri, 11 Apr 2025 15:14:11 +0000 (15:14 +0000)]
net/url: clarify why @ is allowed in userinfo

Add comment to clarify why '@' is allowed in validUserinfo func.

Change-Id: Ia9845bc40fea6c34093434d57bb1be4ddbc70b84
GitHub-Last-Rev: ce65168ab03afd879ad028de295f6adb7ee1c97d
GitHub-Pull-Request: golang/go#73195
Reviewed-on: https://go-review.googlesource.com/c/go/+/663455
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

4 months agocrypto/tls: fix a testing deadlock that occurs on a TLS protocol error
Eric Young [Fri, 3 Jun 2022 02:22:50 +0000 (02:22 +0000)]
crypto/tls: fix a testing deadlock that occurs on a TLS protocol error

A Go routine was, on an error, returning without sending a message on its
signaling channel, so the main program was blocking forever waiting for
a message that was never sent. Found while breaking crypto/tls.

Change-Id: Id0b3c070a27cabd852f74e86bb9eff5c66b86d28
GitHub-Last-Rev: 4d84fb8b556589ec98eba6142a553fbd45683b96
GitHub-Pull-Request: golang/go#53216
Reviewed-on: https://go-review.googlesource.com/c/go/+/410274
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agoall: use strings.ReplaceAll where applicable
Marcel Meyer [Mon, 14 Apr 2025 15:34:30 +0000 (15:34 +0000)]
all: use strings.ReplaceAll where applicable

```
find . \
-not -path './.git/*' \
-not -path './test/*' \
-not -path './src/cmd/vendor/*' \
-not -wholename './src/strings/example_test.go' \
-type f \
-exec \
sed -i -E 's/strings\.Replace\((.+), -1\)/strings\.ReplaceAll\(\1\)/g' {} \;
```

Change-Id: I59e2e91b3654c41a32f17dd91ec56f250198f0d6
GitHub-Last-Rev: 0868b1eccc945ca62a5ed0e56a4054994d4bd659
GitHub-Pull-Request: golang/go#73370
Reviewed-on: https://go-review.googlesource.com/c/go/+/665395
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
4 months agocrypto/cipher: use AEAD.NonceSize to make nonce in the example
najeira [Tue, 14 Sep 2021 04:47:41 +0000 (04:47 +0000)]
crypto/cipher: use AEAD.NonceSize to make nonce in the example

The existing example uses hard-coded constant to make nonce buffer.
Using AEAD.NonceSize makes it a more portable and appropriate example.

Fixes: #48372
Change-Id: I7c7a38ed48aff46ca11ef4f5654c778eac13dde6
GitHub-Last-Rev: 03ccbb16df4ca9cbd4a014836aee0f54b2ff3002
GitHub-Pull-Request: golang/go#48373
Reviewed-on: https://go-review.googlesource.com/c/go/+/349603
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Roland Shoemaker <roland@golang.org>