-
Notifications
You must be signed in to change notification settings - Fork 468
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
Ridiculous corner case on AtomicCell reads #345
Comments
A single update operation is somewhere on the order of around 10 ns, which means 2^32 updates in a loop would take 43 seconds. So in order for a torn read to happen, a reader thread would have to be paused for 43 seconds and then continue running at just the right moment in between two update operations. Considering how OS schedulers work and how unlikely that scenario is to happen, I wouldn't worry about it. Do my calculations seem correct? |
1 bit is reserved as the lock bit, so 2^31 updates is the correct number. I benched Full disclosure: I have a similar issue in swym's stm implementation, and I'm trying to get a feel for what, if anything, there is to do about it. |
Perhaps we should just use |
Having thought about this more, using Doing nothing looks like the best course of action. Thanks for checking this issue out, and sorry for the noise! |
Well, an extremely low probability is not 0 and using |
Might be better to use a rwlock on 32-bit platforms. The |
For
AtomicCell
's that use seqlocks, theusize
in the lock can, in some extreme scenario, wrap around in the middle of a read, causing the read validation to succeed even though the read is torn.Copying the repro from here: Amanieu/seqlock#3
I'm not sure if this worth caring about, but thought I'd post it anyway.
The text was updated successfully, but these errors were encountered: