<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/runtime/runtime2.go, branch makepkg</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=makepkg</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=makepkg'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2026-01-23T22:41:52Z</updated>
<entry>
<title>runtime: speed up cheaprand and cheaprand64</title>
<updated>2026-01-23T22:41:52Z</updated>
<author>
<name>Gavin Lam</name>
<email>gavin.oss@tutamail.com</email>
</author>
<published>2026-01-23T03:44:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=27fcec4d8f3041e845762303d85d868cc3e351e8'/>
<id>urn:sha1:27fcec4d8f3041e845762303d85d868cc3e351e8</id>
<content type='text'>
The current cheaprand performs 128-bit multiplication on 64-bit numbers
and truncate the result to 32 bits, which is inefficient.

A 32-bit specific implementation is more performant because it performs
64-bit multiplication on 32-bit numbers instead.

The current cheaprand64 involves two cheaprand calls.
Implementing it as 64-bit wyrand is significantly faster.

Since cheaprand64 discards one bit, I have preserved this behavior.
The underlying uint64 function is made available as cheaprandu64.

               │    old      │                new           │
               │   sec/op    │   sec/op     vs base         │
Cheaprand-8      1.358n ± 0%   1.218n ± 0%  -10.31% (n=100)
Cheaprand64-8    2.424n ± 0%   1.391n ± 0%  -42.62% (n=100)
Blocksampled-8   8.347n ± 0%   2.022n ± 0%  -75.78% (n=100)

Fixes #77149

Change-Id: Ib0b5da4a642cd34d0401b03c1d343041f8230d11
GitHub-Last-Rev: 549d8d407e2bbcaecdee0b52cbf3a513dda637fb
GitHub-Pull-Request: golang/go#77150
Reviewed-on: https://go-review.googlesource.com/c/go/+/735480
Auto-Submit: Keith Randall &lt;khr@golang.org&gt;
Reviewed-by: Carlos Amedee &lt;carlos@golang.org&gt;
Reviewed-by: Keith Randall &lt;khr@google.com&gt;
Reviewed-by: Keith Randall &lt;khr@golang.org&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
</content>
</entry>
<entry>
<title>runtime: make goroutines inherit DIT state, don't lock to OS thread</title>
<updated>2025-12-11T16:21:53Z</updated>
<author>
<name>Roland Shoemaker</name>
<email>roland@golang.org</email>
</author>
<published>2025-12-03T22:19:25Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=af14f6791108ece9661590cbf922806492954ea6'/>
<id>urn:sha1:af14f6791108ece9661590cbf922806492954ea6</id>
<content type='text'>
When we first implemented DIT (crypto/subtle.WithDataIndependentTiming),
we made it so that enabling DIT on a goroutine would lock that goroutine
to its current OS thread. This was done to ensure that the DIT state
(which is per-thread) would not leak to other goroutines. We also did
not make goroutines inherit the DIT state.

This change makes goroutines inherit the DIT state from their parent
at creation time. It also removes the OS thread locking when enabling
DIT on a goroutine. Instead, we now set the DIT state on the OS thread
in the scheduler whenever we switch to a goroutine that has DIT enabled,
and we unset it when switching to a goroutine that has DIT disabled.

We add a new field to G and M, ditEnabled, to track whether the G wants
DIT enabled, and whether the M currently has DIT enabled, respectively.
When the scheduler executes a goroutine, it checks these fields and
enables/disables DIT on the thread as needed.

Additionally, cgocallbackg is updated to check if DIT is enabled when
being called from C, and sets the G and M fields accordingly. This
ensures that if DIT was enabled/disabled in C, the correct state will be
reflected in the Go runtime.

The behavior as it currently stands is as follows:
- The function passed to crypto/subtle.WithDataIndependentTiming
  will have DIT enabled.
- Any goroutine created within that function will inherit DIT enabled
  for its lifetime. Any goroutine created from subquent goroutines will
  also inherit DIT enabled for their lifetimes.
- Calling into a C function within from a goroutine with DIT enabled
  will have DIT enabled.
- If the C code disables DIT, the goroutine will have DIT re-enabled
  when returning to Go.
- If the C code enables DIT, the goroutine will have DIT disabled
  when returning to Go if it was not previously enabled.
- Calling back into Go code from C will have DIT enabled if it was
  enabled when calling into C, or if the C code enabled it.

Change-Id: I8e91e6df13bb88e56e1036e0e0e5f04efd8eebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/726382
Reviewed-by: Michael Pratt &lt;mpratt@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: David Chase &lt;drchase@google.com&gt;
</content>
</entry>
<entry>
<title>runtime: don't count nGsyscallNoP for extra Ms in C</title>
<updated>2025-12-05T21:48:24Z</updated>
<author>
<name>Michael Anthony Knyszek</name>
<email>mknyszek@google.com</email>
</author>
<published>2025-12-04T23:27:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=745349712e837ef77eb7b5a21c4d4e5c7ca0371a'/>
<id>urn:sha1:745349712e837ef77eb7b5a21c4d4e5c7ca0371a</id>
<content type='text'>
In #76435, it turns out that the new metric
/sched/goroutines/not-in-go:goroutines counts C threads that have called
into Go before (on Linux) as not-in-go goroutines. The reason for this
is that the M is still attached to the C thread on Linux as an
optimization, so we don't go through all the trouble of detaching the M
and, of course, decrementing nGsyscallNoP.

There's an easy fix to this accounting issue. The flag on the M,
isExtraInC, says whether a thread with an extra M attached no longer has
any Go on its (logical) stack. When we take the P from an M in this
state, we simply just don't increment nGsyscallNoP. When it calls back
into Go, we similarly skip the decrement to nGsyscallNoP.

This is more efficient than alternatives, like always updating
nGsyscallNoP in cgocallbackg, since that would add a new
read-modify-write atomic onto that fast path. It does mean we count
threads in C with a P still attached as not-in-go, but this transient in
most real programs, assuming the thread indeed does not call back into
Go any time soon.

Fixes #76435.

Change-Id: Id05563bacbe35d3fae17d67fb5ed45fa43fa0548
Reviewed-on: https://go-review.googlesource.com/c/go/+/726964
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Michael Pratt &lt;mpratt@google.com&gt;
</content>
</entry>
<entry>
<title>runtime/secret: implement new secret package</title>
<updated>2025-11-26T23:42:52Z</updated>
<author>
<name>Daniel Morsing</name>
<email>daniel.morsing@gmail.com</email>
</author>
<published>2025-09-25T16:26:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=a3fb92a7100f3f2824d483ee0cbcf1264584b3e4'/>
<id>urn:sha1:a3fb92a7100f3f2824d483ee0cbcf1264584b3e4</id>
<content type='text'>
Implement secret.Do.

- When secret.Do returns:
  - Clear stack that is used by the argument function.
  - Clear all the registers that might contain secrets.
- On stack growth in secret mode, clear the old stack.
- When objects are allocated in secret mode, mark them and then zero
  the marked objects immediately when they are freed.
- If the argument function panics, raise that panic as if it originated
  from secret.Do. This removes anything about the secret function
  from tracebacks.

For now, this is only implemented on linux for arm64 and amd64.

This is a rebased version of Keith Randalls initial implementation at
CL 600635. I have added arm64 support, signal handling, preemption
handling and dealt with vDSOs spilling into system stacks.

Fixes #21865

Change-Id: I6fbd5a233beeaceb160785e0c0199a5c94d8e520
Co-authored-by: Keith Randall &lt;khr@golang.org&gt;
Reviewed-on: https://go-review.googlesource.com/c/go/+/704615
Reviewed-by: Roland Shoemaker &lt;roland@golang.org&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Filippo Valsorda &lt;filippo@golang.org&gt;
Reviewed-by: Cherry Mui &lt;cherryyz@google.com&gt;
</content>
</entry>
<entry>
<title>crypto/fips140: add WithoutEnforcement</title>
<updated>2025-11-26T22:26:06Z</updated>
<author>
<name>Daniel Morsing</name>
<email>daniel.morsing@gmail.com</email>
</author>
<published>2025-11-24T13:08:10Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=86bbea0cfa72041fb4315eb22099b0bc83caa314'/>
<id>urn:sha1:86bbea0cfa72041fb4315eb22099b0bc83caa314</id>
<content type='text'>
WithoutEnforcement lets programs running under GODEBUG=fips140=only
selectively opt out of strict enforcement. This is especially helpful
for non-critical uses of cryptography routines like SHA-1 for content
addressable storage backends (E.g. git).

Fixes #74630

Change-Id: Iabba1f5eb63498db98047aca45e09c5dccf2fbdf
Reviewed-on: https://go-review.googlesource.com/c/go/+/723720
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
Reviewed-by: Filippo Valsorda &lt;filippo@golang.org&gt;
Auto-Submit: Filippo Valsorda &lt;filippo@golang.org&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Roland Shoemaker &lt;roland@golang.org&gt;
</content>
</entry>
<entry>
<title>runtime: go fmt</title>
<updated>2025-11-21T19:07:05Z</updated>
<author>
<name>Michael Pratt</name>
<email>mpratt@google.com</email>
</author>
<published>2025-11-20T21:25:40Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=e7787b9eca6bf0711cec1ac46841a8b09668f6a8'/>
<id>urn:sha1:e7787b9eca6bf0711cec1ac46841a8b09668f6a8</id>
<content type='text'>
Change-Id: I6a6a636cf38ddb1dc6f2170361eb4093b81acdfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/722521
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Michael Pratt &lt;mpratt@google.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
</content>
</entry>
<entry>
<title>runtime: split findRunnableGCWorker in two</title>
<updated>2025-11-20T16:08:47Z</updated>
<author>
<name>Michael Pratt</name>
<email>mpratt@google.com</email>
</author>
<published>2025-11-17T20:09:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=829779f4fe7e002b959a2f4966aa9e21c59e418c'/>
<id>urn:sha1:829779f4fe7e002b959a2f4966aa9e21c59e418c</id>
<content type='text'>
The first part, assignWaitingGCWorker selects a mark worker (if any) and
assigns it to the P. The second part, findRunnableGCWorker, is
responsible for actually marking the worker as runnable and updating the
CPU limiter.

The advantage of this split is that assignWaitingGCWorker is safe to do
during STW, which will allow the next CL to make selections during
procresize.

This change is a semantic no-op in preparation for the next CL.

For #65694.

Change-Id: I6a6a636c8beb212185829946cfa1e49f706ac31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/721001
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Michael Pratt &lt;mpratt@google.com&gt;
</content>
</entry>
<entry>
<title>runtime: rename findrunnable references to findRunnable</title>
<updated>2025-11-17T19:49:59Z</updated>
<author>
<name>Michael Pratt</name>
<email>mpratt@google.com</email>
</author>
<published>2025-11-17T18:34:51Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=6919858338ae3c4f244f65ca87e9e71662a83413'/>
<id>urn:sha1:6919858338ae3c4f244f65ca87e9e71662a83413</id>
<content type='text'>
These cases were missed by CL 393880.

Change-Id: I6a6a636cf0d97a4efcf4b9df766002ecef48b4de
Reviewed-on: https://go-review.googlesource.com/c/go/+/721120
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Michael Pratt &lt;mpratt@google.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
</content>
</entry>
<entry>
<title>runtime: prefer to restart Ps on the same M after STW</title>
<updated>2025-11-13T15:44:41Z</updated>
<author>
<name>Michael Pratt</name>
<email>mpratt@google.com</email>
</author>
<published>2025-10-24T19:14:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=4ebf295b0b1740caac6302cc824ebd0f6175c1d5'/>
<id>urn:sha1:4ebf295b0b1740caac6302cc824ebd0f6175c1d5</id>
<content type='text'>
Today, Ps jump around arbitrarily across STW. Instead, try to keep the P
on the previous M it ran on. In the future, we'll likely want to try to
expand this beyond STW to create a more general affinity for specific
Ms.

For this to be useful, the Ps need to have runnable Gs. Today, STW
preemption goes through goschedImpl, which places the G on the global
run queue. If that was the only G then the P won't have runnable
goroutines anymore.

It makes more sense to keep the G with its P across STW anyway, so add a
special case to goschedImpl for that.

On my machine, this CL reduces the error rate in TestTraceSTW from 99.8%
to 1.9%.

As a nearly 2% error rate shows, there are still cases where this best
effort scheduling doesn't work. The most obvious is that while
procresize assigns Ps back to their original M, startTheWorldWithSema
calls wakep to start a spinning M. The spinning M may steal a goroutine
from another P if that P is too slow to start.

For #65694.

Change-Id: I6a6a636c0969c587d039b68bc68ea16c74ff1fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/714801
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
Auto-Submit: Michael Pratt &lt;mpratt@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
</content>
</entry>
<entry>
<title>runtime: switch p.gcFractionalMarkTime to atomic.Int64</title>
<updated>2025-11-12T16:26:55Z</updated>
<author>
<name>Michael Pratt</name>
<email>mpratt@google.com</email>
</author>
<published>2025-10-30T20:33:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=d3aeba1670e80095fdd6e313a776163f4c68dc6a'/>
<id>urn:sha1:d3aeba1670e80095fdd6e313a776163f4c68dc6a</id>
<content type='text'>
atomic.Int64 automatically maintains proper alignment, avoiding the need
to manually adjust alignment back and forth as fields above change.

Change-Id: I6a6a636c4c3c366353f6dc8ecac473c075dd5cd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/716700
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
Auto-Submit: Michael Pratt &lt;mpratt@google.com&gt;
</content>
</entry>
</feed>
