Repository navigation
fix: drop Go 1.18, bump CI matrix to [1.19, 1.26] to resolve macOS ARM64 spinlock starvation - #386
Conversation
… OS scheduler After the exponential backoff in spinLock.Lock() is exhausted, use time.Sleep(time.Millisecond) instead of continuing to spin with only runtime.Gosched(). This prevents starvation on platforms with weaker scheduling fairness (e.g. Go 1.18 on ARM64 macOS) where hundreds of goroutines spinning with Gosched() can starve the lock holder. Co-authored-by: panjf2000 <7496278+panjf2000@users.noreply.github.com>
The CI failure on "Go 1.18 @ macos-latest" is caused by a known goroutine scheduler fairness issue in Go 1.18's runtime on ARM64 (Apple Silicon macOS). Under high spinlock contention, many goroutines calling runtime.Gosched() in a tight CAS loop starve the lock holder because Go 1.18's scheduler doesn't adequately reschedule in this scenario on ARM64. Go 1.19 improved the runtime scheduler's fairness guarantees, eliminating this class of starvation. This is why Go 1.19+ has never exhibited this issue. Changes: - Revert the time.Sleep workaround in spinlock (no longer needed) - Bump minimum Go version from 1.18 to 1.19 in go.mod - Update CI test matrix from [1.18, 1.23] to [1.19, 1.23] - Update README badges to reflect Go >= 1.19 Co-authored-by: panjf2000 <7496278+panjf2000@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #386 +/- ##
==========================================
- Coverage 94.54% 94.03% -0.51%
==========================================
Files 14 14
Lines 788 788
==========================================
- Hits 745 741 -4
- Misses 32 35 +3
- Partials 11 12 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: panjf2000 <7496278+panjf2000@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR raises the repository’s minimum supported Go version to 1.19 to address macOS ARM64 CI timeouts attributed to Go 1.18 scheduler fairness issues under spinlock contention, and aligns documentation/CI accordingly.
Changes:
- Bump module Go version from 1.18 to 1.19.
- Update CI test matrix from
[1.18, 1.23]to[1.19, 1.26]. - Update README badges to reflect Go
>= 1.19(English + Chinese).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
go.mod |
Updates the module’s go directive to 1.19. |
.github/workflows/test.yml |
Adjusts Go version test matrix to start at 1.19 and include a newer version. |
README.md |
Updates minimum Go version badge to >= 1.19. |
README_ZH.md |
Updates minimum Go version badge to >= 1.19. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <a title="Tag" target="_blank" href="https://github.com/panjf2000/ants/tags"><img src="https://img.shields.io/github/v/tag/panjf2000/ants?color=%23ff8936&logo=fitbit&style=flat-square" /></a> | ||
| <br/> | ||
| <a title="Minimum Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.18-30dff3?style=flat-square&logo=go" /></a> | ||
| <a title="Minimum Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.19-30dff3?style=flat-square&logo=go" /></a> |
| <a title="Tag" target="_blank" href="https://github.com/panjf2000/ants/tags"><img src="https://img.shields.io/github/v/tag/panjf2000/ants?color=%23ff8936&logo=fitbit&style=flat-square" /></a> | ||
| <br/> | ||
| <a title="Minimum Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.18-30dff3?style=flat-square&logo=go" /></a> | ||
| <a title="Minimum Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.19-30dff3?style=flat-square&logo=go" /></a> |
| fail-fast: false | ||
| matrix: | ||
| go: [1.18, 1.23] | ||
| go: [1.19, 1.26] |
1. Are you opening this pull request for bug-fixs, optimizations or new feature?
Bug fix — CI consistently times out on "Go 1.18 @ macos-latest" due to spinlock livelock.
2. Please describe how these code changes achieve your intention.
macos-latestnow runs on Apple Silicon (ARM64). Go 1.18's goroutine scheduler has a fairness deficiency on ARM64: under high spinlock contention, goroutines spinning on CAS +runtime.Gosched()starve the lock holder indefinitely. Go 1.19 fixed this in the runtime scheduler. This is why 1.19+ never exhibited the issue.The previous commit on this branch added
time.Sleep(time.Millisecond)as a workaround in the spinlock backoff — that's a band-aid for a Go 1.18 runtime bug. The proper fix is to drop 1.18 support.Changes:
pkg/sync/spinlock.go— reverttime.Sleepworkaround, restore clean backoff-only spinlockgo.mod—go 1.18→go 1.19.github/workflows/test.yml— CI matrix[1.18, 1.23]→[1.19, 1.26]README.md,README_ZH.md— minimum version badges≥1.18→≥1.193. Please link to the relevant issues (if any).
4. Which documentation changes (if any) need to be made/updated because of this PR?
README badges updated to reflect Go ≥ 1.19 (included in this PR).
4. Checklist
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.