mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
runtime: only clear inline mark bits on span alloc if necessary
This change modifies initInlineMarkBits to only clear mark bits if the span wasn't just freshly allocated from the OS, where we know the bits are already zeroed. This probably doesn't make a huge difference most of the time, but it's an easy optimization and helps rule it out as a source of slowdown. For #73581. Change-Id: I78cd4d8968bb0bf6536c0a38ef9397475c39f0ad Reviewed-on: https://go-review.googlesource.com/c/go/+/687937 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
0c6296ab12
commit
6d4a91c7a5
1 changed files with 7 additions and 4 deletions
|
@ -110,7 +110,7 @@ func (o *spanScanOwnership) or(v spanScanOwnership) spanScanOwnership {
|
|||
return spanScanOwnership(atomic.Or32(o32, uint32(v)<<off) >> off)
|
||||
}
|
||||
|
||||
func (imb *spanInlineMarkBits) init(class spanClass) {
|
||||
func (imb *spanInlineMarkBits) init(class spanClass, needzero bool) {
|
||||
if imb == nil {
|
||||
// This nil check and throw is almost pointless. Normally we would
|
||||
// expect imb to never be nil. However, this is called on potentially
|
||||
|
@ -131,7 +131,9 @@ func (imb *spanInlineMarkBits) init(class spanClass) {
|
|||
// See go.dev/issue/74375 for details.
|
||||
throw("runtime: span inline mark bits nil?")
|
||||
}
|
||||
if needzero {
|
||||
*imb = spanInlineMarkBits{}
|
||||
}
|
||||
imb.class = class
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,8 @@ func (s *mspan) initInlineMarkBits() {
|
|||
if doubleCheckGreenTea && !gcUsesSpanInlineMarkBits(s.elemsize) {
|
||||
throw("expected span with inline mark bits")
|
||||
}
|
||||
s.inlineMarkBits().init(s.spanclass)
|
||||
// Zeroing is only necessary if this span wasn't just freshly allocated from the OS.
|
||||
s.inlineMarkBits().init(s.spanclass, s.needzero != 0)
|
||||
}
|
||||
|
||||
// moveInlineMarks merges the span's inline mark bits into dst and clears them.
|
||||
|
@ -205,7 +208,7 @@ func (s *mspan) moveInlineMarks(dst *gcBits) {
|
|||
}
|
||||
|
||||
// Reset the inline mark bits.
|
||||
imb.init(s.spanclass)
|
||||
imb.init(s.spanclass, true /* We know these bits are always dirty now. */)
|
||||
}
|
||||
|
||||
// inlineMarkBits returns the inline mark bits for the span.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue