diff options
| author | Nick Ripley <nick.ripley@datadoghq.com> | 2026-02-23 15:46:04 +0000 |
|---|---|---|
| committer | Nick Ripley <nick.ripley@datadoghq.com> | 2026-02-23 12:50:02 -0800 |
| commit | 04772f022a1cb19f2596fa241ecc24bcb7f4dce5 (patch) | |
| tree | bb7a160b23c413bd5965bb71834e5e1b1e54cb0e /src/runtime | |
| parent | fe080173033908f0f69b2dbf4a7ba1eaaea194bf (diff) | |
| download | go-04772f022a1cb19f2596fa241ecc24bcb7f4dce5.tar.xz | |
runtime: remove write barriers from traceRegionAlloc
The memory managed by traceRegionAlloc is off-heap by design. However,
stores to the "current" pointer currently have a write barrier. This CL
switches the stores to their write barrier-free equivalents. If the
traceMap data structure gets extended and used elsewhere in the future,
such as for runtime lock contention profiling, we might not have a P and
thus won't be able to use a write barrier in this code. But for now this
is just a cleanup and minor efficiency improvment.
Change-Id: I3081c9d48a8471fd87534e5c4951823d6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/748120
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>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/traceregion.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/traceregion.go b/src/runtime/traceregion.go index eb19294f1b..e3a024c458 100644 --- a/src/runtime/traceregion.go +++ b/src/runtime/traceregion.go @@ -92,8 +92,8 @@ func (a *traceRegionAlloc) alloc(n uintptr) *notInHeap { block.off.Store(n) x = (*notInHeap)(unsafe.Pointer(&block.data[0])) - // Publish the new block. - a.current.Store(unsafe.Pointer(block)) + // Publish the new block. No write barrier as the memory is off heap. + a.current.StoreNoWB(unsafe.Pointer(block)) unlock(&a.lock) }) return x @@ -112,7 +112,7 @@ func (a *traceRegionAlloc) drop() { } if current := a.current.Load(); current != nil { sysFree(current, unsafe.Sizeof(traceRegionAllocBlock{}), &memstats.other_sys) - a.current.Store(nil) + a.current.StoreNoWB(nil) } a.dropping.Store(false) } |
