Hey Maxim, > The "*(lock) == 0" check here is just an optimization, it only > ensures that the lock is likely to succed.
Yes, and use of the ngx_atomic_load() doesn't affect that. Namely, in the micro-benchmarks I did (heavy contention - 100 threads trying to acquire lock, update value, release lock in a loop), there is no performance lose while using ngx_atomic_load() on x86_64, whereas removing this optimization resulted in 3x worse performance. > If the > check returns a wrong result due to non-atomic load - this won't > do any harm. It's not just wrong result but a "data race", which leads to undefined behavior (at least according to C++11). Best regards, Piotr Sikora _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel