Hacker News new | past | comments | ask | show | jobs | submit login

> Did you know seqlocks are undefined (benign race conditions)?

It wouldn't be undefined behavior if you used atomic variables--data races involving atomics aren't undefined behavior.




That is true in theory, but in practice it's not feasible. Even assuming you restrict to trivially copyable types, you either have to have a purely-atomic duplicate of anything that you want to store, or play games with trying to get a fast atomic memcpy.

Unless things have changed a lot in the past two years neither LLVM or GCC do that much optimisation around atomics so this comes with disastrous performance implications as well as overhead battling the standard.


Yes, a fast and safe seqlock is still elusive. We will hopefully get the misleadingly named std::atomic_memccpy at some point in the future.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: