aboutsummaryrefslogtreecommitdiff
path: root/src/internal/runtime
AgeCommit message (Collapse)Author
2026-02-02internal/maps,cmd/compile/internal/walk: replace calls to mapaccess1* with ↵ArsenySamoylov
mapaccess2* mapaccess1* and mapaccess2* functions share the same implementation and differ only in whether the boolean "found" is returned. This change replaces mapaccess1* calls with mapaccess2*. We can do this transparently, since the call site can safely discard the second (boolean) result. Ideally, mapacces1* functions could be removed entirely, but this change keeps them as thin wrappers for compatibility. Fixes #73196 Change-Id: I07c3423d22ed1095ac3666d00e134c2747b2f9c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/736020 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2026-01-27internal/runtime/gc/scan: include package in expandAVX512 symbol namesMichael Pratt
These symbols are part of the scan package, so they should include the package name in the symbol name for consistency. Change-Id: I6a6a636ca63b34a8da7fb2f0bfe1fa5f8672fff5 Reviewed-on: https://go-review.googlesource.com/c/go/+/738522 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-22internal/runtime: remove math.Mul64Gavin Lam
internal/runtime/math.Mul64 is a copy of math/bits.Mul64 and redundant. Change-Id: I4dd2ab531a32da97839c6b45cf90df6430811967 GitHub-Last-Rev: 1a73e16049ee346ccfa8f052856e49e10e202d70 GitHub-Pull-Request: golang/go#77187 Reviewed-on: https://go-review.googlesource.com/c/go/+/736500 Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-10runtime: VZEROUPPER at the end of FilterNilAVX512Cherry Mui
VZEROUPPER at the end of FilterNilAVX512 as we're leaving AVX context. Also explicitly zero Z15, as the high bits are not guaranteed zero as of CL 728240. Change-Id: I000a199206d0b8fd4905c8a699e934551bbd3c60 Reviewed-on: https://go-review.googlesource.com/c/go/+/728740 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-05crypto/subtle: add speculation barrier after DITRoland Shoemaker
When enabling DIT on ARM64, add speculation barrier instructions to ensure that subsequent instructions are executed using the updated DIT state. See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Enable-DIT-for-constant-time-cryptographic-operations which recommends doing this. The Arm documentation for DIT doesn't tell you to do this, but it seems prudent. Change-Id: Idbc87b332650a77b8cb3509c11377bf5c724f3cf Reviewed-on: https://go-review.googlesource.com/c/go/+/726980 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-12-05internal/runtime/maps: clarify probeSeq doc commentNick Ripley
The probeSeq doc comment describes the probe sequence as triangular and gives the formula for terms in the sequence. This formula isn't actually used in the code, though. List the first few terms of the sequence explicitly so the connection between the description and the code is more clear. Change-Id: I6a6a69648bc94e15df436815c16128ebef3c6eb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/726820 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-12-01internal/runtime/cgroup: remove duplicate readString definitionMichael Pratt
Both CL 723241 and CL 723581 added identical definitions. Change-Id: I6a6a636c9e5f8c9080b9389ebf9d3f10305d79ac Reviewed-on: https://go-review.googlesource.com/c/go/+/725661 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-12-01internal/runtime/cgroup: lineReader fuzz test胡玮文
The original unit test is converted to a fuzz test, to be more confident on future refactors. All sub-tests are converted to seed corpus. Change-Id: Id0c167ed47729a00ea0614d17746ddcc284697d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/723581 Auto-Submit: Michael Pratt <mpratt@google.com> 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>
2025-11-26internal/runtime/cgroup: stricter unescapePath胡玮文
8 and 9 in escape sequence is invalid now, it should be octal. Escape sequence larger than \377 is invalid now, it does not fit one byte. Change-Id: I3fdebce1d054c44919f0e66a33c778b5a2b099e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/723242 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-11-26internal/runtime/cgroup: fix path on non-root mount point胡玮文
We should trim the mount root (4th field in /proc/self/mountinfo) from cgroup path read from /proc/self/cgroup before appending it to the mount point. Non-root mount points are very common in containers with cgroup v1. parseCPURelativePath is renamed to parseCPUCgroup, as it is unclear what it is relative to. cgroups(7) says "This pathname is relative to the mount point of the hierarchy." It should mean the root of the hierarchy, and we cannot concat it to arbirary cgroup mount point. So just use the word cgroup, since it parses /proc/self/cgroup. It now returns errMalformedFile if the cgroup pathname does not start with "/", and errPathTooLong if the pathname can't fit into the buffer. We already rely on this when composing the path, just make this explicit to avoid incorrect paths. We now parse cgroup first then parse the mount point accordingly. We consider the previously read cgroup pathname and version to ensure we got the desired mount point. The out buffer is reused to pass in the cgroup, to avoid extra memory allocation. This should also resolve the race mentioned in the comments, so removing those comments. If our cgroup changed between the two read syscalls, we will stick with the cgroup read from /proc/self/cgroup. This is the same behavior as cgroup change after FindCPU() returns, so nothing special to comment about now. parseCPUMount now returns error when the combined path is too long, to avoid panic or truncation if we got a really long path from mountinfo. cgrouptest is changed to use dev returned from stat() to detect filesystem boundary, since we don't return mount point and sub-path separately now. This also avoid using os.Root since we don't handle untrusted input here. os.Root is too complex, and the performance is bad. Fixes #76390 Change-Id: Ia9cbd7be3e58a2d51caf27a973fbd201dac06afc Reviewed-on: https://go-review.googlesource.com/c/go/+/723241 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-11-26internal/runtime/cgroup: simplify escapePath in test胡玮文
Don't work on rune, kernel does not use utf-8 here. Can be verified like this: # mkdir "$(echo -e "\xff\x20")" # mount -t tmpfs tmpfs "$(echo -e "\xff\x20")" # tail -n 1 /proc/self/mountinfo | xxd 00000000: 3133 3334 2031 3030 2030 3a31 3632 202f 1334 100 0:162 / 00000010: 202f 726f 6f74 2fff 5c30 3430 2072 772c /root/.\040 rw, 00000020: 7265 6c61 7469 6d65 2073 6861 7265 643a relatime shared: 00000030: 3433 3520 2d20 746d 7066 7320 746d 7066 435 - tmpfs tmpf 00000040: 7320 7277 0a s rw. Change-Id: I7468b56eb26f14bc809f8f7580535e6562795c62 Reviewed-on: https://go-review.googlesource.com/c/go/+/723300 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-11-25internal/runtime/cgroup: allow more tests to run on all OSes胡玮文
Move non-Linux specific part out of _linux.go. The parsing code itself doesn't depend anything Linux specific, even if it the format is Linux specific. This should benefit developers working on non-Linux OSes. Change-Id: I1692978d583c3dd9a57ff269c97e8fca53a7a057 Reviewed-on: https://go-review.googlesource.com/c/go/+/723240 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Carrillo Rodriguez <carrillorodriguez672@gmail.com>
2025-11-24runtime: add GODEBUG=tracebacklabels=1 to include pprof labels in tracebacksDavid Finkel
Copy LabelSet to an internal package as label.Set, and include (escaped) labels within goroutine stack dumps. Labels are added to the goroutine header as quoted key:value pairs, so the line may get long if there are a lot of labels. To handle escaping, we add a printescaped function to the runtime and hook it up to the print function in the compiler with a new runtime.quoted type that's a sibling to runtime.hex. (in fact, we leverage some of the machinery from printhex to generate escape sequences). The escaping can be improved for printable runes outside basic ASCII (particularly for languages using non-latin stripts). Additionally, invalid UTF-8 can be improved. So we can experiment with the output format make this opt-in via a a new tracebacklabels GODEBUG var. Updates #23458 Updates #76349 Change-Id: I08e78a40c55839a809236fff593ef2090c13c036 Reviewed-on: https://go-review.googlesource.com/c/go/+/694119 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-11-24internal/runtime/syscall: Syscall changes for s390x regabiSrinivas Pokala
Updates #40724 Change-Id: I07a01ac1bda71214f01f4a72e15ab469ef275725 Reviewed-on: https://go-review.googlesource.com/c/go/+/719423 Reviewed-by: Vishwanatha HD <vishwanatha.hd@ibm.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-21internal/runtime/gc/scan: add AVX512 impl of filterNil.Junyang Shao
Benchmark results: ScanSpanPacked/cache=ram/pages=10368/sizeclass=25/pct=60-48 6.356Gi ± ∞ ¹ 7.332Gi ± ∞ ¹ ~ (p=1.000 n=1) ² ScanSpanPacked/cache=ram/pages=10368/sizeclass=25/pct=70-48 6.756Gi ± ∞ ¹ 8.302Gi ± ∞ ¹ ~ (p=1.000 n=1) ² ScanSpanPacked/cache=ram/pages=10368/sizeclass=25/pct=80-48 7.018Gi ± ∞ ¹ 8.658Gi ± ∞ ¹ ~ (p=1.000 n=1) ² ScanSpanPacked/cache=ram/pages=10368/sizeclass=25/pct=90-48 7.313Gi ± ∞ ¹ 9.055Gi ± ∞ ¹ ~ (p=1.000 n=1) ² ScanSpanPacked/cache=ram/pages=10368/sizeclass=25/pct=100-48 7.583Gi ± ∞ ¹ 9.557Gi ± ∞ ¹ ~ (p=1.000 n=1) ² geomean 10.61Gi 14.83Gi +39.81% Almost a +40% on throughput. Change-Id: I6f31a0f0202ec7f3c9d2bbffca5d6e377306fc25 Reviewed-on: https://go-review.googlesource.com/c/go/+/722040 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-17internal/runtime/maps: update doc for table.ClearJes Cok
Change-Id: I9456b9fb7ed3bbf6a3c29de24951e02cf8f4635d GitHub-Last-Rev: 2deaa1172570c8b477275dd636c092913692661b GitHub-Pull-Request: golang/go#76311 Reviewed-on: https://go-review.googlesource.com/c/go/+/720761 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-11-14internal/runtime/cgobench: add Go function call benchmark for comparisonMichael Anthony Knyszek
Change-Id: I0ada7fa02eb5f18a78da17bdcfc63333abbd8450 Reviewed-on: https://go-review.googlesource.com/c/go/+/713284 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>
2025-11-10internal/runtime/sys,math/bits: eliminate bounds checks on len8tabJoel Sing
The compiler cannot currently determine that the accesses to len8tab are within bounds. Cast to uint8 to avoid unnecessary bounds checks. Fixes #76166 Change-Id: I1fd930bba2b20d3998252c476308642e08ce00b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/718040 Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Joel Sing <joel@sing.id.au> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-03internal/runtime/cgobench: add cgo callback benchmarkMichael Anthony Knyszek
Change-Id: I43ea575aff87a3e420477cb26d35185d03df5ccc Reviewed-on: https://go-review.googlesource.com/c/go/+/713283 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-29internal/itoa, internal/runtime/strconv: deleteRuss Cox
Replaced by internal/strconv. Change-Id: I0656a9ad5075e60339e963fbae7d194d2f3e16be Reviewed-on: https://go-review.googlesource.com/c/go/+/716001 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-28internal/runtime/gc/scan: avoid memory destination on VPCOMPRESSQMichael Pratt
On AMD Genoa / Zen 4, VPCOMPRESSQ with a memory destination imposes a severe performance penalty of another an order of magnitude compared to a register destination. We can trivially work around this penalty with a register destination and an additional move to memory. Benchmark results from: $ go test -bench=BenchmarkScanSpanPacked/.*/.*/.*/.*/impl=Platform internal/runtime/gc/scan I've only included the summarized geomean here because there are ~2500 unique test cases. AMD Genoa (Zen 4): cpu: AMD EPYC 9B14 96-Core Processor │ mem │ reg │ │ sec/op │ sec/op vs base │ geomean 1.039µ 310.1n -70.16% │ mem │ reg │ │ B/s │ B/s vs base │ geomean 2.906Gi 10.99Gi +278.27% As expected, we see a massive performance improvement on Genoa. AMD Turin (Zen 5): cpu: AMD EPYC 9B45 128-Core Processor │ mem │ reg │ │ sec/op │ sec/op vs base │ geomean 231.9n 237.3n +2.32% │ mem │ reg │ │ B/s │ B/s vs base │ geomean 14.79Gi 14.43Gi -2.50% On Turin there is a minor regression. This is primarily due to a fairly large regression (~15%) in very small microbenchmark cases where the entire memory fits in L1 cache. This regression disappears as memory access slows down with larger memories. The latter should be more common in real workloads. Intel Sapphire Rapids: cpu: Intel(R) Xeon(R) Platinum 8481C │ mem │ reg │ │ sec/op │ sec/op vs base │ geomean 254.9n 246.8n -3.18% │ mem │ reg │ │ B/s │ B/s vs base │ geomean 13.65Gi 14.15Gi +3.69% On Sapphire Rapids there is a minor improvement. Here results are fairly noisy. Most cases are a wash, but some are arbitrary 20% slower or 20% faster for unclear reasons. For #73581. Change-Id: I6a6a636cfd294a0dcdc4f34c9ece1bc9a6e5e4c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/715362 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-10-27internal/runtime/gc/scan: correct size class size checkMichael Pratt
This check intends to skip size classes that are too big for scanSpan, but it compares the size class index with a byte size. It must do the conversion first. For #73581. Change-Id: I6a6a636c8d19fa3bf2a2b609870d67d33f47f66e Reviewed-on: https://go-review.googlesource.com/c/go/+/715460 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-10-24runtime: use 32-bit hash for maps on WasmCherry Mui
Currently we use 64-bit hash calculations on Wasm. The 64-bit hash calculation make intensive uses of 64x64->128 bit multiplications, which on many 64-bit platforms are compiler intrinsics and can be compiled to one or two instructions. This is not the case on Wasm, so it is not very performant. This CL makes it use 32-bit hashes on Wasm, just like other 32-bit architectures. The 32-bit hash calculation only uses 32x32->64 bit multiplications, which can be compiled efficiently on Wasm. Using 32-bit hashes may increase the chance of collisions. But it is the same as 32-bit architectures like 386. And our Wasm port supports only 32-bit address space (like 386), so this is not too bad. Runtime Hash benchmark results goos: js goarch: wasm pkg: runtime │ 0h.txt │ 1h.txt │ │ sec/op │ sec/op vs base │ Hash5 20.45n ± 9% 14.06n ± 2% -31.21% (p=0.000 n=10) Hash16 22.34n ± 7% 17.52n ± 1% -21.62% (p=0.000 n=10) Hash64 47.47n ± 3% 28.68n ± 1% -39.59% (p=0.000 n=10) Hash1024 475.4n ± 1% 271.4n ± 0% -42.92% (p=0.000 n=10) Hash65536 28.42µ ± 1% 16.66µ ± 0% -41.40% (p=0.000 n=10) HashStringSpeed 40.07n ± 7% 29.23n ± 1% -27.05% (p=0.000 n=10) HashBytesSpeed 62.01n ± 3% 46.11n ± 4% -25.64% (p=0.000 n=10) HashInt32Speed 24.31n ± 2% 20.39n ± 1% -16.13% (p=0.000 n=10) HashInt64Speed 25.48n ± 7% 20.81n ± 7% -18.29% (p=0.000 n=10) HashStringArraySpeed 87.69n ± 4% 76.65n ± 2% -12.58% (p=0.000 n=10) FastrandHashiter 87.65n ± 1% 87.65n ± 1% ~ (p=0.896 n=10) geomean 90.82n 67.03n -26.19% Map benchmarks are too many to post here. The speedups are around 0-40%. Change-Id: I2f7a68cfc446ab5a547fdb6a40aea07854516d51 Reviewed-on: https://go-review.googlesource.com/c/go/+/714600 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-10-17all: correct name for commentsJes Cok
Change-Id: I390c380349e99ad421264b673ad7734eddb639d3 GitHub-Last-Rev: 32e849a6420574b0d878b9a449a8c044fd6ebdd1 GitHub-Pull-Request: golang/go#75905 Reviewed-on: https://go-review.googlesource.com/c/go/+/711941 Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-10-13all: replace calls to errors.As with errors.AsTypeJulien Cretel
This change replaces most occurrences (in code as well as in comments) of errors.As with errors.AsType. It leaves the errors package and vendored code untouched. Change-Id: I3bde73f318a0b408bdb8f5a251494af15a13118a GitHub-Last-Rev: 8aaaa36a5a12d2a6a90c6d51680464e1a3115139 GitHub-Pull-Request: golang/go#75698 Reviewed-on: https://go-review.googlesource.com/c/go/+/708495 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-27all: fix typosAN Long
Change-Id: I290812905b6b5c52f289f7f8524f93aef19e6efe Reviewed-on: https://go-review.googlesource.com/c/go/+/706775 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Sean Liao <sean@liao.dev>
2025-09-23runtime: add specialized malloc functions for sizes up to 512 bytesMichael Matloob
This CL adds a generator function in runtime/_mkmalloc to generate specialized mallocgc functions for sizes up throuht 512 bytes. (That's the limit where it's possible to end up in the no header case when there are scan bits, and where the benefits of the specialized functions significantly diminish according to microbenchmarks). If the specializedmalloc GOEXPERIMENT is turned on, mallocgc will call one of these functions in the no header case. malloc_generated.go is the generated file containing the specialized malloc functions. malloc_stubs.go contains the templates that will be stamped to create the specialized malloc functions. malloc_tables_generated contains the tables that mallocgc will use to select the specialized function to call. I've had to update the two stdlib_test.go files to account for the new submodule mkmalloc is in. mprof_test accounts for the changes in the stacks since different functions can be called in some cases. I still need to investigate heapsampling.go. Change-Id: Ia0f68dccdf1c6a200554ae88657cf4d686ace819 Reviewed-on: https://go-review.googlesource.com/c/go/+/665835 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-12runtime: move Windows types and consts to internal/runtime/syscall/windowsqmuntal
This CL doesn't change any behavior, it just moves code around to reduce the size of the runtime package and remove some duplicated symbols. Updates #51087. Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64 Change-Id: I3d3e5f214f045c24fb5d4050d56e7b0822a6e4b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/698098 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-11runtime: move mksizeclasses.go to runtime/_mkmallocmatloob
This will allow us to share code with the specialized malloc code generator. Change-Id: I6a6a696450a5039a957811fb06228122d494ddce Reviewed-on: https://go-review.googlesource.com/c/go/+/700495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-09-10internal/runtime/maps: remove redundant package docsxieyuschen
This CL removes redundant package docs comments under different files as all of them will be shown in pkgsite. As of now, package docs 'Package maps implements Go's builtin map type' appears 3 times in pkgsite. See: https://pkg.go.dev/internal/runtime/maps Change-Id: I2f0696dd4f860afea5cc346532bca59135bec798 Reviewed-on: https://go-review.googlesource.com/c/go/+/702135 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-10runtime/internal/maps: only conditionally clear groups when sparseKeith Randall
We only want to do the work of clearing slots if they are full. But we also don't want to do too much work to figure out whether a slot is full or not, especially if clearing a slot is cheap. 1) We decide group-by-group instead of slot-by-slot. If any slot in a group is full, we zero the whole group. 2) If groups are unlikely to be empty, don't bother testing for it. 3) If groups are 50%/50% likely to be empty, also don't bother testing, as it confuses the branch predictor. See #75097. 4) But if a group is really large, do the test anyway, as clearing is expensive. Fixes #75097 Change-Id: I9191865dd3e0fe887751cffe6082ac27d8d8439c Reviewed-on: https://go-review.googlesource.com/c/go/+/697876 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@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Youlin Feng <fengyoulin@live.com>
2025-09-10internal/runtime/maps: speed up ClearKeith Randall
We don't need to know the actual full slots, just whether there are any or not. The test for any full slots is simpler on amd64. We don't have to use PMOVMSKB and do the intreg->floatreg transfer. Fixes #75097 Change-Id: Iace1c100618d7fc2ac5ddd5fe9e8fe5c9595243f Reviewed-on: https://go-review.googlesource.com/c/go/+/697875 Reviewed-by: Youlin Feng <fengyoulin@live.com> Auto-Submit: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com>
2025-08-31internal/runtime/atomic: reset wrong jump target in Cas{,64} on loong64Guoqi Chen
The implementation here needs to be consistent with ssa.OpLOONG64LoweredAtomicCas{32,64}, which was ignored in CL 613396. Change-Id: I72e8d2318e0c1935cc3a35ab5098f8a84e48bcd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/699395 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> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-08-21runtime: remove remaining windows/arm files and commentsqmuntal
CL 648795 deleted most of windows/arm code, but some files escaped from the purge. This CL finishes the job. For #71671 Change-Id: Id454c40a673a1a2a9f190d79248e6d56104cdd61 Reviewed-on: https://go-review.googlesource.com/c/go/+/698036 Reviewed-by: qiu laidongfeng <2645477756@qq.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-08-15internal/runtime: cleaner overflow checkercuiweixie
remove todo Change-Id: I4b10d7a8c26bea9296b321f53abd0330f2afc35a GitHub-Last-Rev: b939acc2873a02687cdafc84894ab9a712d13a98 GitHub-Pull-Request: golang/go#74943 Reviewed-on: https://go-review.googlesource.com/c/go/+/694236 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-08-12internal/runtime/gc/scan: avoid -1 index when cache sizes unavailableMichael Anthony Knyszek
Fixes #74984. Fixes #74983. Change-Id: I011c66c2005bc4d92f1d17f1f8ce88158634f71f Reviewed-on: https://go-review.googlesource.com/c/go/+/695476 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>
2025-08-12internal/runtime/gc/scan: import scan kernel from gclab [green tea]Michael Anthony Knyszek
This change imports the AVX512 GC scanning kernel from CL 593938 into a new package, internal/runtime/gc/scan. Credit to Austin Clements for most of this work. I did some cleanup, added support for more size classes to the expanders, and added more testing. I also restructured the code to make it easier and clearer to add new scan kernels for new architectures. For #73581. Change-Id: I76bcbc889fa6cad73ba0084620fae084a5912e6b Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64_avx512,gotip-linux-amd64_avx512-greenteagc Reviewed-on: https://go-review.googlesource.com/c/go/+/655280 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-08-11internal/runtime/maps: loop invariant code motion with h2(hash) by handcuiweixie
Change-Id: I0cd9763aeedfe326bc566da39b8be0d0ebd113ec GitHub-Last-Rev: 1ec88644148deb41eea2ae89f7f1fb1759b37c27 GitHub-Pull-Request: golang/go#74952 Reviewed-on: https://go-review.googlesource.com/c/go/+/694016 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2025-08-08internal/runtime/maps: remove unused var bitsetDeletedcuiweixie
Change-Id: Ie9e5c2627dc9a7ae1e8186f2c4d0a7a1955ec707 GitHub-Last-Rev: 416419248e312cb356a99b62642a9e7f88c26923 GitHub-Pull-Request: golang/go#74942 Reviewed-on: https://go-review.googlesource.com/c/go/+/694255 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-07-30runtime: add cgo call benchmarkMichael Anthony Knyszek
Change-Id: I12d2ae7dd6a33ecb7110b7d090871e7143fd609f Reviewed-on: https://go-review.googlesource.com/c/go/+/646196 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-07-30all: remove redundant Swiss prefixesMichael Pratt
Now that there is only one map implementation we can simplify names. For #54766. Change-Id: I6a6a636cc6a8fc5e7712c27782fc0ced7467b939 Reviewed-on: https://go-review.googlesource.com/c/go/+/691596 Reviewed-by: Keith Randall <khr@google.com> 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>
2025-07-30all: remove GOEXPERIMENT=swissmapMichael Pratt
For #54766. Change-Id: I6a6a636c40b5fe2e8b0d4a5e23933492bc8bb76e Reviewed-on: https://go-review.googlesource.com/c/go/+/691595 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> Reviewed-by: Keith Randall <khr@golang.org>
2025-07-29internal/abi: move direct/indirect flag from Kind to TFlagKeith Randall
This info makes more sense in the flags instead of as a high bit of the kind. This makes kind access simpler because we now don't need to mask anything. Cleaned up most direct field accesses to use methods instead. (reflect making new types is the only remaining direct accessor.) IfaceIndir -> !IsDirectIface everywhere. gocore has been updated to handle the new location. So has delve. TODO: any other tools need updating? Change-Id: I123f97a4d4bdd0bff1641ee7e276d1cc0bd7e8eb Reviewed-on: https://go-review.googlesource.com/c/go/+/681936 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-28internal/runtime/maps: fix spelling errors in commentsRuihua Wen
Change-Id: I289d26f75bb556b46699159f06ce7eb03d34656d GitHub-Last-Rev: 10ce76df1d4951e021d460808c9d477cfbcf7c5c GitHub-Pull-Request: golang/go#74733 Reviewed-on: https://go-review.googlesource.com/c/go/+/690095 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <mark@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2025-07-28internal/runtime/syscall/windows: factor out code from runtimeqmuntal
Factor out the code related to doing calls using the Windows stdcall calling convention into a separate package. This will allow us to reuse it in other low-level packages that can't depend on syscall. Updates #51087. Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64,gotip-windows-amd64-longtest,gotip-solaris-amd64 Change-Id: I68640b07091183b50da6bef17406c10a397896e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/689156 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-07-24internal/runtime/syscall: rename to internal/runtime/syscall/linuxqmuntal
All code in internal/runtime/syscall is Linux-specific, so better move it to a new linux sub-directory. This way it will be easier to factor out runtime syscall code from other platforms, e.g. Windows. Updates #51087. Change-Id: Idd2a52444b33bf3ad576b47fd232e990cdc8ae75 Reviewed-on: https://go-review.googlesource.com/c/go/+/689155 Reviewed-by: 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>
2025-07-24internal/runtime/exithook: fix a typoJes Cok
That is the say -> That is to say Change-Id: I4a19d4c500103e16e6ae55f41a9fbdddd4bb84a8 GitHub-Last-Rev: 571d49ab8e6d81ac9db8b47d89118fb74bd3f2f6 GitHub-Pull-Request: golang/go#74741 Reviewed-on: https://go-review.googlesource.com/c/go/+/690195 Reviewed-by: 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> Auto-Submit: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-07-22all: go fmtMichael Pratt
Change-Id: I6a6a636c341d4ba3518be7f6806093bbdff11c88 Reviewed-on: https://go-review.googlesource.com/c/go/+/689535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-07-15runtime/maps: fix typo in group.go comment (instrinsified -> intrinsified)dyma solovei
Several comments refer to bitset as 'instrinsified', which is likely a typo, because it refers to the output of the intrinsics implemented with SIMD. Change-Id: I00f26b8d8128592ee0e9dc8a1b1480c93a9542d6 GitHub-Last-Rev: 8a4236710979f2f969210e0b261bdb9ae44f3321 GitHub-Pull-Request: golang/go#74624 Reviewed-on: https://go-review.googlesource.com/c/go/+/688016 Reviewed-by: Keith Randall <khr@golang.org> 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> Reviewed-by: Keith Randall <khr@google.com>
2025-05-21internal/runtime/cgroup: CPU cgroup limit discoveryMichael Pratt
For #73193. Change-Id: I6a6a636ca9fa9cba429cf053468c56c2939cb1ac Reviewed-on: https://go-review.googlesource.com/c/go/+/668638 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>