-
Notifications
You must be signed in to change notification settings - Fork 181
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
Implement pool
for any 32/64-bit architecture that supports the corresponding atomics.
#458
Conversation
e0f93ba
to
0bbdb26
Compare
do we know why the current code is impl'd only for x86? It could be because the treiber stack is only sound in x86 thanks to its stronger ordering guarantees. Or it could be because Would be good to know before we lift the restriction. I'm not familiar at all with these fancier atomics stuff. |
I think the trick here is that the trieber stack is susceptible to the ABA problem: https://en.wikipedia.org/wiki/Treiber_stack#Correctness On platforms with TRUE LL/SC atomics (e.g. Arm), this can be implemented correctly (tho might require custom asm? Unsure the state of things today, but see #180 and changes made in #315). However it looks like this trick (again, I'm out of the loop) is to allow this in cases where the platform supports atomics that are LARGER than pointer widths, so you can CAS a pointer AND a unique tag to avoid the ABA problem, or at least make it sufficiently rare. |
0bbdb26
to
93f1e84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading more about it, I think i'm somewhat comfortable with the x64 impl being sound if it uses AtomicU128. Shame it's nightly-only but it's better than nothing :)
Thanks for the link, I understand now what the problem is and how using a value twice the size of the pointer width fixes it. I have added an example explaining how it works, which is hopefully easy to follow. I guess technically it's still possible to be incorrect if one threads pops/pushes the top of the stack
I would expect because |
b4635a2
to
60d969f
Compare
b792778
to
d4cc41e
Compare
Closes #421.