-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: sync/atomic: add logical operations #31748
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
Comments
Do any non-x86 processors support these operations? How often do they really come up in practice? What existing code could be simplified by using these operations? |
One data point: we use |
While this is useful, I think this would best be made into a third party library, unless if the Go compiler itself could be optimized with this somehow. |
No
Any data structure with flags changing a lot. RWMutex means a lot slower, CAS'd mean a bit slower and more complex code. I will look around if there's anything concrete we could improve.
I agree on one hand, on the other I opened this proposal because we already use and8, or8 internally and it's such a critical thing that, as a dev, I would rather have it come from core than 3rd party libs. |
I did some quick searches with grep and didn't find any good new candidates, hence closing. I'm keen to contribute in this area if there were any opportunities in the future. |
I've filed proposal #61395 with a more limited scope (just AND/OR operations). |
x86, x64 support atomic instructions for NOT, AND, OR, XOR. I believe, exposing them has some advantages:
As for other architectures, implementing these operations in assembly should yield some considerable speed-up and said cleaner code.
Example application: bloom filters.
Example AND/OR implementations for int64, amd64:
The text was updated successfully, but these errors were encountered: