Skip to content

TTAS slow path with adaptive backoff#8

Merged
hayabusa-cloud merged 2 commits into
mainfrom
ttas
Feb 16, 2026
Merged

TTAS slow path with adaptive backoff#8
hayabusa-cloud merged 2 commits into
mainfrom
ttas

Conversation

@hayabusa-cloud

Copy link
Copy Markdown
Owner

Summary

  • Rewrite Lock acquisition into a fast path / slow path split with TTAS (test-and-test-and-set).
  • Adaptive backoff in the slow path:
    • n < 4 waiters: Pause (spin, fast wakeup for short critical sections)
    • n >= 4 waiters: Gosched (yield CPU under heavy contention)
  • Also fixes a data race on yieldDuration by guarding it with spin.Lock.

Changes:

  • lock.go — Split Lock() into inline fast path + lockSlow() TTAS loop with adaptive backoff; document FAA/TTAS design in type and method comments
  • yield.go — Protect yieldDuration with spin.Lock for concurrent Yield/SetYieldDuration safety
  • go.mod, ci.yml — Bump Go 1.25 → 1.26

@hayabusa-cloud hayabusa-cloud changed the title spin: TTAS slow path with adaptive backoff TTAS slow path with adaptive backoff Feb 16, 2026
@codecov

codecov Bot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hayabusa-cloud hayabusa-cloud marked this pull request as ready for review February 16, 2026 13:03
Copilot AI review requested due to automatic review settings February 16, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a TTAS (test-and-test-and-set) lock acquisition strategy with adaptive backoff to improve performance under contention. The fast path uses a single FAA (Fetch-And-Add) operation, while the slow path spins on read-only loads to minimize cache-line invalidations before attempting acquisition. Additionally, the PR fixes a data race on yieldDuration by protecting it with a Lock, and updates the Go version from 1.25 to 1.26.

Changes:

  • Rewrites Lock() into fast path (inline FAA) and lockSlow() (TTAS with adaptive backoff)
  • Protects yieldDuration with Lock to enable safe concurrent access from Yield() and SetYieldDuration()
  • Updates Go version from 1.25 to 1.26 in go.mod and CI workflows

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lock.go Implements TTAS acquisition with fast/slow path split and iteration-based adaptive backoff; adds comprehensive documentation on FAA/MESI cache coherence
yield.go Adds Lock-based protection for yieldDuration to fix data race; documents concurrent safety
pause_test.go Updates comment to reflect new defaultPauseCycles value of 30
go.mod Bumps Go version from 1.25 to 1.26
.github/workflows/ci.yml Updates all CI jobs to use Go 1.26.x

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yield.go
Comment thread lock.go
@hayabusa-cloud hayabusa-cloud merged commit 88e1258 into main Feb 16, 2026
19 checks passed
@hayabusa-cloud hayabusa-cloud deleted the ttas branch February 16, 2026 13:17
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.

2 participants