Skip to content

runtime: g is allocated from the 480-byte size class on amd64, arm64 and loong64 #82000

Open

Description

@KovacevicAleksa

Since CL 704615 (runtime/secret) added g.secret, unsafe.Sizeof(g{}) is 456 bytes on amd64, arm64 and loong64, so every g is allocated from the 480-byte size class. Before that change it was exactly 448 bytes.

g.valgrindStackID (8 bytes) is only used with the valgrind build tag, but every g has it. Moving it into a type that is empty without the build tag, the way xRegPerG is, makes g 448 bytes again on those platforms, and it stays 456 bytes with -tags valgrind.

On darwin/arm64 (Apple M2 Pro) with 100,000 parked goroutines, heap in use per goroutine drops from 639.1 to 609.0 bytes, and each g is allocated from the 448-byte class instead of the 480-byte class.

Separately, CL 843525 removes g.stackLock, which has been unused since CL 36620. It does not change the size class by itself, but together the two changes leave room for a future small field.

I'm sending a CL for this.

Activity

  1. gopherbot commented on Oct 4, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/844725 mentions this issue: runtime: only reserve g.valgrindStackID in valgrind builds

  2. gabyhelp commented on Oct 4, 2026

    @gabyhelp

    Related Code Changes

    (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

  3. gopherbot commented on Oct 5, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/844825 mentions this issue: runtime: report size class changes in TestSizeof

  4. added
    arch-loong64Issues solely affecting the loongson architecture.
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Oct 5, 2026
  5. added this to the Go1.28 milestone on Oct 5, 2026
  6. dmitshur commented on Oct 5, 2026

    @dmitshur
    Member

    CC @golang/runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.arch-amd64arch-arm64arch-loong64Issues solely affecting the loongson architecture.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions