Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes to work-stealing-queue #55629

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Small fixes to work-stealing-queue #55629

wants to merge 2 commits into from

Conversation

vchuravy
Copy link
Member

While working on #55542 I took a closer look at the Chase-Lev-Lê queue,
we implemented for the GC.

I noticed two things:

  1. As noticed in https://wingolog.org/archives/2022/10/03/on-correct-and-efficient-work-stealing-for-weak-memory-models the Lê implementation is liable to wrap around. Following Whippet here and the original Chase paper to calculate the size of the buffer https://github.com/wingo/whippet/blob/a180be0cbd3a77003192e50d094657b1e0a7af8c/src/shared-worklist.h#L201
  2. In the steal Lê uses a consume load, we mistakenly down-graded that to a relaxed load, when we should have upgraded it to a acquire load. It synchronizes with the release store in push.

@vchuravy vchuravy requested review from d-netto and gbaraldi August 29, 2024 15:24
@vtjnash
Copy link
Member

vtjnash commented Aug 29, 2024

In the steal Lê uses a consume load, we mistakenly down-graded that to a relaxed load,

In a GC language, that isn't necessary AFAIK

@gbaraldi
Copy link
Member

Right but that code isn't in a GCed language it's in the C part of it.

@d-netto
Copy link
Member

d-netto commented Aug 29, 2024

We have "a poor-man's GC" for purposes of managing the memory associated with the ws_array_t though.

I.e., whenever we need to expand a queue, we allocate a new ws_array_t, push the old one into the reclaim_set, and only after the end of the GC we go ahead and free all of the arrays in the reclaim_set.

I wonder if this makes it legal to use load_relaxed here.

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.

4 participants