1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:24:47 -07:00
Commit Graph

61556 Commits

Author SHA1 Message Date
Rhys Hiltner
fd050b3c6d runtime: unify lock2, allow deeper sleep
The tri-state mutex implementation (unlocked, locked, sleeping) avoids
sleep/wake syscalls when contention is low or absent, but its
performance degrades when many threads are contending for a mutex to
execute a fast critical section.

A fast critical section means frequent unlock2 calls. Each of those
finds the mutex in the "sleeping" state and so wakes a sleeping thread,
even if many other threads are already awake and in the spin loop of
lock2 attempting to acquire the mutex for themselves. Many spinning
threads means wasting energy and CPU time that could be used by other
processes on the machine. Many threads all spinning on the same cache
line leads to performance collapse.

Merge the futex- and semaphore-based mutex implementations by using a
semaphore abstraction for futex platforms. Then, add a bit to the mutex
state word that communicates whether one of the waiting threads is awake
and spinning. When threads in lock2 see the new "spinning" bit, they can
sleep immediately. In unlock2, the "spinning" bit means we can save a
syscall and not wake a sleeping thread.

This brings up the real possibility of starvation: waiting threads are
able to enter a deeper sleep than before, since one of their peers can
volunteer to be the sole "spinning" thread and thus cause unlock2 to
skip the semawakeup call. Additionally, the waiting threads form a LIFO
stack so any wakeups that do occur will target threads that have gone to
sleep most recently. Counteract those effects by periodically waking the
thread at the bottom of the stack and allowing it to spin.

Exempt sched.lock from most of the new behaviors; it's often used by
several threads in sequence to do thread-specific work, so low-latency
handoff is a priority over improved throughput.

Gate use of this implementation behind GOEXPERIMENT=spinbitmutex, so
it's easy to disable. Enable it by default on supported platforms (the
most efficient implementation requires atomic.Xchg8).

Fixes #68578

    goos: linux
    goarch: amd64
    pkg: runtime
    cpu: 13th Gen Intel(R) Core(TM) i7-13700H
                                │      old       │                 new                  │
                                │     sec/op     │    sec/op     vs base                │
    MutexContention                 17.82n ±   0%   17.74n ±  0%   -0.42% (p=0.000 n=10)
    MutexContention-2               22.17n ±   9%   19.85n ± 12%        ~ (p=0.089 n=10)
    MutexContention-3               26.14n ±  14%   20.81n ± 13%  -20.41% (p=0.000 n=10)
    MutexContention-4               29.28n ±   8%   21.19n ± 10%  -27.62% (p=0.000 n=10)
    MutexContention-5               31.79n ±   2%   21.98n ± 10%  -30.83% (p=0.000 n=10)
    MutexContention-6               34.63n ±   1%   22.58n ±  5%  -34.79% (p=0.000 n=10)
    MutexContention-7               44.16n ±   2%   23.14n ±  7%  -47.59% (p=0.000 n=10)
    MutexContention-8               53.81n ±   3%   23.66n ±  6%  -56.04% (p=0.000 n=10)
    MutexContention-9               65.58n ±   4%   23.91n ±  9%  -63.54% (p=0.000 n=10)
    MutexContention-10              77.35n ±   3%   26.06n ±  9%  -66.31% (p=0.000 n=10)
    MutexContention-11              89.62n ±   1%   25.56n ±  9%  -71.47% (p=0.000 n=10)
    MutexContention-12             102.45n ±   2%   25.57n ±  7%  -75.04% (p=0.000 n=10)
    MutexContention-13             111.95n ±   1%   24.59n ±  8%  -78.04% (p=0.000 n=10)
    MutexContention-14             123.95n ±   3%   24.42n ±  6%  -80.30% (p=0.000 n=10)
    MutexContention-15             120.80n ±  10%   25.54n ±  6%  -78.86% (p=0.000 n=10)
    MutexContention-16             128.10n ±  25%   26.95n ±  4%  -78.96% (p=0.000 n=10)
    MutexContention-17             139.80n ±  18%   24.96n ±  5%  -82.14% (p=0.000 n=10)
    MutexContention-18             141.35n ±   7%   25.05n ±  8%  -82.27% (p=0.000 n=10)
    MutexContention-19             151.35n ±  18%   25.72n ±  6%  -83.00% (p=0.000 n=10)
    MutexContention-20             153.30n ±  20%   24.75n ±  6%  -83.85% (p=0.000 n=10)
    MutexHandoff/Solo-20            13.54n ±   1%   13.61n ±  4%        ~ (p=0.206 n=10)
    MutexHandoff/FastPingPong-20    141.3n ± 209%   164.8n ± 49%        ~ (p=0.436 n=10)
    MutexHandoff/SlowPingPong-20    1.572µ ±  16%   1.804µ ± 19%  +14.76% (p=0.015 n=10)
    geomean                         74.34n          30.26n        -59.30%

    goos: darwin
    goarch: arm64
    pkg: runtime
    cpu: Apple M1
                                │     old      │                 new                  │
                                │    sec/op    │    sec/op     vs base                │
    MutexContention               13.86n ±  3%   12.09n ±  3%  -12.73% (p=0.000 n=10)
    MutexContention-2             15.88n ±  1%   16.50n ±  2%   +3.94% (p=0.001 n=10)
    MutexContention-3             18.45n ±  2%   16.88n ±  2%   -8.54% (p=0.000 n=10)
    MutexContention-4             20.01n ±  2%   18.94n ± 18%        ~ (p=0.469 n=10)
    MutexContention-5             22.60n ±  1%   17.51n ±  9%  -22.50% (p=0.000 n=10)
    MutexContention-6             23.93n ±  2%   17.35n ±  2%  -27.48% (p=0.000 n=10)
    MutexContention-7             24.69n ±  1%   17.15n ±  3%  -30.54% (p=0.000 n=10)
    MutexContention-8             25.01n ±  1%   17.33n ±  2%  -30.69% (p=0.000 n=10)
    MutexHandoff/Solo-8           13.96n ±  4%   12.04n ±  4%  -13.78% (p=0.000 n=10)
    MutexHandoff/FastPingPong-8   68.89n ±  4%   64.62n ±  2%   -6.20% (p=0.000 n=10)
    MutexHandoff/SlowPingPong-8   9.698µ ± 22%   9.646µ ± 35%        ~ (p=0.912 n=10)
    geomean                       38.20n         32.53n        -14.84%

Change-Id: I0058c75eadf282d08eea7fce0d426f0518039f7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/620435
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
2024-11-15 21:16:04 +00:00
Rhys Hiltner
18c2461af3 runtime: allow futex OSes to use sema-based mutex
Implement sema{create,sleep,wakeup} in terms of the futex syscall when
available. Split the lock2/unlock2 implementations out of lock_sema.go
and lock_futex.go (which they shared with runtime.note) to allow
swapping in new implementations of those.

Let futex-based platforms use the semaphore-based mutex implementation.
Control that via the new "spinbitmutex" GOEXPERMENT value, disabled by
default.

This lays the groundwork for a "spinbit" mutex implementation; it does
not include the new mutex implementation.

For #68578.

Change-Id: I091289c85124212a87abec7079ecbd9e610b4270
Reviewed-on: https://go-review.googlesource.com/c/go/+/622996
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15 21:15:59 +00:00
Carlos Amedee
252e9def65 runtime: validate all calls to SetFinalizer
This change moves the check for a change in the memory management
system to after the SetFinalizer parameters have been validated.
Moving the check ensures that invalid parameters will never pass the
validation checks.

Change-Id: I9f1d3454f891f7b147c0d86b6720297172e08ef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/625035
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15 20:08:08 +00:00
Lin Lin
09f9b5e361 runtime: add race detector tips to reportZombies func
We can find a few issues finally turned out to be a race condition,
such as #47513. I believe such a tip can eliminate the need for developers
to file this kind of issue in the first place.

Change-Id: I1597fa09fde641882e8e87453470941747705272
GitHub-Last-Rev: 9f136f5b3b
GitHub-Pull-Request: golang/go#70331
Reviewed-on: https://go-review.googlesource.com/c/go/+/627816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-11-15 17:47:27 +00:00
Cherry Mui
a9afea969a crypto/internal/bigmod: add comparison test for addMulVVW
Sized addMulVVW (addMulVVW1024 etc.) have architecture-specific
implementations on a number of architectures. Add a test checking
that they match the generic implementation.

Change-Id: I574f00ad7cd27d4e1bf008561023f713876244f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/628256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2024-11-15 17:18:22 +00:00
Cherry Mui
5c534ef546 crypto/internal/bigmod: apply wasm-specific implementation for only sized addMulVVW
Restore generic addMulVVW for wasm (and therefore for all
architectures). Apply wasm-specific implementation for only the
explicitly sized functions (addMulVVW1024 etc.).

Also, for the sized functions, use unsafe pointer calculations
directly, without converting them back to slices. (This is what
the assembly code does on other architectures.) This results in a
bit more speedup for crypto/rsa benchmarks on Wasm:

pkg: crypto/rsa
                     │   old.txt   │              new.txt                │
                     │   sec/op    │   sec/op     vs base                │
DecryptPKCS1v15/2048   4.906m ± 0%   4.221m ± 1%  -13.96% (p=0.000 n=25)
DecryptPKCS1v15/3072   15.18m ± 0%   13.57m ± 0%  -10.64% (p=0.000 n=25)
DecryptPKCS1v15/4096   35.49m ± 0%   32.64m ± 1%   -8.04% (p=0.000 n=25)
EncryptPKCS1v15/2048   177.1µ ± 0%   162.3µ ± 0%   -8.35% (p=0.000 n=25)
DecryptOAEP/2048       4.900m ± 1%   4.233m ± 0%  -13.61% (p=0.000 n=25)
EncryptOAEP/2048       181.8µ ± 0%   166.8µ ± 0%   -8.24% (p=0.000 n=25)
SignPKCS1v15/2048      5.026m ± 1%   4.341m ± 0%  -13.63% (p=0.000 n=25)
VerifyPKCS1v15/2048    177.2µ ± 0%   161.3µ ± 1%   -8.97% (p=0.000 n=25)
SignPSS/2048           5.020m ± 0%   4.344m ± 1%  -13.47% (p=0.000 n=25)
VerifyPSS/2048         182.2µ ± 1%   166.6µ ± 0%   -8.52% (p=0.000 n=25)
geomean                1.791m        1.598m       -10.78%

Change-Id: I89775c46a0bbe29380889047ba393c6cfc093ff1
Reviewed-on: https://go-review.googlesource.com/c/go/+/628255
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-11-15 17:18:17 +00:00
Jorropo
e30ce3c498 sync/atomic: make intrinsics noescape except 64bits op on 32bits arch and unsafe.Pointer
Fixes #16241

I made 64 bits op on 32 bits arches still leak since it was kinda promised.

The promised leaks were wider than this but I don't belive it's effect can
be observed in an breaking maner without using unsafe the way it's currently
setup.

Change-Id: I66d8df47bfe49bce3efa64ac668a2a55f70733a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/462298
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-15 17:11:46 +00:00
Sam Thanawalla
956d4bb9cf cmd/go: add user provided auth mode for GOAUTH
This CL adds support for a custom authenticator as a valid GOAUTH command.
This follows the specification in
https://go.dev/issue/26232#issuecomment-461525141

For #26232

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Id1d4b309f11eb9c7ce14793021a9d8caf3b192ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/605298
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15 16:47:09 +00:00
Sam Thanawalla
5030146cfd cmd/go: add bzr based version stamping for binaries
This CL adds support for tagging binaries in a bzr vcs environment.

For: #50603
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I81eb72d9e0e15dbec8778dd06613ca212820a726
Reviewed-on: https://go-review.googlesource.com/c/go/+/627295
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15 16:46:42 +00:00
Cherry Mui
400433af36 doc/next: pre-announce dropping macOS 11 support
Go 1.24 is the last release that will run on macOS 11 Big Sur.
Go 1.25 will require macOS 12 Monterey or later.

For #69839.
For #23011.

Change-Id: Ic58beff0f7eb69f600add5c17cf6edd960d09980
Reviewed-on: https://go-review.googlesource.com/c/go/+/627616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-11-15 16:11:06 +00:00
qmuntal
60d66e6a86 os/user: support built-in service user accounts on Windows
Built-in service user accounts should be treated as special cases
of well-known groups and allowed in user.Lookup and user.LookupId.

Namely, these accounts are:
- NT AUTHORITY\SYSTEM (S-1-5-18)
- NT AUTHORITY\LOCAL SERVICE (S-1-5-19)
- NT AUTHORITY\NETWORK SERVICE (S-1-5-20)

See https://learn.microsoft.com/en-us/windows/win32/services/service-user-accounts.

Note that #49509 also mentions S-1-5-17 (NT AUTHORITY\IUSR) as
another well-known group that should be treated as a user. I haven't
found any documentation supporting this claim, and it is not an account
that is used usually, so I'm not adding it for now.

This CL is heavily based on CL 452497.

Fixes #49509

Change-Id: I6e204ddfb4ed0c01b4503001cf284602531e4a88
Reviewed-on: https://go-review.googlesource.com/c/go/+/626255
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-11-15 16:10:50 +00:00
Russ Cox
dea12628e6 cmd/compile/internal/staticinit: remove FIPS debugging
This is panicking on the darwin-amd64-longtest builders.
Not sure why, but it was added only to get a stack trace
during debugging. If there's still a problem, we should let
it proceed and find the real problem.

The test that was failing - internal/coverage/cfile - passes
with this CL, even when I set GODEBUG=fips140=on,
so there's hope that it will fix the longtest builders.

Change-Id: I9b3e743effdddcc0a76895922f87631527781dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/628375
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15 16:06:27 +00:00
Russ Cox
ad6bc88e07 crypto/internal/fips: make linknames path-independent
When using a FIPS140 snapshot, the import paths will have
FIPS version numbers in them, so use explicit import paths
for coordination with package runtime, which expects
crypto/internal/fips, not (say) crypto/internal/fips/v1.1.

Change-Id: I3ac48c84810493152e039eaa5f44d7cfe13d35f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/627915
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-11-15 15:49:36 +00:00
Russ Cox
534551d55a crypto/internal/fips/check: fix for ASAN builds
For now, FIPS does not work with ASAN: ASAN detects reads
it doesn't like during the scans of memory done by verification.
It could be made to work if there was a way to disable ASAN
during verification, but that doesn't appear to be possible.

Instead of a cryptic ASAN message, panic with a clear error.
And disable the test during ASAN.

Fixes #70321.

Change-Id: Ibc3876836abb83248a23c18c3b44c4cbb4a0c600
Reviewed-on: https://go-review.googlesource.com/c/go/+/627603
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-15 15:49:34 +00:00
Jakub Ciolek
102d031a58 internal/fuzz: add benchmarks for byte slice mutators
Cover each byte slice mutation function in a benchmark.
Grants visibility into the cost of each transformation
and allows us to perform informed optimization.

Results on go1.23/Intel Alder Lake i5-12600K (n=16):

name                                                  time/op
ByteSliceMutators/RemoveBytes/64-16                   14.8ns ± 0%
ByteSliceMutators/RemoveBytes/128-16                  14.6ns ± 0%
ByteSliceMutators/RemoveBytes/256-16                  14.7ns ± 0%
ByteSliceMutators/RemoveBytes/512-16                  17.0ns ± 0%
ByteSliceMutators/RemoveBytes/1024-16                 18.3ns ± 0%
ByteSliceMutators/InsertRandomBytes/64-16             9.88ns ± 0%
ByteSliceMutators/InsertRandomBytes/128-16            9.88ns ± 1%
ByteSliceMutators/InsertRandomBytes/256-16            9.87ns ± 0%
ByteSliceMutators/InsertRandomBytes/512-16            9.88ns ± 0%
ByteSliceMutators/InsertRandomBytes/1024-16           9.87ns ± 0%
ByteSliceMutators/DuplicateBytes/64-16                12.4ns ± 0%
ByteSliceMutators/DuplicateBytes/128-16               12.3ns ± 0%
ByteSliceMutators/DuplicateBytes/256-16               12.3ns ± 0%
ByteSliceMutators/DuplicateBytes/512-16               12.3ns ± 0%
ByteSliceMutators/DuplicateBytes/1024-16              12.3ns ± 0%
ByteSliceMutators/OverwriteBytes/64-16                17.5ns ± 0%
ByteSliceMutators/OverwriteBytes/128-16               17.3ns ± 0%
ByteSliceMutators/OverwriteBytes/256-16               17.1ns ± 0%
ByteSliceMutators/OverwriteBytes/512-16               17.0ns ± 0%
ByteSliceMutators/OverwriteBytes/1024-16              17.0ns ± 0%
ByteSliceMutators/BitFlip/64-16                       5.06ns ± 1%
ByteSliceMutators/BitFlip/128-16                      5.07ns ± 1%
ByteSliceMutators/BitFlip/256-16                      5.07ns ± 1%
ByteSliceMutators/BitFlip/512-16                      5.07ns ± 0%
ByteSliceMutators/BitFlip/1024-16                     5.06ns ± 1%
ByteSliceMutators/XORByte/64-16                       5.33ns ± 1%
ByteSliceMutators/XORByte/128-16                      5.30ns ± 1%
ByteSliceMutators/XORByte/256-16                      5.29ns ± 1%
ByteSliceMutators/XORByte/512-16                      5.29ns ± 1%
ByteSliceMutators/XORByte/1024-16                     5.29ns ± 1%
ByteSliceMutators/SwapByte/64-16                      5.75ns ± 0%
ByteSliceMutators/SwapByte/128-16                     5.70ns ± 0%
ByteSliceMutators/SwapByte/256-16                     5.67ns ± 0%
ByteSliceMutators/SwapByte/512-16                     5.67ns ± 1%
ByteSliceMutators/SwapByte/1024-16                    5.67ns ± 0%
ByteSliceMutators/ArithmeticUint8/64-16               9.55ns ± 0%
ByteSliceMutators/ArithmeticUint8/128-16              9.56ns ± 0%
ByteSliceMutators/ArithmeticUint8/256-16              9.57ns ± 0%
ByteSliceMutators/ArithmeticUint8/512-16              9.56ns ± 0%
ByteSliceMutators/ArithmeticUint8/1024-16             9.56ns ± 0%
ByteSliceMutators/ArithmeticUint16/64-16              13.2ns ± 0%
ByteSliceMutators/ArithmeticUint16/128-16             13.2ns ± 0%
ByteSliceMutators/ArithmeticUint16/256-16             13.2ns ± 0%
ByteSliceMutators/ArithmeticUint16/512-16             13.2ns ± 0%
ByteSliceMutators/ArithmeticUint16/1024-16            13.2ns ± 0%
ByteSliceMutators/ArithmeticUint32/64-16              13.4ns ± 0%
ByteSliceMutators/ArithmeticUint32/128-16             13.4ns ± 0%
ByteSliceMutators/ArithmeticUint32/256-16             13.4ns ± 0%
ByteSliceMutators/ArithmeticUint32/512-16             13.4ns ± 0%
ByteSliceMutators/ArithmeticUint32/1024-16            13.4ns ± 0%
ByteSliceMutators/ArithmeticUint64/64-16              13.4ns ± 0%
ByteSliceMutators/ArithmeticUint64/128-16             13.5ns ± 0%
ByteSliceMutators/ArithmeticUint64/256-16             13.5ns ± 0%
ByteSliceMutators/ArithmeticUint64/512-16             13.5ns ± 0%
ByteSliceMutators/ArithmeticUint64/1024-16            13.5ns ± 0%
ByteSliceMutators/OverwriteInterestingUint8/64-16     5.39ns ± 2%
ByteSliceMutators/OverwriteInterestingUint8/128-16    5.38ns ± 1%
ByteSliceMutators/OverwriteInterestingUint8/256-16    5.37ns ± 1%
ByteSliceMutators/OverwriteInterestingUint8/512-16    5.41ns ± 2%
ByteSliceMutators/OverwriteInterestingUint8/1024-16   5.38ns ± 0%
ByteSliceMutators/OverwriteInterestingUint16/64-16    10.7ns ± 0%
ByteSliceMutators/OverwriteInterestingUint16/128-16   10.7ns ± 0%
ByteSliceMutators/OverwriteInterestingUint16/256-16   10.7ns ± 0%
ByteSliceMutators/OverwriteInterestingUint16/512-16   10.7ns ± 0%
ByteSliceMutators/OverwriteInterestingUint16/1024-16  10.7ns ± 0%
ByteSliceMutators/OverwriteInterestingUint32/64-16    10.9ns ± 0%
ByteSliceMutators/OverwriteInterestingUint32/128-16   10.9ns ± 0%
ByteSliceMutators/OverwriteInterestingUint32/256-16   10.9ns ± 0%
ByteSliceMutators/OverwriteInterestingUint32/512-16   10.9ns ± 0%
ByteSliceMutators/OverwriteInterestingUint32/1024-16  10.9ns ± 0%
ByteSliceMutators/InsertConstantBytes/64-16           10.1ns ± 0%
ByteSliceMutators/InsertConstantBytes/128-16          10.1ns ± 0%
ByteSliceMutators/InsertConstantBytes/256-16          10.1ns ± 0%
ByteSliceMutators/InsertConstantBytes/512-16          10.1ns ± 0%
ByteSliceMutators/InsertConstantBytes/1024-16         10.1ns ± 0%
ByteSliceMutators/OverwriteConstantBytes/64-16        18.7ns ± 0%
ByteSliceMutators/OverwriteConstantBytes/128-16       18.8ns ± 0%
ByteSliceMutators/OverwriteConstantBytes/256-16       18.8ns ± 0%
ByteSliceMutators/OverwriteConstantBytes/512-16       19.0ns ± 0%
ByteSliceMutators/OverwriteConstantBytes/1024-16      19.3ns ± 0%
ByteSliceMutators/ShuffleBytes/64-16                  24.5ns ± 0%
ByteSliceMutators/ShuffleBytes/128-16                 25.4ns ± 0%
ByteSliceMutators/ShuffleBytes/256-16                 26.6ns ± 0%
ByteSliceMutators/ShuffleBytes/512-16                 28.2ns ± 0%
ByteSliceMutators/ShuffleBytes/1024-16                33.3ns ± 0%
ByteSliceMutators/SwapBytes/64-16                     16.2ns ± 1%
ByteSliceMutators/SwapBytes/128-16                    15.8ns ± 0%
ByteSliceMutators/SwapBytes/256-16                    15.5ns ± 0%
ByteSliceMutators/SwapBytes/512-16                    15.4ns ± 0%
ByteSliceMutators/SwapBytes/1024-16                   15.3ns ± 0%
[Geo mean]                                            11.0ns

Note that implementing this via a single parent benchmark function
adds an overhead of about 1-8%, but that should be acceptable and
results in more concise code.

Change-Id: Ifa2693f8fc8c2058513a615208d0d6862efd3617
Reviewed-on: https://go-review.googlesource.com/c/go/+/623895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-11-15 15:25:12 +00:00
Filippo Valsorda
f61c2603e9 crypto/internal/fips/check: enable windows/arm64
Looks like it works.

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64
Change-Id: I4914d5076eccaf1dd850a148070f179edf291c40
Reviewed-on: https://go-review.googlesource.com/c/go/+/627958
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2024-11-15 14:34:48 +00:00
Paul E. Murphy
f99f5da18f cmd/internal/obj/fips: mark R_ADDRPOWR_GOT as a pcrel relocation
It's actually a TOC relative relocation, but those are also accepted
as pcrel relocations here too. This fixes compilation on GOPPC64 <= power9.

Change-Id: I235125a76f59ab26c6c753540cfaeb398f9c105d
Reviewed-on: https://go-review.googlesource.com/c/go/+/628157
Auto-Submit: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-14 22:29:26 +00:00
Carlana Johnson
3d61de41a2 log/slog: add DiscardHandler
This adds a package-level variable, slog.DiscardHandler, which is a
slog.Handler which performs no output. This serves a similar purpose
to io.Discard.

Fixes #62005

Change-Id: Ia8babc55f860dec9b663a5c400090a7669608fd5
GitHub-Last-Rev: 0a611174ee
GitHub-Pull-Request: golang/go#70296
Reviewed-on: https://go-review.googlesource.com/c/go/+/626486
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 22:27:09 +00:00
Tim King
cd35323be9 internal/exportdata: introduce shared library for exportdata
Deduplicates FindPkg and FindExportData which were shared by
go/internal/gcimporter and cmd/compile/internal/importer into
a new package internal/exportdata.

This change only moves code.

Change-Id: I1daf24dd79fafbe9014b2b15671dcde46b54711e
Reviewed-on: https://go-review.googlesource.com/c/go/+/626700
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 22:20:26 +00:00
Rhys Hiltner
9fe70bcd65 runtime: add test for mutex starvation
When multiple threads all need to acquire the same runtime.mutex, make
sure that none of them has to wait for too long. Measure how long a
single thread can capture the mutex, and how long individual other
threads must go between having a turn with the mutex.

For #68578

Change-Id: I56ecc551232f9c2730c128a9f8eeb7bd45c2d3b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/622995
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-14 22:05:16 +00:00
Tim King
c79a486be2 cmd/compile/internal/importer: minimize Import differences
Minimizes the differences with go/internal/gcimporter.Import.

Note that the copy in cmd/compile/internal/importer is currently
only used in tests.

The delta between the two Import functions is now just types vs types2.

Change-Id: I5e94d3aa5bbdb78252e47310c95807f63e27ef3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/626698
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 21:58:26 +00:00
Robert Griesemer
c9ac589853 cmd/compile/internal/types2: enable disabled part of an example test (cleanup)
Change-Id: I8ffb198d64ec1b89e6d13bfa299bf699f1ca3830
Reviewed-on: https://go-review.googlesource.com/c/go/+/628156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2024-11-14 21:07:44 +00:00
Tim King
4003ee79d0 go/internal/gcimporter,cmd/compile/internal/importer: reuse archive.ReadHeader
Reuse (or copy) cmd/internal/archive.ReadHeader in importers.

Change-Id: I3caa19b1b366c2bbffcdeb0ef4db337ee457b47e
Reviewed-on: https://go-review.googlesource.com/c/go/+/626776
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-11-14 21:03:19 +00:00
Jorropo
672a53def7 strconv: cleanup old compiler bits.TrailingZeros workaround
Since CL 599096 the compiler knows bits.TrailingZeros's maximum value
based on the input type size.

Since CL 603996 it knows it based on input's maximum value.

Change-Id: Ib0d6b15a3ba6894d3e7e12b79b387ddbffabe370
Reviewed-on: https://go-review.googlesource.com/c/go/+/618715
Auto-Submit: Robert Griesemer <gri@google.com>
Commit-Queue: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2024-11-14 18:20:19 +00:00
Richard Miller
a763084ed2 make.rc: correct test for undefined GOROOT_BOOTSTRAP
The test "if(! ~ $#GOROOT_BOOTSTRAP 1)", to check for the environment
variable GOROOT_BOOTSTRAP being undefined, will not succeed if the
variable is set to the empty string (as the coordinator was doing).
A better test is "if(~ $"GOROOT_BOOTSTRAP '')", which succeeds if
the variable is undefined, or set to an empty list or an empty string.

For #69038

Change-Id: Ic6e6944e0c76461daea206ba9575b863f92f6228
Reviewed-on: https://go-review.googlesource.com/c/go/+/627944
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-14 18:02:59 +00:00
qiulaidongfeng
cce90c1eeb cmd/go: print not-defaults arch-env
Fixes #67492
For #34208

Change-Id: Idcddf88aad8e18b0274ce8e2ff8a83d57db603a6
GitHub-Last-Rev: 8ef7cf59d0
GitHub-Pull-Request: golang/go#67493
Reviewed-on: https://go-review.googlesource.com/c/go/+/586241
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 17:25:22 +00:00
qmuntal
3f0b293e70 runtime/cgo: report a meaningful error message when using Cygwin
Go has never supported Cygwin as a C compiler, but users get the
following cryptic error message when they try to use it:

    implicit declaration of function '_beginthread'

This is because Cygwin doesn't implement _beginthread. Note that
this is not the only problem with Cygwin, but it's the one that
users are most likely to run into first.

This CL improves the error message to make it clear that Cygwin
is not supported, and suggests using MinGW instead.

Fixes #59490
Fixes #36691

Change-Id: Ifeec7a2cb38d7c5f50d6362c95504f72818c6a76
Reviewed-on: https://go-review.googlesource.com/c/go/+/627935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-14 17:24:38 +00:00
lugen4ro
8e714281e4 embed: remove incorrect slash in comment
Change-Id: Ida74e8127c29d3e6f0a4322f86c7963fa2ef8244
GitHub-Last-Rev: ae479155d6
GitHub-Pull-Request: golang/go#70330
Reviewed-on: https://go-review.googlesource.com/c/go/+/627815
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 16:08:01 +00:00
Flavio Castelli
8b0ac33da8 syscall: define EBADFD for wasip1 target
Fixes #60998

Change-Id: I7e899708c7e0406bd9927eb411b57fc3240b7f18
GitHub-Last-Rev: c1a20aee0e
GitHub-Pull-Request: golang/go#60999
Reviewed-on: https://go-review.googlesource.com/c/go/+/506175
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 16:05:15 +00:00
Jes Cok
eb1e505f3f runtime: make Frames example produce documented output
I believe now this code can work in both test and standalone situations.

Fixes #70057

Change-Id: Ieb5163e6b917fd03d050f65589df6c31ad2515fe
GitHub-Last-Rev: db4863c05e
GitHub-Pull-Request: golang/go#70270
Reviewed-on: https://go-review.googlesource.com/c/go/+/625904
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-14 15:25:17 +00:00
Austin Clements
d31d77a263 cmd/go: remove confusing TrimPrefix(str, "\n")
It's not clear why strings here would have a *prefix* \n. This trim
was introduced back in March 2012 without explanation in omnibus
commit b03a5f66e8 (as a HasPrefix, since
we didn't have TrimPrefix at the time).

Change-Id: Ib0a7af36900e437fdc52ec5c1c921f92833f6cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/558638
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 15:22:44 +00:00
Russ Cox
673a539170 cmd/go: code cleanups and go env output sorting
Sort the table of variables in the envcmd source code,
because all tables in all source code should be sorted
unless there's a reason they can't be.

Sort the go env output as well.

Sort the flag registrations, same reason.

Remove redundant range variable.

Change-Id: I5f1af3e22a09621706eb57c369bd2675b754b063
Reviewed-on: https://go-review.googlesource.com/c/go/+/627476
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 06:16:01 +00:00
Russ Cox
6c841e4640 all: enable FIPS verification code
Previous CLs committed changes to cmd/compile, cmd/link,
and crypto/internal/fips/check behind boolean flags.
Turn those flags on, to enable the CLs.

This is a separate, trivial CL for easier rollback.

For #69536.

Change-Id: I68206bae0b7d7ad5c8758267d1a2e68853b63644
Reviewed-on: https://go-review.googlesource.com/c/go/+/626000
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-14 05:50:37 +00:00
Robert Griesemer
2eac154b1c cmd/compile: better error message when offending/missing token is a keyword
Prefix keywords (type, default, case, etc.) with "keyword" in error
messages to make them less ambiguous.

Fixes #68589.

Change-Id: I1eb92d1382f621b934167b3a4c335045da26be9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/623819
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-11-14 02:14:13 +00:00
Cherry Mui
3730814f2f crypto/internal/bigmod: optimize addMulVVW on Wasm
The current implementation of addMulVVW makes heavy use of
64x64->128 bit multiplications and 64-bit add-with-carry, which
are compiler intrinsics and are very efficient on many
architectures. However, those are not supported on Wasm. Here we
implement it with 32x32->64 bit operations, which is more
efficient on Wasm.

crypto/rsa benchmarks with Node:

                     │   old.txt   │              new.txt                │
                     │   sec/op    │   sec/op     vs base                │
DecryptPKCS1v15/2048   7.726m ± 1%   4.895m ± 2%  -36.65% (p=0.000 n=35)
DecryptPKCS1v15/3072   23.52m ± 1%   15.33m ± 1%  -34.83% (p=0.000 n=35)
DecryptPKCS1v15/4096   52.64m ± 2%   35.40m ± 1%  -32.75% (p=0.000 n=35)
EncryptPKCS1v15/2048   264.2µ ± 1%   176.9µ ± 1%  -33.02% (p=0.000 n=35)
DecryptOAEP/2048       7.608m ± 1%   4.911m ± 1%  -35.45% (p=0.000 n=35)
EncryptOAEP/2048       266.2µ ± 0%   183.3µ ± 2%  -31.15% (p=0.000 n=35)
SignPKCS1v15/2048      7.836m ± 1%   5.009m ± 2%  -36.08% (p=0.000 n=35)
VerifyPKCS1v15/2048    262.9µ ± 1%   176.3µ ± 1%  -32.94% (p=0.000 n=35)
SignPSS/2048           7.814m ± 0%   5.020m ± 1%  -35.76% (p=0.000 n=35)
VerifyPSS/2048         267.0µ ± 1%   183.8µ ± 1%  -31.17% (p=0.000 n=35)
geomean                2.718m        1.794m       -34.01%

With wazero:

                     │    old.txt   │              new.txt                │
                     │    sec/op    │   sec/op     vs base                │
DecryptPKCS1v15/2048   13.445m ± 0%   6.528m ± 0%  -51.45% (p=0.000 n=25)
DecryptPKCS1v15/3072    41.07m ± 0%   18.85m ± 0%  -54.10% (p=0.000 n=25)
DecryptPKCS1v15/4096    91.84m ± 1%   39.66m ± 0%  -56.81% (p=0.000 n=25)
EncryptPKCS1v15/2048    461.3µ ± 0%   197.2µ ± 0%  -57.25% (p=0.000 n=25)
DecryptOAEP/2048       13.438m ± 0%   6.577m ± 0%  -51.06% (p=0.000 n=25)
EncryptOAEP/2048        471.5µ ± 0%   207.7µ ± 0%  -55.95% (p=0.000 n=25)
SignPKCS1v15/2048      13.739m ± 0%   6.687m ± 0%  -51.33% (p=0.000 n=25)
VerifyPKCS1v15/2048     461.3µ ± 1%   196.8µ ± 0%  -57.35% (p=0.000 n=25)
SignPSS/2048           13.765m ± 0%   6.686m ± 0%  -51.43% (p=0.000 n=25)
VerifyPSS/2048          470.8µ ± 0%   208.9µ ± 1%  -55.64% (p=0.000 n=25)
geomean                 4.769m        2.179m       -54.31%

Change-Id: I97f37d8cf1e3e9756a4e03ab4e681bf04152925f
Reviewed-on: https://go-review.googlesource.com/c/go/+/626957
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-13 20:44:08 +00:00
Cherry Mui
4ffa2aecc1 cmd/internal/obj/wasm: correct return PC for frameless wasmexport wrappers
For a wasmexport wrapper, we generate a call to the actual
exported Go function, and use the wrapper function's PC 1 as the
(fake) return address. This address is not used for returning,
which is handled by the Wasm call stack. It is used for stack
unwinding, and PC 1 makes it past the prologue and therefore has
the right SP delta. But if the function has no arguments and
results, the wrapper is frameless, with no prologue, and PC 1
doesn't exist. This causes the unwinder to fail. In this case, we
put PC 0, which also has the correct SP delta (0).

Fixes #69584.

Change-Id: Ic047a6e62100db540b5099cc5a56a1d0f16d58b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/624000
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-13 20:09:36 +00:00
Russ Cox
26e1010372 cmd/dist: add more pie tests, fips tests
Check the various pie combinations with the new FIPS code.

For #69536.

Change-Id: I8fc771eab465c4af46a0ec8154d550c1bf95f7d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/625999
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-13 19:57:45 +00:00
Robert Griesemer
66b6b174b6 go/types, types2: avoid errors due to missing methods for invalid types
Don't report a (follow-on) error if a method is not found in a type
due to a prior error that made the type invalid, or which caused an
embedded field of a struct to have an invalid type (and thus one
cannot with certainty claim that a method is missing).

Fixes #53535.

Change-Id: Ib2879c6b3b9d927c93bbbf1d355397dd19f336f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/626997
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-11-13 19:41:32 +00:00
Brad Fitzpatrick
83a7626687 cmd/go: enable GOCACHEPROG by default, without GOEXPERIMENT
Fixes #64876

Change-Id: I2c0e1ed22f8e13d00dfb5fededbc84038cd7ff8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/626035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-11-13 19:09:01 +00:00
Sean Liao
4310502385 testing/slogtest: reuse results obtained from previous call
Fixes #67605

Change-Id: Ib48ddfabb93887c88bfca347ba2e5f3c4b4e90b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/599836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-11-13 19:03:44 +00:00
Sean Liao
d7ea9ff50b runtime/pprof: note different between go test -memprofile and WriteHeapProfile
Fixes #65328

Change-Id: I11242be93a95e117a6758ac037e143c3b38aa71c
Reviewed-on: https://go-review.googlesource.com/c/go/+/597980
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-11-13 19:02:55 +00:00
Michael Anthony Knyszek
80d306da50 runtime: prevent weak->strong conversions during mark termination
Currently it's possible for weak->strong conversions to create more GC
work during mark termination. When a weak->strong conversion happens
during the mark phase, we need to mark the newly-strong pointer, since
it may now be the only pointer to that object. In other words, the
object could be white.

But queueing new white objects creates GC work, and if this happens
during mark termination, we could end up violating mark termination
invariants. In the parlance of the mark termination algorithm, the
weak->strong conversion is a non-monotonic source of GC work, unlike the
write barriers (which will eventually only see black objects).

This change fixes the problem by forcing weak->strong conversions to
block during mark termination. We can do this efficiently by setting a
global flag before the ragged barrier that is checked at each
weak->strong conversion. If the flag is set, then the conversions block.
The ragged barrier ensures that all Ps have observed the flag and that
any weak->strong conversions which completed before the ragged barrier
have their newly-minted strong pointers visible in GC work queues if
necessary. We later unset the flag and wake all the blocked goroutines
during the mark termination STW.

There are a few subtleties that we need to account for. For one, it's
possible that a goroutine which blocked in a weak->strong conversion
wakes up only to find it's mark termination time again, so we need to
recheck the global flag on wake. We should also stay non-preemptible
while performing the check, so that if the check *does* appear as true,
it cannot switch back to false while we're actively trying to block. If
it switches to false while we try to block, then we'll be stuck in the
queue until the following GC.

All-in-all, this CL is more complicated than I would have liked, but
it's the only idea so far that is clearly correct to me at a high level.

This change adds a test which is somewhat invasive as it manipulates
mark termination, but hopefully that infrastructure will be useful for
debugging, fixing, and regression testing mark termination whenever we
do fix it.

Fixes #69803.

Change-Id: Ie314e6fd357c9e2a07a9be21f217f75f7aba8c4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/623615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-13 18:52:12 +00:00
Constantin Konstantinidis
f1add18530 testing: replace CRLF by LF on windows before comparing to the expected output
Fixes #51269

Change-Id: I06747db18ca078c1f1bda9b7bc60006f53191f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/627035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-13 18:37:25 +00:00
David Chase
d311cc95dc cmd/compile: change status of "bad iterator" panic
Execution of the loop body previously either terminated
the iteration (returned false because of a break, goto, or
return) or actually panicked.  The check against abi.RF_READY
ensures that the body can no longer run and also panics.

This CL in addition transitions the loop state to abi.RF_PANIC
so that if this already badly-behaved iterator defer-recovers
this panic, then the exit check at the loop context will
catch the problem and panic there.

Previously, panics triggered by attempted execution of a
no-longer active loop would not trigger a panic at the loop
context if they were defer-recovered.

Change-Id: Ieeed2fafd0d65edb66098dc27dc9ae8c1e6bcc8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/625455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-11-13 18:30:21 +00:00
Michael Pratt
7c40544441 internal/runtime/maps: use match to skip non-full slots in iteration
Iteration over swissmaps with low load (think map with large hint but
only one entry) is signicantly regressed vs old maps. See noswiss vs
swiss-tip below (+60%).

Currently we visit every single slot and individually check if the slot
is full or not.

We can do much better by using the control word to find all full slots
in a group in a single operation. This lets us skip completely empty
groups for instance.

Always using the control match approach is great for maps with low load,
but is a regression for mostly full maps. Mostly full maps have the
majority of slots full, so most calls to mapiternext will return the
next slot. In that case, doing the full group match on every call is
more expensive than checking the individual slot.

Thus we take a hybrid approach: on each call, we first check an
individual slot. If that slot is full, we're done. If that slot is
non-full, then we fall back to doing full group matches.

This trade-off works well. Both mostly empty and mostly full maps
perform nearly as well as doing all matching and all individual,
respectively.

The fast path is placed above the slow path loop rather than combined
(with some sort of `useMatch` variable) into a single loop to help the
compiler's code generation. The compiler really struggles with code
generation on a combined loop for some reason, yielding ~15% additional
instructions/op.

Comparison with old maps prior to this CL:

                                                 │    noswiss    │              swiss-tip               │
                                                 │    sec/op     │    sec/op      vs base               │
MapIter/Key=int64/Elem=int64/len=6-12               11.53n ±  2%    10.64n ±  2%   -7.72% (p=0.002 n=6)
MapIter/Key=int64/Elem=int64/len=64-12             10.180n ±  2%    9.670n ±  5%   -5.01% (p=0.004 n=6)
MapIter/Key=int64/Elem=int64/len=65536-12           10.78n ±  1%    10.15n ±  2%   -5.84% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=6-12        6.116n ±  2%    6.840n ±  2%  +11.84% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=64-12       2.403n ±  2%    3.892n ±  0%  +61.95% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=65536-12    1.940n ±  3%    3.237n ±  1%  +66.81% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=6-12                66.20n ±  2%    60.14n ±  3%   -9.15% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=64-12               97.24n ±  1%   171.35n ±  1%  +76.21% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=65536-12            826.1n ± 12%    842.5n ± 10%        ~ (p=0.937 n=6)
geomean                                             17.93n          20.96n        +16.88%

After this CL:

                                                 │    noswiss    │              swiss-cl               │
                                                 │    sec/op     │    sec/op     vs base               │
MapIter/Key=int64/Elem=int64/len=6-12               11.53n ±  2%    10.90n ± 3%   -5.42% (p=0.002 n=6)
MapIter/Key=int64/Elem=int64/len=64-12             10.180n ±  2%    9.719n ± 9%   -4.53% (p=0.043 n=6)
MapIter/Key=int64/Elem=int64/len=65536-12           10.78n ±  1%    10.07n ± 2%   -6.63% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=6-12        6.116n ±  2%    7.022n ± 1%  +14.82% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=64-12       2.403n ±  2%    1.475n ± 1%  -38.63% (p=0.002 n=6)
MapIterLowLoad/Key=int64/Elem=int64/len=65536-12    1.940n ±  3%    1.210n ± 6%  -37.67% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=6-12                66.20n ±  2%    61.54n ± 2%   -7.02% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=64-12               97.24n ±  1%   110.10n ± 1%  +13.23% (p=0.002 n=6)
MapPop/Key=int64/Elem=int64/len=65536-12            826.1n ± 12%    504.7n ± 6%  -38.91% (p=0.002 n=6)
geomean                                             17.93n          15.29n       -14.74%

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10
Change-Id: Ic07f9df763239e85be57873103df5007144fdaef
Reviewed-on: https://go-review.googlesource.com/c/go/+/627156
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-11-13 18:14:17 +00:00
Michael Pratt
6e9c56e26b runtime: add benchmark of iteration over map with low load
Change-Id: I3a3b7da6245a18bf1db0c595008f0eea853ce544
Reviewed-on: https://go-review.googlesource.com/c/go/+/627155
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-11-13 18:14:14 +00:00
Robert Griesemer
5e91059f8b go/types: adjust type-checking of pointer types
This matches the behavior of types2.

For #49005.

Change-Id: I45661c96124f1c75c4fb6f69cbba7c73984a8231
Reviewed-on: https://go-review.googlesource.com/c/go/+/626039
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-13 17:15:38 +00:00
Russ Cox
c759ea7471 crypto/internal/fips/check: add new package
This package is in charge of the FIPS init-time code+data verification.

If GODEBUG=fips140=off or the empty string, then no verification
happens. Otherwise, the setting must be "on", "debug", or "only",
all of which enable verification. If the setting is "debug", successful
verification prints a message to that effect. Otherwise successful
verification is quiet.

The linker leaves special information for this package to use.
See cmd/internal/obj/fips.go and cmd/link/internal/ld/fips.go,
both submitted in earlier CLs, for details.

For #69536.

Change-Id: Ie1fe29f316db290e0bd7df0a5a09108be4779d63
Reviewed-on: https://go-review.googlesource.com/c/go/+/625998
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-11-13 10:42:11 +00:00
Keith Randall
2bbc6a4512 cmd/asm: fix format string so vet doesn't complain
Fixes #70309

Change-Id: I4a3e27e89bdfda66d64f2efbb4c08a5ddde34a52
Reviewed-on: https://go-review.googlesource.com/c/go/+/626040
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2024-11-13 09:40:14 +00:00
chenguoqi
84e58c84fd cmd/internal/obj: add tool to generate Cnames string
Add cmd/internal/obj/mkcnames.go to do the generation and update
the architecture packages to use it to maintain the Cnames tables.

Currently works correctly on arm64,loong64,mips,ppc64 and s390x.

Change-Id: I5220b0ba6d8a8a5fcc4d9774731eb2af69a671af
Reviewed-on: https://go-review.googlesource.com/c/go/+/622256
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
2024-11-13 05:02:13 +00:00