Skip to content

Comments

pkg/util/hack: split map ABI for go1.25 and go1.26#66254

Open
hawkingrei wants to merge 16 commits intopingcap:masterfrom
hawkingrei:hack-map-abi-go126
Open

pkg/util/hack: split map ABI for go1.25 and go1.26#66254
hawkingrei wants to merge 16 commits intopingcap:masterfrom
hawkingrei:hack-map-abi-go126

Conversation

@hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Feb 13, 2026

What problem does this PR solve?

Issue Number: close #65761

Problem Summary:
pkg/util/hack/map_abi.go is hardcoded to the Go 1.25 swiss-map ABI and panics under Go 1.26. We need version-specific ABI definitions to keep the memory-aware map implementation working across both toolchains.

What changed and how does it work?

  • Added Go-version split for map ABI implementation in pkg/util/hack:
    • map_abi.go is now guarded by //go:build go1.25 && !go1.26
    • New file map_abi_go126.go is guarded by //go:build go1.26 && !go1.27
  • Kept the 1.25 implementation unchanged for the existing ABI path.
  • Added the 1.26 counterpart with the same structure and logic shape, while switching the runtime version guard to go1.26.
  • Updated pkg/util/hack/BUILD.bazel to include the new source file.

Check List

Tests

  • Unit test

test it with go1.26.0

#66256

  • Integration test
  • Manual test (add detailed scripts or steps below)

It can compile with go1.26

image
  • No need to test
    • I checked and no code files have been changed.
    • This change only introduces Go-version build-tag split and keeps per-version runtime logic equivalent.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 13, 2026
@pantheon-ai
Copy link

pantheon-ai bot commented Feb 13, 2026

✅ Review completed. No issues found. The PR looks good to merge.

@ti-chi-bot ti-chi-bot bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 13, 2026
@D3Hunter
Copy link
Contributor

D3Hunter commented Feb 13, 2026

maybe just re-install golang 1.25 locally. i don't think we should pollute the main branch, just for workaround compiling tidb with go 1.26, we can wait golang fix it in later 1.26 fix version

or maybe you can file a PR to golang and fix the compile issue

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Copy link

@pantheon-ai pantheon-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Code looks good. No issues found.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 13, 2026

@pantheon-ai[bot]: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

✅ Code looks good. No issues found.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 13, 2026
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.5161%. Comparing base (3b69f59) to head (5d16af1).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66254        +/-   ##
================================================
- Coverage   77.6934%   77.5161%   -0.1773%     
================================================
  Files          2006       1928        -78     
  Lines        548247     535790     -12457     
================================================
- Hits         425952     415324     -10628     
+ Misses       120635     120460       -175     
+ Partials       1660          6      -1654     
Flag Coverage Δ
integration 41.4024% <ø> (-6.7858%) ⬇️
unit 76.6309% <ø> (+0.2946%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7997% <ø> (-12.0881%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// See the License for the specific language governing permissions and
// limitations under the License.

//go:build go1.25 && !go1.26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the build process add go1.25 tag? I didn't find the doc related to it 😂

And seems we only need one version tag?

//go:build go1.25
//go:build go1.26

should be enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini says it's called ReleaseTags, golang will assign all tags <= current version, so we should use

//go:build go1.25 && !go1.26

However I didn't find the official document for it. Do you have more authorized materials for this feature?

@lance6716
Copy link
Contributor

maybe just re-install golang 1.25 locally. i don't think we should pollute the main branch, just for workaround compiling tidb with go 1.26, we can wait golang fix it in later 1.26 fix version

or maybe you can file a PR to golang and fix the compile issue

As #65761 and this comment, we can pin the version of golang used to compile TiDB. But if golang can't reliably pin a version for developer, as the situation of your development environment @hawkingrei , I'm good for this PR.

@D3Hunter
Copy link
Contributor

D3Hunter commented Feb 13, 2026

/hold

please try fix the issue in golang itself, not workaround like this, it's an overkill for tidb repo, and the same issue might occur at other golang repo too, fixing the issue in golang is more appropriate

I hold it, in case anyone approve this pr, i think we need more discussion

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2026
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 13, 2026
@hawkingrei
Copy link
Member Author

/hold

please try fix the issue in golang itself, not workaround like this, it's an overkill for tidb repo, and the same issue might occur at other golang repo too, fixing the issue in golang is more appropriate

I hold it, in case anyone approve this pr, i think we need more discussion

It's impossible unless Go itself reverts those map changes.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 13, 2026
@D3Hunter
Copy link
Contributor

D3Hunter commented Feb 13, 2026

/hold
please try fix the issue in golang itself, not workaround like this, it's an overkill for tidb repo, and the same issue might occur at other golang repo too, fixing the issue in golang is more appropriate
I hold it, in case anyone approve this pr, i think we need more discussion

It's impossible unless Go itself reverts those map changes.

seems i have some mis-understanding of the problem we are facing.

anyway i hate the idea that we have to file a PR like this every time golang release a new version. i prefer we use or modify the implementation of CRDB directly, if we want to estimate the memory taken by the map, and i check the number of callsites that depends on the memory is not that large

@hawkingrei
Copy link
Member Author

/retest

// Number of slots in a group.
const mapGroupSlots = 1 << mapGroupSlotsBits // 8

// $GOROOT/src/internal/runtime/maps/table.go:`type table struct`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can AI tools help to add and check memory size & layout of such struct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a new skills for it. we can add this new skills in the next PR.

Copy link
Contributor

@solotzg solotzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 14, 2026

@solotzg: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hawkingrei
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 14, 2026
@hawkingrei hawkingrei requested a review from lance6716 February 14, 2026 05:14
@hawkingrei
Copy link
Member Author

maybe just re-install golang 1.25 locally. i don't think we should pollute the main branch, just for workaround compiling tidb with go 1.26, we can wait golang fix it in later 1.26 fix version
or maybe you can file a PR to golang and fix the compile issue

As #65761 and this comment, we can pin the version of golang used to compile TiDB. But if golang can't reliably pin a version for developer, as the situation of your development environment @hawkingrei , I'm good for this PR.

It won't work, just like when I upgraded my system and couldn't compile TiDB anymore.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Feb 14, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 14, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-02-14 08:49:21.983907831 +0000 UTC m=+2014.998601291: ☑️ agreed by YangKeao.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pantheon-ai[bot], solotzg, YangKeao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with Go 1.26

5 participants