Skip to content

Optimize join and spawn#38

Closed
Coldwings wants to merge 6 commits intomainfrom
dev/perf-improve
Closed

Optimize join and spawn#38
Coldwings wants to merge 6 commits intomainfrom
dev/perf-improve

Conversation

@Coldwings
Copy link
Owner

No description provided.

The mutex implementation had a data race between unlock() reading head->next_
and await_suspend() writing to the mutex state when multiple coroutines race.

Fixed by:
- Changing await_suspend() CAS to use memory_order_acq_rel (was memory_order_release)
- Changing unlock() initial load to memory_order_acquire (was memory_order_relaxed)

This ensures proper synchronization between the unlock and await_suspend paths.

Verified: All sync tests pass with ASAN and TSAN (198 assertions in 23 test cases)
@Coldwings Coldwings closed this Mar 24, 2026
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.

1 participant