Skip to content

Enable go 1.27 support - #52

Open
jprieto-temporal wants to merge 1 commit into
cockroachdb:mainfrom
jprieto-temporal:jprieto/tustpvzympyk
Open

Enable go 1.27 support#52
jprieto-temporal wants to merge 1 commit into
cockroachdb:mainfrom
jprieto-temporal:jprieto/tustpvzympyk

Conversation

@jprieto-temporal

Copy link
Copy Markdown

Adds support for Go 1.27. Follows the pattern of changes in #50.

@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde

Copy link
Copy Markdown
Member

Thanks! Did you verify that the aliased structures in the runtime are unchanged (at least the prefix that we're using)?

@RaduBerinde

Copy link
Copy Markdown
Member

Claude checked:

⏺ Verified — and I ran it, not just read it.

Source check (github.com/golang/go @ tag go1.27.0)

internal/abi.Type — field-for-field identical to swiss's rtType: Size_, PtrBytes uintptr; Hash uint32; TFlag, Align_, FieldAlign_, Kind_ uint8; Equal func; GCData
*byte; Str NameOff; PtrToThis TypeOff. (TFlag/NameOff/TypeOff are still uint8/int32/int32; Kind_'s declared type is now abi.Kind, which is uint8 — same size, no
layout effect.)

internal/abi.MapType (src/internal/abi/map.go) — the aliased prefix is unchanged:

type MapType struct {
Type
Key *Type
Elem *Type
Group *Type // swiss calls this Bucket — same position, same type
Hasher func(unsafe.Pointer, uintptr) uintptr
... // GroupSize, KeysOff, KeyStride, ElemsOff, ElemStride, ElemOff, Flags
}

Everything past Hasher was reworked in 1.27 for the mapsplitgroup experiment, but that's all beyond the prefix swiss reads. Note internal/abi/map_swiss.go and the
old OldMapType are gone — there's now just one MapType — so the "prefix of both abi.SwissMapType and abi.OldMapType" comment in swiss is stale.

runtime.eface — still {_type *_type; data unsafe.Pointer}.

runtime.fastrand64 — still exists as a push-linknamed compat shim (src/runtime/rand.go:341, //go:linkname legacy_fastrand64 runtime.fastrand64), so swiss's pull
linkname remains legal under the 1.23+ linkname restrictions.

Empirical check

Pulled the real go1.27.0 toolchain from the module proxy and ran swiss against it with -tags untested_go_version:

  • Full suite: ok (plain, and -race -tags invariants).
  • A layout test I added (/tmp/claude-503/swiss/runtime_layout_check_test.go) that cross-checks the aliased fields against reflect ground truth for 8 key types:
    rtEface.typ == the *abi.Type reflect reports for the map type; Size_/Align_/FieldAlign_/Kind_ match reflect.Type; Equal == nil, GCData != nil; mt.Key/mt.Elem are
    pointer-identical to typePtr(rt.Key())/typePtr(rt.Elem()) — which pins every offset up to and including Elem; Bucket/Group is a plausible non-nil type; Hasher is
    callable, deterministic, seed-sensitive, and well-distributed. All pass.
  • Passes under both GOEXPERIMENT=mapsplitgroup and nomapsplitgroup.

Conclusion

Safe to widen the build tag to (go1.20 && !go1.28) || untested_go_version. This was tested on darwin/arm64 only, but since the struct definitions are textually
identical to swiss's copies, the layouts agree on every architecture. Worth also fixing the abi.SwissMapType/abi.OldMapType comment while you're in there.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants